转:http://blog.csdn.net/nerdx/article/details/12843647
-
-
-
1.1 static struct notifier_block fib_netdev_notifier = {
-
.notifier_call = fib_netdev_event,
-
};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
1.2 static int fib_netdev_event(struct notifier_block *this, unsigned long event, void *ptr)
-
{
-
struct net_device *dev = ptr;
-
struct in_device *in_dev = __in_dev_get(dev);
-
-
-
if (event == NETDEV_UNREGISTER) {
-
fib_disable_ip(dev, 2);
-
return NOTIFY_DONE;
-
}
-
-
if (!in_dev)
-
return NOTIFY_DONE;
-
-
switch (event) {
-
case NETDEV_UP:
-
-
for_ifa(in_dev) {
-
-
fib_add_ifaddr(ifa);
-
} endfor_ifa(in_dev);
-
-
#ifdef CONFIG_IP_ROUTE_MULTIPATH
-
fib_sync_up(dev);
-
#endif
-
-
rt_cache_flush(-1);
-
break;
-
case NETDEV_DOWN:
-
-
fib_disable_ip(dev, 0);
-
break;
-
-
case NETDEV_CHANGEMTU:
-
case NETDEV_CHANGE:
-
-
rt_cache_flush(0);
-
break;
-
}
-
return NOTIFY_DONE;
-
}
-
阅读(791) | 评论(0) | 转发(0) |