Skip to content

Commit

Permalink
topotests: add nexthop-group allow-recursion test
Browse files Browse the repository at this point in the history
Add a nexthop group test that ensures that a recursive
next-hop is resolved in zebra.

Signed-off-by: Philippe Guibert <[email protected]>
  • Loading branch information
pguibert6WIND committed Dec 10, 2023
1 parent 2d8c1b1 commit d49e589
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
8 changes: 8 additions & 0 deletions tests/topotests/all_protocol_startup/r1/ip_nht.ref
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ VRF default:
6.6.6.4
unresolved
Client list: pbr(fd XX)
192.0.2.200
resolved via static
via 192.168.0.208, r1-eth0 (vrf default), weight 1
Client list: pbr(fd XX)
192.168.0.2
resolved via connected
is directly connected, r1-eth0 (vrf default)
Expand All @@ -61,6 +65,10 @@ VRF default:
resolved via connected
is directly connected, r1-eth0 (vrf default)
Client list: static(fd XX)
192.168.0.208
resolved via connected
is directly connected, r1-eth0 (vrf default)
Client list: static(fd XX)
192.168.7.10
resolved via connected
is directly connected, r1-eth7 (vrf default)
Expand Down
1 change: 1 addition & 0 deletions tests/topotests/all_protocol_startup/r1/ipv4_routes.ref
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ S>* 1.1.1.5/32 [1/0] is directly connected, r1-eth5, weight 1, XX:XX:XX
S>* 1.1.1.6/32 [1/0] is directly connected, r1-eth6, weight 1, XX:XX:XX
S>* 1.1.1.7/32 [1/0] is directly connected, r1-eth7, weight 1, XX:XX:XX
S>* 1.1.1.8/32 [1/0] is directly connected, r1-eth8, weight 1, XX:XX:XX
S>* 192.0.2.0/24 [1/0] via 192.168.0.208, r1-eth0, weight 1, XX:XX:XX
S>* 4.5.6.10/32 [1/0] via 192.168.0.2, r1-eth0, weight 1, XX:XX:XX
S>* 4.5.6.11/32 [1/0] via 192.168.0.2, r1-eth0, weight 1, XX:XX:XX
S>* 4.5.6.12/32 [1/0] is directly connected, r1-eth0, weight 1, XX:XX:XX
Expand Down
4 changes: 4 additions & 0 deletions tests/topotests/all_protocol_startup/r1/zebra.conf
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ ip route 4.5.6.16/32 192.168.0.4 10
ip route 4.5.6.17/32 192.168.0.2 tag 9000
ip route 4.5.6.17/32 192.168.0.2 tag 10000

! Create a static route to test recursive
! resolution
ip route 192.0.2.0/24 192.168.0.208

!
interface r1-eth0
description to sw0 - no routing protocol
Expand Down
27 changes: 25 additions & 2 deletions tests/topotests/all_protocol_startup/test_all_protocol_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def route_get_nhg_id(route_str):
return nhg_id


def verify_nexthop_group(nhg_id, recursive=False, ecmp=0):
def verify_nexthop_group(nhg_id, recursive=False, ecmp=0, recursive_again=False):
net = get_topogen().net
count = 0
valid = None
Expand Down Expand Up @@ -440,7 +440,7 @@ def verify_nexthop_group(nhg_id, recursive=False, ecmp=0):
continue

resolved_id = int(depends[0])
verify_nexthop_group(resolved_id, False)
verify_nexthop_group(resolved_id, recursive=recursive_again)
else:
installed = re.search(r"Installed", output)
if installed is None:
Expand Down Expand Up @@ -613,6 +613,29 @@ def test_nexthop_groups():
% nhg_id
)

## nexthop-group allow-recursion
## create a static route, and use that static route to resolve the nexthop-group
net["r1"].cmd('vtysh -c "c t" -c "zebra nexthop-group keep 10"')
net["r1"].cmd(
'vtysh -c "c t" -c "nexthop-group allowrecursion" -c "allow-recursion" -c "nexthop 192.0.2.200"'
)
net["r1"].cmd(
'vtysh -c "sharp install routes 9.9.9.9 nexthop-group allowrecursion 1"'
)
nhg_id = route_get_nhg_id("9.9.9.9/32")
verify_nexthop_group(nhg_id, recursive=True, ecmp=0, recursive_again=True)

net["r1"].cmd('vtysh -c "sharp remove routes 9.9.9.9 1"')
net["r1"].cmd(
'vtysh -c "c t" -c "nexthop-group allowrecursion" -c "no allow-recursion"'
)
output = net["r1"].cmd('vtysh -c "show nexthop-group rib %d"' % nhg_id)
found = re.search(r"Time to Deletion", output)
assert found is not None, (
"Route 9.9.9.9/32 with Nexthop Group ID=%d is not scheduled for removal"
% nhg_id
)

## Remove all NHG routes

net["r1"].cmd('vtysh -c "sharp remove routes 2.2.2.1 1"')
Expand Down

0 comments on commit d49e589

Please sign in to comment.