Skip to content

Commit 5b7d616

Browse files
idoschdavem330
authored andcommitted
ipv4: fib: Send notification before deleting FIB alias
When a FIB alias is replaced following NLM_F_REPLACE, the ENTRY_ADD notification is sent after the reference on the previous FIB info was dropped. This is problematic as potential listeners might need to access it in their notification blocks. Solve this by sending the notification prior to the deletion of the replaced FIB alias. This is consistent with ENTRY_DEL notifications. Signed-off-by: Ido Schimmel <[email protected]> Signed-off-by: Jiri Pirko <[email protected]> CC: Patrick McHardy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 42d5aa7 commit 5b7d616

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

net/ipv4/fib_trie.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,13 @@ int fib_table_insert(struct net *net, struct fib_table *tb,
12951295
new_fa->tb_id = tb->tb_id;
12961296
new_fa->fa_default = -1;
12971297

1298+
call_fib_entry_notifiers(net, FIB_EVENT_ENTRY_ADD,
1299+
key, plen, fi,
1300+
new_fa->fa_tos, cfg->fc_type,
1301+
tb->tb_id, nlflags);
1302+
rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen,
1303+
tb->tb_id, &cfg->fc_nlinfo, nlflags);
1304+
12981305
hlist_replace_rcu(&fa->fa_list, &new_fa->fa_list);
12991306

13001307
alias_free_mem_rcu(fa);
@@ -1303,13 +1310,6 @@ int fib_table_insert(struct net *net, struct fib_table *tb,
13031310
if (state & FA_S_ACCESSED)
13041311
rt_cache_flush(cfg->fc_nlinfo.nl_net);
13051312

1306-
call_fib_entry_notifiers(net, FIB_EVENT_ENTRY_ADD,
1307-
key, plen, fi,
1308-
new_fa->fa_tos, cfg->fc_type,
1309-
tb->tb_id, cfg->fc_nlflags);
1310-
rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen,
1311-
tb->tb_id, &cfg->fc_nlinfo, nlflags);
1312-
13131313
goto succeeded;
13141314
}
13151315
/* Error if we find a perfect match which

0 commit comments

Comments
 (0)