aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/netconsole.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/netconsole.c')
-rw-r--r--drivers/net/netconsole.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index be15ca6205a8..55570988250b 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -80,6 +80,33 @@ static struct netconsole_target default_target = {
80 }, 80 },
81}; 81};
82 82
83/* Handle network interface device notifications */
84static int netconsole_netdev_event(struct notifier_block *this,
85 unsigned long event,
86 void *ptr)
87{
88 struct net_device *dev = ptr;
89 struct netconsole_target *nt = &default_target;
90
91 if (nt->np.dev == dev) {
92 switch (event) {
93 case NETDEV_CHANGEADDR:
94 memcpy(nt->np.local_mac, dev->dev_addr, ETH_ALEN);
95 break;
96
97 case NETDEV_CHANGENAME:
98 strlcpy(nt->np.dev_name, dev->name, IFNAMSIZ);
99 break;
100 }
101 }
102
103 return NOTIFY_DONE;
104}
105
106static struct notifier_block netconsole_netdev_notifier = {
107 .notifier_call = netconsole_netdev_event,
108};
109
83static void write_msg(struct console *con, const char *msg, unsigned int len) 110static void write_msg(struct console *con, const char *msg, unsigned int len)
84{ 111{
85 int frag, left; 112 int frag, left;
@@ -122,6 +149,10 @@ static int __init init_netconsole(void)
122 if (err) 149 if (err)
123 goto out; 150 goto out;
124 151
152 err = register_netdevice_notifier(&netconsole_netdev_notifier);
153 if (err)
154 goto out;
155
125 register_console(&netconsole); 156 register_console(&netconsole);
126 printk(KERN_INFO "netconsole: network logging started\n"); 157 printk(KERN_INFO "netconsole: network logging started\n");
127 158
@@ -134,6 +165,7 @@ static void __exit cleanup_netconsole(void)
134 struct netconsole_target *nt = &default_target; 165 struct netconsole_target *nt = &default_target;
135 166
136 unregister_console(&netconsole); 167 unregister_console(&netconsole);
168 unregister_netdevice_notifier(&netconsole_netdev_notifier);
137 netpoll_cleanup(&nt->np); 169 netpoll_cleanup(&nt->np);
138} 170}
139 171