Skip to content

Commit 06c7427

Browse files
kaberdavem330
authored andcommitted
[FIB_TRIE]: Don't ignore negative results from fib_semantic_match
When a semantic match occurs either success, not found or an error (for matching unreachable routes/blackholes) is returned. fib_trie ignores the errors and looks for a different matching route. Treat results other than "no match" as success and end lookup. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0572e3d commit 06c7427

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
@@ -1333,9 +1333,9 @@ err:;
13331333
}
13341334

13351335
static inline int check_leaf(struct trie *t, struct leaf *l, t_key key, int *plen, const struct flowi *flp,
1336-
struct fib_result *res, int *err)
1336+
struct fib_result *res)
13371337
{
1338-
int i;
1338+
int err, i;
13391339
t_key mask;
13401340
struct leaf_info *li;
13411341
struct hlist_head *hhead = &l->list;
@@ -1348,18 +1348,18 @@ static inline int check_leaf(struct trie *t, struct leaf *l, t_key key, int *pl
13481348
if (l->key != (key & mask))
13491349
continue;
13501350

1351-
if (((*err) = fib_semantic_match(&li->falh, flp, res, l->key, mask, i)) == 0) {
1351+
if ((err = fib_semantic_match(&li->falh, flp, res, l->key, mask, i)) <= 0) {
13521352
*plen = i;
13531353
#ifdef CONFIG_IP_FIB_TRIE_STATS
13541354
t->stats.semantic_match_passed++;
13551355
#endif
1356-
return 1;
1356+
return err;
13571357
}
13581358
#ifdef CONFIG_IP_FIB_TRIE_STATS
13591359
t->stats.semantic_match_miss++;
13601360
#endif
13611361
}
1362-
return 0;
1362+
return 1;
13631363
}
13641364

13651365
static int
@@ -1386,7 +1386,7 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
13861386

13871387
/* Just a leaf? */
13881388
if (IS_LEAF(n)) {
1389-
if (check_leaf(t, (struct leaf *)n, key, &plen, flp, res, &ret))
1389+
if ((ret = check_leaf(t, (struct leaf *)n, key, &plen, flp, res)) <= 0)
13901390
goto found;
13911391
goto failed;
13921392
}
@@ -1508,7 +1508,7 @@ fn_trie_lookup(struct fib_table *tb, const struct flowi *flp, struct fib_result
15081508
continue;
15091509
}
15101510
if (IS_LEAF(n)) {
1511-
if (check_leaf(t, (struct leaf *)n, key, &plen, flp, res, &ret))
1511+
if ((ret = check_leaf(t, (struct leaf *)n, key, &plen, flp, res)) <= 0)
15121512
goto found;
15131513
}
15141514
backtrace:

0 commit comments

Comments
 (0)