summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRajasekar Raja <rajasekarr@nvidia.com>2025-03-11 12:15:32 -0700
committerRajasekar Raja <rajasekarr@nvidia.com>2025-03-18 12:21:42 -0700
commitde168795ab5d75151f1b410fcdad88e2c28ef40e (patch)
tree638a7bbeb51b56962ccb2d74cf61c609f5773420 /tests
parentb66145b8ca1ee8c222ceb79afa89bced21273537 (diff)
zebra: Fix reinstalling nexthops in NHGs upon interface flaps
Trigger: Imagine a route utilizing an NHG with six nexthops (Intf swp1-swp6). If interfaces swp1-swp4 flaps, the NHG remains the same but now only references two nexthops (swp5-6) instead of all six. This behavior occurs due to how NHGs with recursive nexthops are managed within Zebra. In the scenario below, NHG 370 has all six nexthops installed in the kernel. However, Zebra maintains a list of recursive NHGs that NHG 370 references i.e., Depends: (371), (372), (373) which are not directly installed in the kernel. - When an interface comes up, its nexthop and corresponding dependents are installed. - These dependents (counterparts to 371-373) are non-recursive and are installed as well. - However, when attempting to install the recursive ones in zebra_nhg_install_kernel(), they resolve to the already installed counterparts, resulting in a NO-OP. Fixing this by iterating all dependents of the recursively resolved NHGs and reinstalling them. Trigger: Flap swp1 to swp4 Before Fix: root@leaf-11:mgmt:/var/home/cumulus# ip route show | grep 6.0.0.5 6.0.0.5 nhid 370 proto bgp metric 20 ip -d next show id 337 via 2000:1:0:1:0:f:0:9 dev swp6 scope link proto zebra id 339 via 2000:1:0:1:0:e:0:9 dev swp5 scope link proto zebra id 341 via 2000:1:0:1:0:8:0:8 dev swp4 scope link proto zebra id 343 via 2000:1:0:1:0:7:0:8 dev swp3 scope link proto zebra id 346 via 2000:1:0:1:0:1:0:7 dev swp2 scope link proto zebra id 348 via 2000:1:0:1::7 dev swp1 scope link proto zebra id 370 group 346/348/341/343/337/339 scope global proto zebra After Trigger: root@leaf-11:mgmt:/var/home/cumulus# ip route show | grep 6.0.0.5 6.0.0.5 nhid 370 proto bgp metric 20 root@leaf-11:mgmt:/var/home/cumulus# ip -d next show id 337 via 2000:1:0:1:0:f:0:9 dev swp6 scope link proto zebra id 339 via 2000:1:0:1:0:e:0:9 dev swp5 scope link proto zebra id 370 group 337/339 scope global proto zebra After Fix: root@leaf-11:mgmt:/var/home/cumulus# ip route show | grep 6.0.0.5 6.0.0.5 nhid 432 proto bgp metric 20 ip -d next show id 432 group 395/397/400/402/405/407 scope global proto zebra After Trigger root@leaf-11:mgmt:/var/home/cumulus# ip route show | grep 6.0.0.5 6.0.0.5 nhid 432 proto bgp metric 20 root@leaf-11:mgmt:/var/home/cumulus# ip -d next show id 432 group 395/397/400/402/405/407 scope global proto zebra Ticket :# Signed-off-by: Rajasekar Raja <rajasekarr@nvidia.com> Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/topotests/all_protocol_startup/test_all_protocol_startup.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/topotests/all_protocol_startup/test_all_protocol_startup.py b/tests/topotests/all_protocol_startup/test_all_protocol_startup.py
index 06a350c8e9..80903b134e 100644
--- a/tests/topotests/all_protocol_startup/test_all_protocol_startup.py
+++ b/tests/topotests/all_protocol_startup/test_all_protocol_startup.py
@@ -652,6 +652,34 @@ def test_nexthop_groups():
nhg_id
)
+ ## Validate NHG's installed in kernel has same nexthops with Interface flaps
+ pre_out = net["r1"].cmd('ip route show | grep "5.5.5.1"')
+ pre_nhg = re.search(r"nhid\s+(\d+)", pre_out)
+ pre_nh_show = net["r1"].cmd("ip next show id {}".format(pre_nhg.group(1)))
+ pre_total_nhs = len((re.search(r"group ([\d/]+)", pre_nh_show)).group(1).split("/"))
+
+ net["r1"].cmd(
+ "ip link set r1-eth1 down;ip link set r1-eth2 down;ip link set r1-eth3 down;ip link set r1-eth4 down"
+ )
+ sleep(1)
+ net["r1"].cmd(
+ "ip link set r1-eth1 up;ip link set r1-eth2 up;ip link set r1-eth3 up;ip link set r1-eth4 up"
+ )
+ sleep(5)
+
+ post_out = net["r1"].cmd('ip route show | grep "5.5.5.1"')
+ post_nhg = re.search(r"nhid\s+(\d+)", post_out)
+ post_nh_show = net["r1"].cmd("ip next show id {}".format(post_nhg.group(1)))
+ post_total_nhs = len(
+ (re.search(r"group ([\d/]+)", post_nh_show)).group(1).split("/")
+ )
+
+ assert (
+ post_total_nhs == pre_total_nhs
+ ), "Expected same nexthops(pre-{}: post-{}) in NHG (pre-{}:post-{}) after few Interface flaps".format(
+ pre_total_nhs, post_total_nhs, pre_nhg.group(1), post_nhg.group(1)
+ )
+
## Remove all NHG routes
net["r1"].cmd('vtysh -c "sharp remove routes 2.2.2.1 1"')