Commit f363575c5e for frr
commit f363575c5e06038e4a119dda5da779fef05663eb
Author: Philippe Guibert <philippe.guibert@6wind.com>
Date: Tue Dec 1 11:24:36 2026 +0100
topotests: check the aigp recursion depth limit in bgp_vpnv4_asbr
r1 sets the nexthop of its labeled-unicast route 192.0.2.1/32 to the
first of a chain of labeled-unicast routes, each one resolving the
nexthop of the previous one, all with an AIGP metric of 1. With 8 BGP
routes resolving the nexthop of 172.31.0.0/24 on r2, check that r3
receives an AIGP metric of 18. With 9 BGP routes, more than the limit,
check that r3 receives 172.31.0.0/24 without the AIGP attribute.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
diff --git a/tests/topotests/bgp_vpnv4_asbr/test_bgp_vpnv4_asbr.py b/tests/topotests/bgp_vpnv4_asbr/test_bgp_vpnv4_asbr.py
index 7b906826c9..47ecc5e36c 100644
--- a/tests/topotests/bgp_vpnv4_asbr/test_bgp_vpnv4_asbr.py
+++ b/tests/topotests/bgp_vpnv4_asbr/test_bgp_vpnv4_asbr.py
@@ -616,6 +616,98 @@ router bgp 65500 vrf vrf1
)
+def test_aigp_vpn_recursive_nexthop_depth():
+ """
+ r1 sets the nexthop of the labeled-unicast route 192.0.2.1/32 to
+ 10.255.0.1, and originates the labeled-unicast routes 10.255.0.1/32 to
+ 10.255.0.7/32, each one with the nexthop of the next one, 10.255.0.7/32
+ with the nexthop 192.168.0.1. All have an AIGP metric of 1. On r2, the
+ nexthop 192.0.2.1 of 172.31.0.0/24 is resolved by 8 BGP routes: r3
+ receives an AIGP metric of 10 + 8.
+ r1 sets the nexthop of 10.255.0.7/32 to 10.255.0.8, whose route has the
+ nexthop 192.168.0.1: 9 BGP routes resolve the nexthop, more than the
+ limit of 8, and r3 receives 172.31.0.0/24 without the AIGP attribute.
+ """
+ tgen = get_topogen()
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ r1 = tgen.gears["r1"]
+ r3 = tgen.gears["r3"]
+
+ def _check_r3_aigp_metric(aigp):
+ output = r3.vtysh_cmd("show bgp ipv4 vpn 172.31.0.0/24 json", isjson=True)
+ expected = {"444:1": {"paths": [{"aigpMetric": aigp}]}}
+ return topotest.json_cmp(output, expected)
+
+ def configure_chain_nexthop(index, nexthop):
+ r1.vtysh_cmd(
+ """
+configure terminal
+route-map aigp-chain-{0} permit 10
+ set aigp-metric 1
+ set ip next-hop {1}
+""".format(
+ index, nexthop
+ )
+ )
+
+ chain = """
+configure terminal
+router bgp 65500
+ no bgp network import-check
+ address-family ipv4 unicast
+"""
+ for index in range(1, 9):
+ chain += " network 10.255.0.{0}/32 route-map aigp-chain-{0}\n".format(index)
+
+ try:
+ for index in range(1, 7):
+ configure_chain_nexthop(index, "10.255.0.{}".format(index + 1))
+ configure_chain_nexthop(7, "192.168.0.1")
+ configure_chain_nexthop(8, "192.168.0.1")
+ r1.vtysh_cmd(chain)
+ r1.vtysh_cmd(
+ """
+configure terminal
+route-map aigp-lu permit 10
+ set aigp-metric 1
+ set ip next-hop 10.255.0.1
+"""
+ )
+
+ _, result = topotest.run_and_expect(
+ partial(_check_r3_aigp_metric, 18), None, count=60, wait=1
+ )
+ assert result is None, "r3, {}".format(result)
+
+ configure_chain_nexthop(7, "10.255.0.8")
+
+ _, result = topotest.run_and_expect(
+ partial(_check_r3_aigp_metric, None), None, count=60, wait=1
+ )
+ assert result is None, "r3, {}".format(result)
+ finally:
+ r1.vtysh_cmd(
+ """
+configure terminal
+route-map aigp-lu permit 10
+ no set aigp-metric
+ no set ip next-hop
+"""
+ )
+ r1.vtysh_cmd(chain.replace(" network", " no network"))
+ r1.vtysh_cmd(
+ """
+configure terminal
+router bgp 65500
+ bgp network import-check
+"""
+ )
+ for index in range(1, 9):
+ r1.vtysh_cmd("configure terminal\nno route-map aigp-chain-{}".format(index))
+
+
def test_r3_prefixes_removed():
"""
Remove BGP redistributed updates from r3.