转:http://blog.csdn.net/nerdx/article/details/12843799
-
-
-
1.1 static struct notifier_block fib_inetaddr_notifier = {
-
.notifier_call = fib_inetaddr_event,
-
};
-
-
-
-
-
-
-
-
-
-
-
-
-
1.2 static int fib_inetaddr_event(struct notifier_block *this, unsigned long event, void *ptr)
-
{
-
struct in_ifaddr *ifa = (struct in_ifaddr*)ptr;
-
-
switch (event) {
-
-
case NETDEV_UP:
-
-
fib_add_ifaddr(ifa);
-
-
#ifdef CONFIG_IP_ROUTE_MULTIPATH
-
fib_sync_up(ifa->ifa_dev->dev);
-
#endif
-
-
rt_cache_flush(-1);
-
break;
-
-
case NETDEV_DOWN:
-
-
fib_del_ifaddr(ifa);
-
if (ifa->ifa_dev && ifa->ifa_dev->ifa_list == NULL) {
-
-
-
fib_disable_ip(ifa->ifa_dev->dev, 1);
-
} else {
-
-
rt_cache_flush(-1);
-
}
-
break;
-
}
-
return NOTIFY_DONE;
-
}
-
阅读(869) | 评论(0) | 转发(0) |