Commit 18a912e9 authored by Julian Anastasov's avatar Julian Anastasov Committed by David S. Miller

ipv4: fib_select_default should match the prefix

fib_trie starting from 4.1 can link fib aliases from
different prefixes in same list. Make sure the alternative
gateways are in same table and for same prefix (0) by
checking tb_id and fa_slen.

Fixes: 79e5ad2c ("fib_trie: Remove leaf_info")
Signed-off-by: default avatarJulian Anastasov <ja@ssi.bg>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c5dfd654
...@@ -1207,12 +1207,17 @@ void fib_select_default(struct fib_result *res) ...@@ -1207,12 +1207,17 @@ void fib_select_default(struct fib_result *res)
struct fib_info *fi = NULL, *last_resort = NULL; struct fib_info *fi = NULL, *last_resort = NULL;
struct hlist_head *fa_head = res->fa_head; struct hlist_head *fa_head = res->fa_head;
struct fib_table *tb = res->table; struct fib_table *tb = res->table;
u8 slen = 32 - res->prefixlen;
int order = -1, last_idx = -1; int order = -1, last_idx = -1;
struct fib_alias *fa; struct fib_alias *fa;
hlist_for_each_entry_rcu(fa, fa_head, fa_list) { hlist_for_each_entry_rcu(fa, fa_head, fa_list) {
struct fib_info *next_fi = fa->fa_info; struct fib_info *next_fi = fa->fa_info;
if (fa->fa_slen != slen)
continue;
if (fa->tb_id != tb->tb_id)
continue;
if (next_fi->fib_scope != res->scope || if (next_fi->fib_scope != res->scope ||
fa->fa_type != RTN_UNICAST) fa->fa_type != RTN_UNICAST)
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment