75cb76139ddc149bbfe56be3f9ec14e116b77dd3
2 * linux/drivers/net/netconsole.c
4 * Copyright (C) 2001 Ingo Molnar <mingo@redhat.com>
6 * This file contains the implementation of an IRQ-safe, crash-safe
7 * kernel console implementation that outputs kernel messages to the
10 * Modification history:
12 * 2001-09-17 started by Ingo Molnar.
13 * 2003-08-11 2.6 port by Matt Mackall
17 * 2003-09-07 rewritten with netpoll api
20 /****************************************************************
21 * This program is free software; you can redistribute it and/or modify
22 * it under the terms of the GNU General Public License as published by
23 * the Free Software Foundation; either version 2, or (at your option)
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program; if not, write to the Free Software
33 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
35 ****************************************************************/
38 #include <linux/init.h>
39 #include <linux/module.h>
40 #include <linux/console.h>
41 #include <linux/moduleparam.h>
42 #include <linux/string.h>
43 #include <linux/netpoll.h>
45 MODULE_AUTHOR("Maintainer: Matt Mackall <mpm@selenic.com>");
46 MODULE_DESCRIPTION("Console driver for network interfaces");
47 MODULE_LICENSE("GPL");
49 #define MAX_PARAM_LENGTH 256
50 #define MAX_PRINT_CHUNK 1000
52 static char config
[MAX_PARAM_LENGTH
];
53 module_param_string(netconsole
, config
, MAX_PARAM_LENGTH
, 0);
54 MODULE_PARM_DESC(netconsole
, " netconsole=[src-port]@[src-ip]/[dev],[tgt-port]@<tgt-ip>/[tgt-macaddr]\n");
57 static int __init
option_setup(char *opt
)
59 strlcpy(config
, opt
, MAX_PARAM_LENGTH
);
62 __setup("netconsole=", option_setup
);
65 static struct netpoll np
= {
70 .remote_mac
= {0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
73 static void write_msg(struct console
*con
, const char *msg
, unsigned int len
)
78 if (netif_running(np
.dev
)) {
79 local_irq_save(flags
);
80 for (left
= len
; left
;) {
81 frag
= min(left
, MAX_PRINT_CHUNK
);
82 netpoll_send_udp(&np
, msg
, frag
);
86 local_irq_restore(flags
);
90 static struct console netconsole
= {
92 .flags
= CON_ENABLED
| CON_PRINTBUFFER
,
96 static int __init
init_netconsole(void)
100 if (!strnlen(config
, MAX_PARAM_LENGTH
)) {
101 printk(KERN_INFO
"netconsole: not configured, aborting\n");
105 err
= netpoll_parse_options(&np
, config
);
109 err
= netpoll_setup(&np
);
113 register_console(&netconsole
);
114 printk(KERN_INFO
"netconsole: network logging started\n");
120 static void __exit
cleanup_netconsole(void)
122 unregister_console(&netconsole
);
123 netpoll_cleanup(&np
);
126 module_init(init_netconsole
);
127 module_exit(cleanup_netconsole
);
This page took 0.053276 seconds and 4 git commands to generate.