ipv4: fib: Only flush FIB aliases belonging to currently flushed table
authorIdo Schimmel <[email protected]>
Thu, 9 Feb 2017 09:28:38 +0000 (10:28 +0100)
committerDavid S. Miller <[email protected]>
Fri, 10 Feb 2017 16:32:12 +0000 (11:32 -0500)
In case the MAIN table is flushed and its trie is shared with the LOCAL
table, then we might be flushing FIB aliases belonging to the latter.
This can lead to FIB_ENTRY_DEL notifications sent with the wrong table
ID.

The above doesn't affect current listeners, as the table ID is ignored
during entry deletion, but this will change later in the patchset.

When flushing a particular table, skip any aliases belonging to a
different one.

Signed-off-by: Ido Schimmel <[email protected]>
Signed-off-by: Jiri Pirko <[email protected]>
CC: Alexander Duyck <[email protected]>
CC: Patrick McHardy <[email protected]>
Reviewed-by: Alexander Duyck <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
net/ipv4/fib_trie.c

index 2919d1a10cfdd83f4c68ee12ee6ba29ce8dcb989..5ef4596d7afcd28fc1c7b0d4f1e820cd65190586 100644 (file)
@@ -1963,7 +1963,8 @@ int fib_table_flush(struct net *net, struct fib_table *tb)
                hlist_for_each_entry_safe(fa, tmp, &n->leaf, fa_list) {
                        struct fib_info *fi = fa->fa_info;
 
-                       if (!fi || !(fi->fib_flags & RTNH_F_DEAD)) {
+                       if (!fi || !(fi->fib_flags & RTNH_F_DEAD) ||
+                           tb->tb_id != fa->tb_id) {
                                slen = fa->fa_slen;
                                continue;
                        }