Merge pull request #16342 from pguibert6WIND/duplicate_fib_proposal

Duplicate fib proposal
This commit is contained in:
Mark Stapp 2024-07-09 13:48:37 -04:00 committed by GitHub
commit 7d08b29721
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 32 additions and 8 deletions

View File

@ -320,7 +320,7 @@ def check_ipv4_prefix_recursive_with_multiple_nexthops(
) )
test_func = functools.partial( test_func = functools.partial(
ip_check_path_selection, tgen.gears["r1"], prefix, expected ip_check_path_selection, tgen.gears["r1"], prefix, expected, check_fib=True
) )
_, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5) _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
assert ( assert (

View File

@ -23,7 +23,7 @@
"recursive":true "recursive":true
}, },
{ {
"fib":true, "duplicate":true,
"ip":"10.0.3.2", "ip":"10.0.3.2",
"active":true "active":true
} }

View File

@ -23,7 +23,7 @@
"recursive":true "recursive":true
}, },
{ {
"fib":true, "duplicate":true,
"ip":"10.0.3.2", "ip":"10.0.3.2",
"active":true "active":true
} }

View File

@ -10,11 +10,13 @@ import json
from lib import topotest from lib import topotest
def ip_check_path_selection(router, ipaddr_str, expected, vrf_name=None): def ip_check_path_selection(
router, ipaddr_str, expected, vrf_name=None, check_fib=False
):
if vrf_name: if vrf_name:
cmdstr = f'show ip route vrf {vrf_name} {ipaddr_str} json' cmdstr = f"show ip route vrf {vrf_name} {ipaddr_str} json"
else: else:
cmdstr = f'show ip route {ipaddr_str} json' cmdstr = f"show ip route {ipaddr_str} json"
try: try:
output = json.loads(router.vtysh_cmd(cmdstr)) output = json.loads(router.vtysh_cmd(cmdstr))
except: except:
@ -25,6 +27,21 @@ def ip_check_path_selection(router, ipaddr_str, expected, vrf_name=None):
num_nh_expected = len(expected[ipaddr_str][0]["nexthops"]) num_nh_expected = len(expected[ipaddr_str][0]["nexthops"])
num_nh_observed = len(output[ipaddr_str][0]["nexthops"]) num_nh_observed = len(output[ipaddr_str][0]["nexthops"])
if num_nh_expected == num_nh_observed: if num_nh_expected == num_nh_observed:
if check_fib:
# special case: when fib flag is unset,
# an extra test should be done to check that the flag is really unset
for nh_output, nh_expected in zip(
output[ipaddr_str][0]["nexthops"],
expected[ipaddr_str][0]["nexthops"],
):
if (
"fib" in nh_output.keys()
and nh_output["fib"]
and ("fib" not in nh_expected.keys() or not nh_expected["fib"])
):
return "{}, prefix {} nexthop {} has the fib flag set, whereas it is not expected".format(
router.name, ipaddr_str, nh_output["ip"]
)
return ret return ret
return "{}, prefix {} does not have the correct number of nexthops : observed {}, expected {}".format( return "{}, prefix {} does not have the correct number of nexthops : observed {}, expected {}".format(
router.name, ipaddr_str, num_nh_observed, num_nh_expected router.name, ipaddr_str, num_nh_observed, num_nh_expected
@ -37,9 +54,9 @@ def iproute2_check_path_selection(router, ipaddr_str, expected, vrf_name=None):
return None return None
if vrf_name: if vrf_name:
cmdstr = f'ip -json route show vrf {vrf_name} {ipaddr_str}' cmdstr = f"ip -json route show vrf {vrf_name} {ipaddr_str}"
else: else:
cmdstr = f'ip -json route show {ipaddr_str}' cmdstr = f"ip -json route show {ipaddr_str}"
try: try:
output = json.loads(cmdstr) output = json.loads(cmdstr)
except: except:

View File

@ -4314,6 +4314,10 @@ dplane_route_update_internal(struct route_node *rn,
NEXTHOP_FLAG_RECURSIVE)) NEXTHOP_FLAG_RECURSIVE))
continue; continue;
if (CHECK_FLAG(nexthop->flags,
NEXTHOP_FLAG_DUPLICATE))
continue;
if (CHECK_FLAG(nexthop->flags, if (CHECK_FLAG(nexthop->flags,
NEXTHOP_FLAG_ACTIVE)) NEXTHOP_FLAG_ACTIVE))
SET_FLAG(nexthop->flags, SET_FLAG(nexthop->flags,

View File

@ -1659,6 +1659,9 @@ static bool rib_update_nhg_from_ctx(struct nexthop_group *re_nhg,
if (!CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE)) if (!CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE))
continue; continue;
if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE))
continue;
/* Check for a FIB nexthop corresponding to the RIB nexthop */ /* Check for a FIB nexthop corresponding to the RIB nexthop */
if (!nexthop_same(ctx_nexthop, nexthop)) { if (!nexthop_same(ctx_nexthop, nexthop)) {
/* If the FIB doesn't know about the nexthop, /* If the FIB doesn't know about the nexthop,