[NET] netconsole: Introduce netconsole_target
Based upon initial work by Keiichi Kii <k-keiichi@bx.jp.nec.com>. Introduce a wrapper structure over netpoll to represent logging targets configured in netconsole. This will get extended with other members in further patches. This is done independent of the (to-be-introduced) NETCONSOLE_DYNAMIC config option so that we're able to drastically cut down on the #ifdef complexity of final netconsole.c. Also, struct netconsole_target would be required for multiple targets support also, and not just dynamic reconfigurability. Signed-off-by: Satyam Sharma <satyam@infradead.org> Signed-off-by: Keiichi Kii <k-keiichi@bx.jp.nec.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
8d4ef88b5d
commit
df180e369c
@@ -62,24 +62,35 @@ static int __init option_setup(char *opt)
|
|||||||
__setup("netconsole=", option_setup);
|
__setup("netconsole=", option_setup);
|
||||||
#endif /* MODULE */
|
#endif /* MODULE */
|
||||||
|
|
||||||
static struct netpoll np = {
|
/**
|
||||||
.name = "netconsole",
|
* struct netconsole_target - Represents a configured netconsole target.
|
||||||
.dev_name = "eth0",
|
* @np: The netpoll structure for this target.
|
||||||
.local_port = 6665,
|
*/
|
||||||
.remote_port = 6666,
|
struct netconsole_target {
|
||||||
.remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
|
struct netpoll np;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct netconsole_target default_target = {
|
||||||
|
.np = {
|
||||||
|
.name = "netconsole",
|
||||||
|
.dev_name = "eth0",
|
||||||
|
.local_port = 6665,
|
||||||
|
.remote_port = 6666,
|
||||||
|
.remote_mac = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static void write_msg(struct console *con, const char *msg, unsigned int len)
|
static void write_msg(struct console *con, const char *msg, unsigned int len)
|
||||||
{
|
{
|
||||||
int frag, left;
|
int frag, left;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
struct netconsole_target *nt = &default_target;
|
||||||
|
|
||||||
if (netif_running(np.dev)) {
|
if (netif_running(nt->np.dev)) {
|
||||||
local_irq_save(flags);
|
local_irq_save(flags);
|
||||||
for (left = len; left;) {
|
for (left = len; left;) {
|
||||||
frag = min(left, MAX_PRINT_CHUNK);
|
frag = min(left, MAX_PRINT_CHUNK);
|
||||||
netpoll_send_udp(&np, msg, frag);
|
netpoll_send_udp(&nt->np, msg, frag);
|
||||||
msg += frag;
|
msg += frag;
|
||||||
left -= frag;
|
left -= frag;
|
||||||
}
|
}
|
||||||
@@ -96,17 +107,18 @@ static struct console netconsole = {
|
|||||||
static int __init init_netconsole(void)
|
static int __init init_netconsole(void)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
struct netconsole_target *nt = &default_target;
|
||||||
|
|
||||||
if (!strnlen(config, MAX_PARAM_LENGTH)) {
|
if (!strnlen(config, MAX_PARAM_LENGTH)) {
|
||||||
printk(KERN_INFO "netconsole: not configured, aborting\n");
|
printk(KERN_INFO "netconsole: not configured, aborting\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = netpoll_parse_options(&np, config);
|
err = netpoll_parse_options(&nt->np, config);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
err = netpoll_setup(&np);
|
err = netpoll_setup(&nt->np);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@@ -119,8 +131,10 @@ out:
|
|||||||
|
|
||||||
static void __exit cleanup_netconsole(void)
|
static void __exit cleanup_netconsole(void)
|
||||||
{
|
{
|
||||||
|
struct netconsole_target *nt = &default_target;
|
||||||
|
|
||||||
unregister_console(&netconsole);
|
unregister_console(&netconsole);
|
||||||
netpoll_cleanup(&np);
|
netpoll_cleanup(&nt->np);
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(init_netconsole);
|
module_init(init_netconsole);
|
||||||
|
Reference in New Issue
Block a user