Skip to content

Commit

Permalink
fib6: fix adding default route as first route
Browse files Browse the repository at this point in the history
[ upstream commit fd66617c5774a2869cbb69f86494d1b4803890fc ]

Currently when adding default route as first route
it is not added and no error is reported.
When we enter the loop over an address range in
the general case we will eventually reach the check
for when the range has ended, and exit the loop.
However when adding default route as first route,
since address range covered begins and ends at zero
this also triggers loop exit without writing to the table.

Fixed by adding check for default route,
i.e. both ledge and redge are equal to 0::0.

Bugzilla ID: 1272
Fixes: c3e12e0 ("fib: add dataplane algorithm for IPv6")

Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
  • Loading branch information
vmedvedk authored and bluca committed Oct 18, 2023
1 parent a4698a6 commit b4b6c87
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/librte_fib/trie.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,14 @@ get_nxt_net(uint8_t *ip, uint8_t depth)
}
}

static int
v6_addr_is_zero(const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE])
{
uint8_t ip_addr[RTE_FIB6_IPV6_ADDR_SIZE] = {0};

return rte_rib6_is_equal(ip, ip_addr);
}

static int
modify_dp(struct rte_trie_tbl *dp, struct rte_rib6 *rib,
const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE],
Expand Down Expand Up @@ -489,11 +497,19 @@ modify_dp(struct rte_trie_tbl *dp, struct rte_rib6 *rib,
return ret;
get_nxt_net(redge, tmp_depth);
rte_rib6_copy_addr(ledge, redge);
/*
* we got to the end of address space
* and wrapped around
*/
if (v6_addr_is_zero(ledge))
break;
} else {
rte_rib6_copy_addr(redge, ip);
get_nxt_net(redge, depth);
if (rte_rib6_is_equal(ledge, redge))
if (rte_rib6_is_equal(ledge, redge) &&
!v6_addr_is_zero(ledge))
break;

ret = install_to_dp(dp, ledge, redge,
next_hop);
if (ret != 0)
Expand Down

0 comments on commit b4b6c87

Please sign in to comment.