Skip to content

Commit

Permalink
rib: fix traversal with /32 route
Browse files Browse the repository at this point in the history
[ upstream commit 1b984e9 ]

If a /32 route is entered in the RIB the code to traverse
will not see end of the tree. This is due to trying
to do a negative shift which is an undefined in C.

Fix by checking for max depth as is already done in rib6.

Fixes: 5a5793a ("rib: add RIB library")

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
  • Loading branch information
shemminger authored and kevintraynor committed Jun 8, 2022
1 parent 7bbf330 commit 6bbdd05
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/rib/rte_rib.c
Expand Up @@ -73,6 +73,8 @@ is_covered(uint32_t ip1, uint32_t ip2, uint8_t depth)
static inline struct rte_rib_node *
get_nxt_node(struct rte_rib_node *node, uint32_t ip)
{
if (node->depth == RIB_MAXDEPTH)
return NULL;
return (ip & (1 << (31 - node->depth))) ? node->right : node->left;
}

Expand Down

0 comments on commit 6bbdd05

Please sign in to comment.