From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, idosch@mellanox.com, eladr@mellanox.com,
yotamg@mellanox.com, nogahf@mellanox.com, arkadis@mellanox.com,
ogerlitz@mellanox.com, roopa@cumulusnetworks.com,
dsa@cumulusnetworks.com, nikolay@cumulusnetworks.com,
andy@greyhouse.net, vivien.didelot@savoirfairelinux.com,
andrew@lunn.ch, f.fainelli@gmail.com,
alexander.h.duyck@intel.com, hannes@stressinduktion.org,
kaber@trash.net
Subject: [patch net-next v4 09/10] ipv4: fib: Allow for consistent FIB dumping
Date: Sat, 3 Dec 2016 16:45:06 +0100 [thread overview]
Message-ID: <1480779907-32535-10-git-send-email-jiri@resnulli.us> (raw)
In-Reply-To: <1480779907-32535-1-git-send-email-jiri@resnulli.us>
From: Ido Schimmel <idosch@mellanox.com>
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>
---
include/net/netns/ipv4.h | 3 +++
net/ipv4/fib_frontend.c | 2 ++
net/ipv4/fib_trie.c | 1 +
3 files changed, 6 insertions(+)
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index 7adf438..f0cf5a1 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -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
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 121384b..dbad5a1 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -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);
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 9bfce0d..2891356 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -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);
}
--
2.7.4
next prev parent reply other threads:[~2016-12-03 15:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-03 15:44 [patch net-next v4 00/10] ipv4: fib: Replay events when registering FIB notifier Jiri Pirko
2016-12-03 15:44 ` [patch net-next v4 01/10] ipv4: fib: Export free_fib_info() Jiri Pirko
2016-12-03 15:44 ` [patch net-next v4 02/10] ipv4: fib: Add fib_info_hold() helper Jiri Pirko
2016-12-03 15:45 ` [patch net-next v4 03/10] mlxsw: core: Create an ordered workqueue for FIB offload Jiri Pirko
2016-12-03 15:45 ` [patch net-next v4 04/10] mlxsw: spectrum_router: Implement FIB offload in deferred work Jiri Pirko
2016-12-03 15:45 ` [patch net-next v4 05/10] rocker: Create an ordered workqueue for FIB offload Jiri Pirko
2016-12-03 15:45 ` [patch net-next v4 06/10] rocker: Implement FIB offload in deferred work Jiri Pirko
2016-12-03 15:45 ` [patch net-next v4 07/10] rocker: Register FIB notifier before creating ports Jiri Pirko
2016-12-03 15:45 ` [patch net-next v4 08/10] ipv4: fib: Convert FIB notification chain to be atomic Jiri Pirko
2016-12-03 15:45 ` Jiri Pirko [this message]
2016-12-03 15:45 ` [patch net-next v4 10/10] ipv4: fib: Replay events when registering FIB notifier Jiri Pirko
2016-12-04 0:30 ` [patch net-next v4 00/10] " David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1480779907-32535-10-git-send-email-jiri@resnulli.us \
--to=jiri@resnulli.us \
--cc=alexander.h.duyck@intel.com \
--cc=andrew@lunn.ch \
--cc=andy@greyhouse.net \
--cc=arkadis@mellanox.com \
--cc=davem@davemloft.net \
--cc=dsa@cumulusnetworks.com \
--cc=eladr@mellanox.com \
--cc=f.fainelli@gmail.com \
--cc=hannes@stressinduktion.org \
--cc=idosch@mellanox.com \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
--cc=nikolay@cumulusnetworks.com \
--cc=nogahf@mellanox.com \
--cc=ogerlitz@mellanox.com \
--cc=roopa@cumulusnetworks.com \
--cc=vivien.didelot@savoirfairelinux.com \
--cc=yotamg@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).