1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * linux/drivers/net/netconsole.c
5 * Copyright (C) 2001 Ingo Molnar <mingo@redhat.com>
7 * This file contains the implementation of an IRQ-safe, crash-safe
8 * kernel console implementation that outputs kernel messages to the
11 * Modification history:
13 * 2001-09-17 started by Ingo Molnar.
14 * 2003-08-11 2.6 port by Matt Mackall
18 * 2003-09-07 rewritten with netpoll api
21 /****************************************************************
23 ****************************************************************/
25 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
28 #include <linux/init.h>
29 #include <linux/module.h>
30 #include <linux/slab.h>
31 #include <linux/console.h>
32 #include <linux/moduleparam.h>
33 #include <linux/kernel.h>
34 #include <linux/string.h>
35 #include <linux/netpoll.h>
36 #include <linux/inet.h>
37 #include <linux/configfs.h>
38 #include <linux/etherdevice.h>
39 #include <linux/utsname.h>
41 MODULE_AUTHOR("Maintainer: Matt Mackall <mpm@selenic.com>");
42 MODULE_DESCRIPTION("Console driver for network interfaces");
43 MODULE_LICENSE("GPL");
45 #define MAX_PARAM_LENGTH 256
46 #define MAX_PRINT_CHUNK 1000
48 static char config[MAX_PARAM_LENGTH];
49 module_param_string(netconsole, config, MAX_PARAM_LENGTH, 0);
50 MODULE_PARM_DESC(netconsole, " netconsole=[src-port]@[src-ip]/[dev],[tgt-port]@<tgt-ip>/[tgt-macaddr]");
52 static bool oops_only = false;
53 module_param(oops_only, bool, 0600);
54 MODULE_PARM_DESC(oops_only, "Only log oops messages");
57 static int __init option_setup(char *opt)
59 strscpy(config, opt, MAX_PARAM_LENGTH);
62 __setup("netconsole=", option_setup);
65 /* Linked list of all configured targets */
66 static LIST_HEAD(target_list);
68 /* This needs to be a spinlock because write_msg() cannot sleep */
69 static DEFINE_SPINLOCK(target_list_lock);
72 * Console driver for extended netconsoles. Registered on the first use to
73 * avoid unnecessarily enabling ext message formatting.
75 static struct console netconsole_ext;
78 * struct netconsole_target - Represents a configured netconsole target.
79 * @list: Links this target into the target_list.
80 * @item: Links us into the configfs subsystem hierarchy.
81 * @enabled: On / off knob to enable / disable target.
82 * Visible from userspace (read-write).
83 * We maintain a strict 1:1 correspondence between this and
84 * whether the corresponding netpoll is active or inactive.
85 * Also, other parameters of a target may be modified at
86 * runtime only when it is disabled (enabled == 0).
87 * @extended: Denotes whether console is extended or not.
88 * @release: Denotes whether kernel release version should be prepended
89 * to the message. Depends on extended console.
90 * @np: The netpoll structure for this target.
91 * Contains the other userspace visible parameters:
92 * dev_name (read-write)
93 * local_port (read-write)
94 * remote_port (read-write)
95 * local_ip (read-write)
96 * remote_ip (read-write)
97 * local_mac (read-only)
98 * remote_mac (read-write)
100 struct netconsole_target {
101 struct list_head list;
102 #ifdef CONFIG_NETCONSOLE_DYNAMIC
103 struct config_item item;
111 #ifdef CONFIG_NETCONSOLE_DYNAMIC
113 static struct configfs_subsystem netconsole_subsys;
114 static DEFINE_MUTEX(dynamic_netconsole_mutex);
116 static int __init dynamic_netconsole_init(void)
118 config_group_init(&netconsole_subsys.su_group);
119 mutex_init(&netconsole_subsys.su_mutex);
120 return configfs_register_subsystem(&netconsole_subsys);
123 static void __exit dynamic_netconsole_exit(void)
125 configfs_unregister_subsystem(&netconsole_subsys);
129 * Targets that were created by parsing the boot/module option string
130 * do not exist in the configfs hierarchy (and have NULL names) and will
131 * never go away, so make these a no-op for them.
133 static void netconsole_target_get(struct netconsole_target *nt)
135 if (config_item_name(&nt->item))
136 config_item_get(&nt->item);
139 static void netconsole_target_put(struct netconsole_target *nt)
141 if (config_item_name(&nt->item))
142 config_item_put(&nt->item);
145 #else /* !CONFIG_NETCONSOLE_DYNAMIC */
147 static int __init dynamic_netconsole_init(void)
152 static void __exit dynamic_netconsole_exit(void)
157 * No danger of targets going away from under us when dynamic
158 * reconfigurability is off.
160 static void netconsole_target_get(struct netconsole_target *nt)
164 static void netconsole_target_put(struct netconsole_target *nt)
168 #endif /* CONFIG_NETCONSOLE_DYNAMIC */
170 /* Allocate and initialize with defaults.
171 * Note that these targets get their config_item fields zeroed-out.
173 static struct netconsole_target *alloc_and_init(void)
175 struct netconsole_target *nt;
177 nt = kzalloc(sizeof(*nt), GFP_KERNEL);
181 if (IS_ENABLED(CONFIG_NETCONSOLE_EXTENDED_LOG))
183 if (IS_ENABLED(CONFIG_NETCONSOLE_PREPEND_RELEASE))
186 nt->np.name = "netconsole";
187 strscpy(nt->np.dev_name, "eth0", IFNAMSIZ);
188 nt->np.local_port = 6665;
189 nt->np.remote_port = 6666;
190 eth_broadcast_addr(nt->np.remote_mac);
195 /* Allocate new target (from boot/module param) and setup netpoll for it */
196 static struct netconsole_target *alloc_param_target(char *target_config)
198 struct netconsole_target *nt;
201 nt = alloc_and_init();
207 if (*target_config == '+') {
212 if (*target_config == 'r') {
214 pr_err("Netconsole configuration error. Release feature requires extended log message");
222 /* Parse parameters and setup netpoll */
223 err = netpoll_parse_options(&nt->np, target_config);
227 err = netpoll_setup(&nt->np);
240 /* Cleanup netpoll for given target (from boot/module param) and free it */
241 static void free_param_target(struct netconsole_target *nt)
243 netpoll_cleanup(&nt->np);
247 #ifdef CONFIG_NETCONSOLE_DYNAMIC
250 * Our subsystem hierarchy is:
252 * /sys/kernel/config/netconsole/
268 static struct netconsole_target *to_target(struct config_item *item)
271 container_of(item, struct netconsole_target, item) :
276 * Attribute operations for netconsole_target.
279 static ssize_t enabled_show(struct config_item *item, char *buf)
281 return sysfs_emit(buf, "%d\n", to_target(item)->enabled);
284 static ssize_t extended_show(struct config_item *item, char *buf)
286 return sysfs_emit(buf, "%d\n", to_target(item)->extended);
289 static ssize_t release_show(struct config_item *item, char *buf)
291 return sysfs_emit(buf, "%d\n", to_target(item)->release);
294 static ssize_t dev_name_show(struct config_item *item, char *buf)
296 return sysfs_emit(buf, "%s\n", to_target(item)->np.dev_name);
299 static ssize_t local_port_show(struct config_item *item, char *buf)
301 return sysfs_emit(buf, "%d\n", to_target(item)->np.local_port);
304 static ssize_t remote_port_show(struct config_item *item, char *buf)
306 return sysfs_emit(buf, "%d\n", to_target(item)->np.remote_port);
309 static ssize_t local_ip_show(struct config_item *item, char *buf)
311 struct netconsole_target *nt = to_target(item);
314 return sysfs_emit(buf, "%pI6c\n", &nt->np.local_ip.in6);
316 return sysfs_emit(buf, "%pI4\n", &nt->np.local_ip);
319 static ssize_t remote_ip_show(struct config_item *item, char *buf)
321 struct netconsole_target *nt = to_target(item);
324 return sysfs_emit(buf, "%pI6c\n", &nt->np.remote_ip.in6);
326 return sysfs_emit(buf, "%pI4\n", &nt->np.remote_ip);
329 static ssize_t local_mac_show(struct config_item *item, char *buf)
331 struct net_device *dev = to_target(item)->np.dev;
332 static const u8 bcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
334 return sysfs_emit(buf, "%pM\n", dev ? dev->dev_addr : bcast);
337 static ssize_t remote_mac_show(struct config_item *item, char *buf)
339 return sysfs_emit(buf, "%pM\n", to_target(item)->np.remote_mac);
343 * This one is special -- targets created through the configfs interface
344 * are not enabled (and the corresponding netpoll activated) by default.
345 * The user is expected to set the desired parameters first (which
346 * would enable him to dynamically add new netpoll targets for new
347 * network interfaces as and when they come up).
349 static ssize_t enabled_store(struct config_item *item,
350 const char *buf, size_t count)
352 struct netconsole_target *nt = to_target(item);
357 mutex_lock(&dynamic_netconsole_mutex);
358 err = kstrtobool(buf, &enabled);
363 if ((bool)enabled == nt->enabled) {
364 pr_info("network logging has already %s\n",
365 nt->enabled ? "started" : "stopped");
369 if (enabled) { /* true */
370 if (nt->release && !nt->extended) {
371 pr_err("Not enabling netconsole. Release feature requires extended log message");
375 if (nt->extended && !console_is_registered(&netconsole_ext))
376 register_console(&netconsole_ext);
379 * Skip netpoll_parse_options() -- all the attributes are
380 * already configured via configfs. Just print them out.
382 netpoll_print_options(&nt->np);
384 err = netpoll_setup(&nt->np);
388 pr_info("network logging started\n");
390 /* We need to disable the netconsole before cleaning it up
391 * otherwise we might end up in write_msg() with
392 * nt->np.dev == NULL and nt->enabled == true
394 spin_lock_irqsave(&target_list_lock, flags);
396 spin_unlock_irqrestore(&target_list_lock, flags);
397 netpoll_cleanup(&nt->np);
400 nt->enabled = enabled;
402 mutex_unlock(&dynamic_netconsole_mutex);
403 return strnlen(buf, count);
405 mutex_unlock(&dynamic_netconsole_mutex);
409 static ssize_t release_store(struct config_item *item, const char *buf,
412 struct netconsole_target *nt = to_target(item);
416 mutex_lock(&dynamic_netconsole_mutex);
418 pr_err("target (%s) is enabled, disable to update parameters\n",
419 config_item_name(&nt->item));
424 err = kstrtobool(buf, &release);
428 nt->release = release;
430 mutex_unlock(&dynamic_netconsole_mutex);
431 return strnlen(buf, count);
433 mutex_unlock(&dynamic_netconsole_mutex);
437 static ssize_t extended_store(struct config_item *item, const char *buf,
440 struct netconsole_target *nt = to_target(item);
444 mutex_lock(&dynamic_netconsole_mutex);
446 pr_err("target (%s) is enabled, disable to update parameters\n",
447 config_item_name(&nt->item));
452 err = kstrtobool(buf, &extended);
456 nt->extended = extended;
458 mutex_unlock(&dynamic_netconsole_mutex);
459 return strnlen(buf, count);
461 mutex_unlock(&dynamic_netconsole_mutex);
465 static ssize_t dev_name_store(struct config_item *item, const char *buf,
468 struct netconsole_target *nt = to_target(item);
471 mutex_lock(&dynamic_netconsole_mutex);
473 pr_err("target (%s) is enabled, disable to update parameters\n",
474 config_item_name(&nt->item));
475 mutex_unlock(&dynamic_netconsole_mutex);
479 strscpy(nt->np.dev_name, buf, IFNAMSIZ);
481 /* Get rid of possible trailing newline from echo(1) */
482 len = strnlen(nt->np.dev_name, IFNAMSIZ);
483 if (nt->np.dev_name[len - 1] == '\n')
484 nt->np.dev_name[len - 1] = '\0';
486 mutex_unlock(&dynamic_netconsole_mutex);
487 return strnlen(buf, count);
490 static ssize_t local_port_store(struct config_item *item, const char *buf,
493 struct netconsole_target *nt = to_target(item);
496 mutex_lock(&dynamic_netconsole_mutex);
498 pr_err("target (%s) is enabled, disable to update parameters\n",
499 config_item_name(&nt->item));
503 rv = kstrtou16(buf, 10, &nt->np.local_port);
506 mutex_unlock(&dynamic_netconsole_mutex);
507 return strnlen(buf, count);
509 mutex_unlock(&dynamic_netconsole_mutex);
513 static ssize_t remote_port_store(struct config_item *item,
514 const char *buf, size_t count)
516 struct netconsole_target *nt = to_target(item);
519 mutex_lock(&dynamic_netconsole_mutex);
521 pr_err("target (%s) is enabled, disable to update parameters\n",
522 config_item_name(&nt->item));
526 rv = kstrtou16(buf, 10, &nt->np.remote_port);
529 mutex_unlock(&dynamic_netconsole_mutex);
530 return strnlen(buf, count);
532 mutex_unlock(&dynamic_netconsole_mutex);
536 static ssize_t local_ip_store(struct config_item *item, const char *buf,
539 struct netconsole_target *nt = to_target(item);
541 mutex_lock(&dynamic_netconsole_mutex);
543 pr_err("target (%s) is enabled, disable to update parameters\n",
544 config_item_name(&nt->item));
548 if (strnchr(buf, count, ':')) {
550 if (in6_pton(buf, count, nt->np.local_ip.in6.s6_addr, -1, &end) > 0) {
551 if (*end && *end != '\n') {
552 pr_err("invalid IPv6 address at: <%c>\n", *end);
560 nt->np.local_ip.ip = in_aton(buf);
565 mutex_unlock(&dynamic_netconsole_mutex);
566 return strnlen(buf, count);
568 mutex_unlock(&dynamic_netconsole_mutex);
572 static ssize_t remote_ip_store(struct config_item *item, const char *buf,
575 struct netconsole_target *nt = to_target(item);
577 mutex_lock(&dynamic_netconsole_mutex);
579 pr_err("target (%s) is enabled, disable to update parameters\n",
580 config_item_name(&nt->item));
584 if (strnchr(buf, count, ':')) {
586 if (in6_pton(buf, count, nt->np.remote_ip.in6.s6_addr, -1, &end) > 0) {
587 if (*end && *end != '\n') {
588 pr_err("invalid IPv6 address at: <%c>\n", *end);
596 nt->np.remote_ip.ip = in_aton(buf);
601 mutex_unlock(&dynamic_netconsole_mutex);
602 return strnlen(buf, count);
604 mutex_unlock(&dynamic_netconsole_mutex);
608 static ssize_t remote_mac_store(struct config_item *item, const char *buf,
611 struct netconsole_target *nt = to_target(item);
612 u8 remote_mac[ETH_ALEN];
614 mutex_lock(&dynamic_netconsole_mutex);
616 pr_err("target (%s) is enabled, disable to update parameters\n",
617 config_item_name(&nt->item));
621 if (!mac_pton(buf, remote_mac))
623 if (buf[3 * ETH_ALEN - 1] && buf[3 * ETH_ALEN - 1] != '\n')
625 memcpy(nt->np.remote_mac, remote_mac, ETH_ALEN);
627 mutex_unlock(&dynamic_netconsole_mutex);
628 return strnlen(buf, count);
630 mutex_unlock(&dynamic_netconsole_mutex);
634 CONFIGFS_ATTR(, enabled);
635 CONFIGFS_ATTR(, extended);
636 CONFIGFS_ATTR(, dev_name);
637 CONFIGFS_ATTR(, local_port);
638 CONFIGFS_ATTR(, remote_port);
639 CONFIGFS_ATTR(, local_ip);
640 CONFIGFS_ATTR(, remote_ip);
641 CONFIGFS_ATTR_RO(, local_mac);
642 CONFIGFS_ATTR(, remote_mac);
643 CONFIGFS_ATTR(, release);
645 static struct configfs_attribute *netconsole_target_attrs[] = {
660 * Item operations and type for netconsole_target.
663 static void netconsole_target_release(struct config_item *item)
665 kfree(to_target(item));
668 static struct configfs_item_operations netconsole_target_item_ops = {
669 .release = netconsole_target_release,
672 static const struct config_item_type netconsole_target_type = {
673 .ct_attrs = netconsole_target_attrs,
674 .ct_item_ops = &netconsole_target_item_ops,
675 .ct_owner = THIS_MODULE,
679 * Group operations and type for netconsole_subsys.
682 static struct config_item *make_netconsole_target(struct config_group *group,
685 struct netconsole_target *nt;
688 nt = alloc_and_init();
690 return ERR_PTR(-ENOMEM);
692 /* Initialize the config_item member */
693 config_item_init_type_name(&nt->item, name, &netconsole_target_type);
695 /* Adding, but it is disabled */
696 spin_lock_irqsave(&target_list_lock, flags);
697 list_add(&nt->list, &target_list);
698 spin_unlock_irqrestore(&target_list_lock, flags);
703 static void drop_netconsole_target(struct config_group *group,
704 struct config_item *item)
707 struct netconsole_target *nt = to_target(item);
709 spin_lock_irqsave(&target_list_lock, flags);
711 spin_unlock_irqrestore(&target_list_lock, flags);
714 * The target may have never been enabled, or was manually disabled
715 * before being removed so netpoll may have already been cleaned up.
718 netpoll_cleanup(&nt->np);
720 config_item_put(&nt->item);
723 static struct configfs_group_operations netconsole_subsys_group_ops = {
724 .make_item = make_netconsole_target,
725 .drop_item = drop_netconsole_target,
728 static const struct config_item_type netconsole_subsys_type = {
729 .ct_group_ops = &netconsole_subsys_group_ops,
730 .ct_owner = THIS_MODULE,
733 /* The netconsole configfs subsystem */
734 static struct configfs_subsystem netconsole_subsys = {
737 .ci_namebuf = "netconsole",
738 .ci_type = &netconsole_subsys_type,
743 #endif /* CONFIG_NETCONSOLE_DYNAMIC */
745 /* Handle network interface device notifications */
746 static int netconsole_netdev_event(struct notifier_block *this,
747 unsigned long event, void *ptr)
750 struct netconsole_target *nt;
751 struct net_device *dev = netdev_notifier_info_to_dev(ptr);
752 bool stopped = false;
754 if (!(event == NETDEV_CHANGENAME || event == NETDEV_UNREGISTER ||
755 event == NETDEV_RELEASE || event == NETDEV_JOIN))
758 spin_lock_irqsave(&target_list_lock, flags);
760 list_for_each_entry(nt, &target_list, list) {
761 netconsole_target_get(nt);
762 if (nt->np.dev == dev) {
764 case NETDEV_CHANGENAME:
765 strscpy(nt->np.dev_name, dev->name, IFNAMSIZ);
769 case NETDEV_UNREGISTER:
770 /* rtnl_lock already held
771 * we might sleep in __netpoll_cleanup()
773 spin_unlock_irqrestore(&target_list_lock, flags);
775 __netpoll_cleanup(&nt->np);
777 spin_lock_irqsave(&target_list_lock, flags);
778 netdev_put(nt->np.dev, &nt->np.dev_tracker);
782 netconsole_target_put(nt);
786 netconsole_target_put(nt);
788 spin_unlock_irqrestore(&target_list_lock, flags);
790 const char *msg = "had an event";
792 case NETDEV_UNREGISTER:
793 msg = "unregistered";
796 msg = "released slaves";
799 msg = "is joining a master device";
802 pr_info("network logging stopped on interface %s as it %s\n",
810 static struct notifier_block netconsole_netdev_notifier = {
811 .notifier_call = netconsole_netdev_event,
815 * send_ext_msg_udp - send extended log message to target
816 * @nt: target to send message to
817 * @msg: extended log message to send
818 * @msg_len: length of message
820 * Transfer extended log @msg to @nt. If @msg is longer than
821 * MAX_PRINT_CHUNK, it'll be split and transmitted in multiple chunks with
822 * ncfrag header field added to identify them.
824 static void send_ext_msg_udp(struct netconsole_target *nt, const char *msg,
827 static char buf[MAX_PRINT_CHUNK]; /* protected by target_list_lock */
828 const char *header, *body;
830 int header_len, body_len;
831 const char *msg_ready = msg;
836 release = init_utsname()->release;
837 release_len = strlen(release) + 1;
840 if (msg_len + release_len <= MAX_PRINT_CHUNK) {
841 /* No fragmentation needed */
843 scnprintf(buf, MAX_PRINT_CHUNK, "%s,%s", release, msg);
844 msg_len += release_len;
847 netpoll_send_udp(&nt->np, msg_ready, msg_len);
851 /* need to insert extra header fields, detect header and body */
853 body = memchr(msg, ';', msg_len);
854 if (WARN_ON_ONCE(!body))
857 header_len = body - header;
858 body_len = msg_len - header_len - 1;
862 * Transfer multiple chunks with the following extra header.
863 * "ncfrag=<byte-offset>/<total-bytes>"
866 scnprintf(buf, MAX_PRINT_CHUNK, "%s,", release);
867 memcpy(buf + release_len, header, header_len);
868 header_len += release_len;
870 while (offset < body_len) {
871 int this_header = header_len;
874 this_header += scnprintf(buf + this_header,
875 sizeof(buf) - this_header,
876 ",ncfrag=%d/%d;", offset, body_len);
878 this_chunk = min(body_len - offset,
879 MAX_PRINT_CHUNK - this_header);
880 if (WARN_ON_ONCE(this_chunk <= 0))
883 memcpy(buf + this_header, body + offset, this_chunk);
885 netpoll_send_udp(&nt->np, buf, this_header + this_chunk);
887 offset += this_chunk;
891 static void write_ext_msg(struct console *con, const char *msg,
894 struct netconsole_target *nt;
897 if ((oops_only && !oops_in_progress) || list_empty(&target_list))
900 spin_lock_irqsave(&target_list_lock, flags);
901 list_for_each_entry(nt, &target_list, list)
902 if (nt->extended && nt->enabled && netif_running(nt->np.dev))
903 send_ext_msg_udp(nt, msg, len);
904 spin_unlock_irqrestore(&target_list_lock, flags);
907 static void write_msg(struct console *con, const char *msg, unsigned int len)
911 struct netconsole_target *nt;
914 if (oops_only && !oops_in_progress)
916 /* Avoid taking lock and disabling interrupts unnecessarily */
917 if (list_empty(&target_list))
920 spin_lock_irqsave(&target_list_lock, flags);
921 list_for_each_entry(nt, &target_list, list) {
922 if (!nt->extended && nt->enabled && netif_running(nt->np.dev)) {
924 * We nest this inside the for-each-target loop above
925 * so that we're able to get as much logging out to
926 * at least one target if we die inside here, instead
927 * of unnecessarily keeping all targets in lock-step.
930 for (left = len; left;) {
931 frag = min(left, MAX_PRINT_CHUNK);
932 netpoll_send_udp(&nt->np, tmp, frag);
938 spin_unlock_irqrestore(&target_list_lock, flags);
941 static struct console netconsole_ext = {
942 .name = "netcon_ext",
943 .flags = CON_ENABLED | CON_EXTENDED,
944 .write = write_ext_msg,
947 static struct console netconsole = {
949 .flags = CON_ENABLED,
953 static int __init init_netconsole(void)
956 struct netconsole_target *nt, *tmp;
957 bool extended = false;
960 char *input = config;
962 if (strnlen(input, MAX_PARAM_LENGTH)) {
963 while ((target_config = strsep(&input, ";"))) {
964 nt = alloc_param_target(target_config);
969 /* Dump existing printks when we register */
972 netconsole_ext.flags |= CON_PRINTBUFFER;
974 netconsole.flags |= CON_PRINTBUFFER;
977 spin_lock_irqsave(&target_list_lock, flags);
978 list_add(&nt->list, &target_list);
979 spin_unlock_irqrestore(&target_list_lock, flags);
983 err = register_netdevice_notifier(&netconsole_netdev_notifier);
987 err = dynamic_netconsole_init();
992 register_console(&netconsole_ext);
993 register_console(&netconsole);
994 pr_info("network logging started\n");
999 unregister_netdevice_notifier(&netconsole_netdev_notifier);
1002 pr_err("cleaning up\n");
1005 * Remove all targets and destroy them (only targets created
1006 * from the boot/module option exist here). Skipping the list
1007 * lock is safe here, and netpoll_cleanup() will sleep.
1009 list_for_each_entry_safe(nt, tmp, &target_list, list) {
1010 list_del(&nt->list);
1011 free_param_target(nt);
1017 static void __exit cleanup_netconsole(void)
1019 struct netconsole_target *nt, *tmp;
1021 if (console_is_registered(&netconsole_ext))
1022 unregister_console(&netconsole_ext);
1023 unregister_console(&netconsole);
1024 dynamic_netconsole_exit();
1025 unregister_netdevice_notifier(&netconsole_netdev_notifier);
1028 * Targets created via configfs pin references on our module
1029 * and would first be rmdir(2)'ed from userspace. We reach
1030 * here only when they are already destroyed, and only those
1031 * created from the boot/module option are left, so remove and
1032 * destroy them. Skipping the list lock is safe here, and
1033 * netpoll_cleanup() will sleep.
1035 list_for_each_entry_safe(nt, tmp, &target_list, list) {
1036 list_del(&nt->list);
1037 free_param_target(nt);
1042 * Use late_initcall to ensure netconsole is
1043 * initialized after network device driver if built-in.
1045 * late_initcall() and module_init() are identical if built as module.
1047 late_initcall(init_netconsole);
1048 module_exit(cleanup_netconsole);