Skip to content

Commit

Permalink
fib: fix adding default route overwriting entire table
Browse files Browse the repository at this point in the history
[ upstream commit ab1b927cd73e96643cfe93dc2493d03c737b59ae ]

When FIB contains any route covering last IP address
(255.255.255.255), upon adding a new default route
the entire FIB table will be overwritten with corresponding
default route next hop.

Previous fix added check for ledge against 0 for case
if default route is added as a first route, however
this check was also erroneously triggered in case when
ledge was wrapped around the address space
(this would happen if FIB contains any route covering
last possible address - 255.255.255.255).

This fix prevents wrap around from happening.

Fixes: 880bc2b5f3bd ("fib: fix adding default route")

Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
  • Loading branch information
vmedvedk authored and bluca committed Oct 18, 2023
1 parent 9a4ca12 commit a4698a6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/librte_fib/dir24_8.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,12 @@ modify_fib(struct dir24_8_tbl *dp, struct rte_rib *rib, uint32_t ip,
return ret;
ledge = redge +
(uint32_t)(1ULL << (32 - tmp_depth));
/*
* we got to the end of address space
* and wrapped around
*/
if (ledge == 0)
break;
} else {
redge = ip + (uint32_t)(1ULL << (32 - depth));
if (ledge == redge && ledge != 0)
Expand Down

0 comments on commit a4698a6

Please sign in to comment.