@@ -170,6 +170,8 @@ struct in_ifaddr {
extern int register_inetaddr_notifier(struct notifier_block *nb);
extern int unregister_inetaddr_notifier(struct notifier_block *nb);
+extern int register_iproute_notifier(struct notifier_block *nb);
+extern int unregister_iproute_notifier(struct notifier_block *nb);
extern struct net_device *__ip_dev_find(struct net *net, __be32 addr, bool devref);
static inline struct net_device *ip_dev_find(struct net *net, __be32 addr)
@@ -1540,6 +1540,7 @@ struct packet_type {
#define NETDEV_RELEASE 0x0012
#define NETDEV_NOTIFY_PEERS 0x0013
#define NETDEV_JOIN 0x0014
+#define NETDEV_ROUTE_CHANGED 0x0015
extern int register_netdevice_notifier(struct notifier_block *nb);
extern int unregister_netdevice_notifier(struct notifier_block *nb);
@@ -73,6 +73,7 @@
#include <linux/slab.h>
#include <linux/prefetch.h>
#include <linux/export.h>
+#include <linux/notifier.h>
#include <net/net_namespace.h>
#include <net/ip.h>
#include <net/protocol.h>
@@ -178,6 +179,8 @@ static const int sync_pages = 128;
static struct kmem_cache *fn_alias_kmem __read_mostly;
static struct kmem_cache *trie_leaf_kmem __read_mostly;
+static BLOCKING_NOTIFIER_HEAD(iproute_chain);
+
/*
* caller must hold RTNL
*/
@@ -1337,6 +1340,8 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg)
rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen, tb->tb_id,
&cfg->fc_nlinfo, 0);
succeeded:
+ blocking_notifier_call_chain(&iproute_chain,
+ NETDEV_ROUTE_CHANGED, fi);
return 0;
out_free_new_fa:
@@ -1713,6 +1718,8 @@ int fib_table_delete(struct fib_table *tb, struct fib_config *cfg)
if (fa->fa_state & FA_S_ACCESSED)
rt_cache_flush(cfg->fc_nlinfo.nl_net);
+ blocking_notifier_call_chain(&iproute_chain,
+ NETDEV_ROUTE_CHANGED, fa->fa_info);
fib_release_info(fa->fa_info);
alias_free_mem_rcu(fa);
return 0;
@@ -1979,6 +1986,17 @@ void __init fib_trie_init(void)
0, SLAB_PANIC, NULL);
}
+int register_iproute_notifier(struct notifier_block *nb)
+{
+ return blocking_notifier_chain_register(&iproute_chain, nb);
+}
+EXPORT_SYMBOL(register_iproute_notifier);
+
+int unregister_iproute_notifier(struct notifier_block *nb)
+{
+ return blocking_notifier_chain_unregister(&iproute_chain, nb);
+}
+EXPORT_SYMBOL(unregister_iproute_notifier);
struct fib_table *fib_trie_table(u32 id)
{
Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> --- include/linux/inetdevice.h | 2 ++ include/linux/netdevice.h | 1 + net/ipv4/fib_trie.c | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 0 deletions(-)