]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ipv4: fib: Allow for consistent FIB dumping
authorIdo Schimmel <idosch@mellanox.com>
Sat, 3 Dec 2016 15:45:06 +0000 (16:45 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 4 Dec 2016 00:29:35 +0000 (19:29 -0500)
The next patch will enable listeners of the FIB notification chain to
request a dump of the FIB tables. However, since RTNL isn't taken during
the dump, it's possible for the FIB tables to change mid-dump, which
will result in inconsistency between the listener's table and the
kernel's.

Allow listeners to know about changes that occurred mid-dump, by adding
a change sequence counter to each net namespace. The counter is
incremented just before a notification is sent in the FIB chain.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/netns/ipv4.h
net/ipv4/fib_frontend.c
net/ipv4/fib_trie.c

index 7adf4386ac8fa644cf41198ef028c369dcbe02e0..f0cf5a1b777e4d4c37c0b927f5c9ee7bfd78fd64 100644 (file)
@@ -135,6 +135,9 @@ struct netns_ipv4 {
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
        int sysctl_fib_multipath_use_neigh;
 #endif
+
+       unsigned int    fib_seq;        /* protected by rtnl_mutex */
+
        atomic_t        rt_genid;
 };
 #endif
index 121384bbb40ba24163c5aca2b84c8bd6bfb38f93..dbad5a1c161aac81152bfbfb6dd6c53cd946dc02 100644 (file)
@@ -1219,6 +1219,8 @@ static int __net_init ip_fib_net_init(struct net *net)
        int err;
        size_t size = sizeof(struct hlist_head) * FIB_TABLE_HASHSZ;
 
+       net->ipv4.fib_seq = 0;
+
        /* Avoid false sharing : Use at least a full cache line */
        size = max_t(size_t, size, L1_CACHE_BYTES);
 
index 9bfce0df20dce5cc0a7969b3db63d2fe53890f23..28913563e7cdb90d6cd5f83842513a36ade2f6f1 100644 (file)
@@ -101,6 +101,7 @@ EXPORT_SYMBOL(unregister_fib_notifier);
 int call_fib_notifiers(struct net *net, enum fib_event_type event_type,
                       struct fib_notifier_info *info)
 {
+       net->ipv4.fib_seq++;
        info->net = net;
        return atomic_notifier_call_chain(&fib_chain, event_type, info);
 }