39 #include <linux/module.h>
40 #include <linux/slab.h>
43 #include <linux/string.h>
52 #define MAX_PARAM_LENGTH 256
53 #define MAX_PRINT_CHUNK 1000
57 MODULE_PARM_DESC(netconsole,
" netconsole=[src-port]@[src-ip]/[dev],[tgt-port]@<tgt-ip>/[tgt-macaddr]");
96 #ifdef CONFIG_NETCONSOLE_DYNAMIC
103 #ifdef CONFIG_NETCONSOLE_DYNAMIC
107 static int __init dynamic_netconsole_init(
void)
114 static void __exit dynamic_netconsole_exit(
void)
126 if (config_item_name(&nt->item))
132 if (config_item_name(&nt->item))
138 static int __init dynamic_netconsole_init(
void)
143 static void __exit dynamic_netconsole_exit(
void)
175 nt->
np.name =
"netconsole";
177 nt->
np.local_port = 6665;
178 nt->
np.remote_port = 6666;
206 #ifdef CONFIG_NETCONSOLE_DYNAMIC
226 struct netconsole_target_attr {
279 static const u8 bcast[
ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
306 if (enabled < 0 || enabled > 1)
310 nt->
enabled ?
"started" :
"stopped");
345 "disable to update parameters\n",
346 config_item_name(&nt->item));
354 if (nt->
np.dev_name[len - 1] ==
'\n')
355 nt->
np.dev_name[len - 1] =
'\0';
368 "disable to update parameters\n",
369 config_item_name(&nt->item));
387 "disable to update parameters\n",
388 config_item_name(&nt->item));
404 "disable to update parameters\n",
405 config_item_name(&nt->item));
420 "disable to update parameters\n",
421 config_item_name(&nt->item));
438 "disable to update parameters\n",
439 config_item_name(&nt->item));
456 #define NETCONSOLE_TARGET_ATTR_RO(_name) \
457 static struct netconsole_target_attr netconsole_target_##_name = \
458 __CONFIGFS_ATTR(_name, S_IRUGO, show_##_name, NULL)
460 #define NETCONSOLE_TARGET_ATTR_RW(_name) \
461 static struct netconsole_target_attr netconsole_target_##_name = \
462 __CONFIGFS_ATTR(_name, S_IRUGO | S_IWUSR, show_##_name, store_##_name)
464 NETCONSOLE_TARGET_ATTR_RW(enabled);
465 NETCONSOLE_TARGET_ATTR_RW(dev_name);
468 NETCONSOLE_TARGET_ATTR_RW(local_ip);
469 NETCONSOLE_TARGET_ATTR_RW(remote_ip);
470 NETCONSOLE_TARGET_ATTR_RO(local_mac);
471 NETCONSOLE_TARGET_ATTR_RW(remote_mac);
474 &netconsole_target_enabled.attr,
475 &netconsole_target_dev_name.attr,
476 &netconsole_target_local_port.attr,
477 &netconsole_target_remote_port.attr,
478 &netconsole_target_local_ip.attr,
479 &netconsole_target_remote_ip.attr,
480 &netconsole_target_local_mac.attr,
481 &netconsole_target_remote_mac.attr,
489 static void netconsole_target_release(
struct config_item *item)
491 kfree(to_target(item));
500 struct netconsole_target_attr *na =
501 container_of(attr,
struct netconsole_target_attr, attr);
504 ret = na->show(nt, buf);
516 struct netconsole_target_attr *na =
517 container_of(attr,
struct netconsole_target_attr, attr);
520 ret = na->store(nt, buf, count);
526 .
release = netconsole_target_release,
527 .show_attribute = netconsole_target_attr_show,
528 .store_attribute = netconsole_target_attr_store,
532 .
ct_attrs = netconsole_target_attrs,
533 .ct_item_ops = &netconsole_target_item_ops,
555 nt->
np.name =
"netconsole";
557 nt->
np.local_port = 6665;
558 nt->
np.remote_port = 6666;
566 list_add(&nt->
list, &target_list);
567 spin_unlock_irqrestore(&target_list_lock, flags);
572 static void drop_netconsole_target(
struct config_group *group,
580 spin_unlock_irqrestore(&target_list_lock, flags);
594 .drop_item = drop_netconsole_target,
606 .ci_namebuf =
"netconsole",
607 .ci_type = &netconsole_subsys_type,
630 netconsole_target_get(nt);
631 if (nt->
np.dev == dev) {
652 netconsole_target_put(nt);
654 spin_unlock_irqrestore(&target_list_lock, flags);
657 "interface %s as it ", dev->
name);
676 .notifier_call = netconsole_netdev_event,
679 static void write_msg(
struct console *
con,
const char *
msg,
unsigned int len)
687 if (list_empty(&target_list))
692 netconsole_target_get(nt);
693 if (nt->
enabled && netif_running(nt->
np.dev)) {
701 for (left = len;
left;) {
708 netconsole_target_put(nt);
710 spin_unlock_irqrestore(&target_list_lock, flags);
713 static struct console netconsole = {
719 static int __init init_netconsole(
void)
728 while ((target_config =
strsep(&input,
";"))) {
729 nt = alloc_param_target(target_config);
738 list_add(&nt->
list, &target_list);
739 spin_unlock_irqrestore(&target_list_lock, flags);
747 err = dynamic_netconsole_init();
769 free_param_target(nt);
775 static void __exit cleanup_netconsole(
void)
780 dynamic_netconsole_exit();
793 free_param_target(nt);