[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191002084103.12138-11-idosch@idosch.org>
Date: Wed, 2 Oct 2019 11:40:58 +0300
From: Ido Schimmel <idosch@...sch.org>
To: netdev@...r.kernel.org
Cc: davem@...emloft.net, dsahern@...il.com, jiri@...lanox.com,
jakub.kicinski@...ronome.com, saeedm@...lanox.com,
mlxsw@...lanox.com, Ido Schimmel <idosch@...lanox.com>
Subject: [RFC PATCH net-next 10/15] ipv4: Replace route in list before notifying
From: Ido Schimmel <idosch@...lanox.com>
Subsequent patches will add an 'in_hw' flag to routes which will signal
if the route is present in hardware or not.
After programming the route to the hardware, drivers will have to ask
the IPv4 code to set the flag by passing the route's key.
In the case of route replace, the new route is notified before it is
actually inserted into the FIB alias list. This can prevent simple
drivers (e.g., netdevsim) that program the route to the hardware in the
same context it is notified in from being able to set the flag.
Solve this by first inserting the new route to the list and rollback the
operation in case the route was vetoed.
Signed-off-by: Ido Schimmel <idosch@...lanox.com>
---
net/ipv4/fib_trie.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index cbb41eebb43b..9ea9610eebfd 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -1237,23 +1237,26 @@ int fib_table_insert(struct net *net, struct fib_table *tb,
new_fa->tb_id = tb->tb_id;
new_fa->fa_default = -1;
+ hlist_replace_rcu(&fa->fa_list, &new_fa->fa_list);
+
if (fib_find_first_alias(&l->leaf, fa->fa_slen,
- tb->tb_id) == fa) {
+ tb->tb_id) == new_fa) {
enum fib_event_type fib_event;
fib_event = FIB_EVENT_ENTRY_REPLACE;
err = call_fib_entry_notifiers(net, fib_event,
key, plen,
new_fa, extack);
- if (err)
+ if (err) {
+ hlist_replace_rcu(&new_fa->fa_list,
+ &fa->fa_list);
goto out_free_new_fa;
+ }
}
rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen,
tb->tb_id, &cfg->fc_nlinfo, nlflags);
- hlist_replace_rcu(&fa->fa_list, &new_fa->fa_list);
-
alias_free_mem_rcu(fa);
fib_release_info(fi_drop);
--
2.21.0
Powered by blists - more mailing lists