Commit 6f5d4ed7f5 for frr
commit 6f5d4ed7f58d641541c926de06d842d193de89c5
Author: Philippe Guibert <philippe.guibert@6wind.com>
Date: Mon Oct 12 18:22:13 2026 +0200
topotests: check aigp of the recursive nexthop route in bgp_vpnv4_asbr
r1 sets an AIGP metric of 10 on its exported VPN routes, and of 20 on
the labeled-unicast route 192.0.2.1/32, which resolves the nexthop of
these VPN routes on r2. Check that r3 receives 172.31.0.0/24 with an
AIGP metric of 30. When r1 changes the AIGP metric of 192.0.2.1/32 to
40, check that r3 receives 50. When r1 removes it, check that r3
receives 172.31.0.0/24 without the AIGP attribute. When r1 stops setting
the AIGP metric on its VPN routes and r2 sets an AIGP metric of 5 in its
outbound route-map towards rs200, check that r3 receives 172.31.0.0/24
with an AIGP metric of 5.
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 85051f5038..7b906826c9 100644
--- a/tests/topotests/bgp_vpnv4_asbr/test_bgp_vpnv4_asbr.py
+++ b/tests/topotests/bgp_vpnv4_asbr/test_bgp_vpnv4_asbr.py
@@ -16,6 +16,8 @@ The test demonstrates the connectivity across the network between h1 and h3.
r3 sets an AIGP metric on its exported VPN routes, and AIGP is enabled on
the eBGP sessions between r2, rs200 and r3: r2 and r1 receive the AIGP
metric. r2 increases it towards rr100 with "set aigp-metric +1".
+r1 sets an AIGP metric on its exported VPN routes and on its
+labeled-unicast route 192.0.2.1/32: r3 receives the sum of both.
+----------+ +----+--------+ +--------+ +--------+-----+
@@ -488,6 +490,132 @@ router bgp 65500
assert result is True, result
+def test_aigp_vpn_recursive_nexthop():
+ """
+ r1 sets an AIGP metric of 10 on its exported VPN routes, and of 20 on
+ the labeled-unicast route 192.0.2.1/32. On r2, the nexthop 192.0.2.1
+ of 172.31.0.0/24 is resolved by this labeled-unicast route, so r3
+ receives 172.31.0.0/24 with an AIGP metric of 10 + 20.
+ r1 changes the AIGP metric of 192.0.2.1/32 to 40, and r3 receives an
+ AIGP metric of 50.
+ r1 removes the AIGP metric from 192.0.2.1/32, 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"]
+ r2 = tgen.gears["r2"]
+ r3 = tgen.gears["r3"]
+
+ r1.vtysh_cmd(
+ """
+configure terminal
+route-map aigp-lu permit 10
+ set aigp-metric 20
+route-map aigp-vpn permit 10
+ set aigp-metric 10
+router bgp 65500
+ address-family ipv4 unicast
+ network 192.0.2.1/32 route-map aigp-lu
+router bgp 65500 vrf vrf1
+ address-family ipv4 unicast
+ route-map vpn export aigp-vpn
+"""
+ )
+
+ result = check_vpn_aigp_metric(r2, "444:1", "172.31.0.0/24", 10)
+ assert result is True, result
+ result = check_vpn_aigp_metric(r3, "444:1", "172.31.0.0/24", 30)
+ assert result is True, result
+
+ r1.vtysh_cmd(
+ """
+configure terminal
+route-map aigp-lu permit 10
+ set aigp-metric 40
+"""
+ )
+
+ result = check_vpn_aigp_metric(r3, "444:1", "172.31.0.0/24", 50)
+ assert result is True, result
+
+ r1.vtysh_cmd(
+ """
+configure terminal
+route-map aigp-lu permit 10
+ no set aigp-metric
+"""
+ )
+
+ result = check_vpn_aigp_metric(r2, "444:1", "172.31.0.0/24", 10)
+ assert result is True, result
+ result = check_vpn_aigp_metric(r3, "444:1", "172.31.0.0/24", None)
+ assert result is True, result
+
+
+def test_aigp_vpn_recursive_nexthop_originate():
+ """
+ r1 stops setting an AIGP metric on its exported VPN routes, and r2
+ receives 172.31.0.0/24 without the AIGP attribute. The nexthop
+ 192.0.2.1 is still resolved by a labeled-unicast route without the
+ AIGP attribute. r2 sets an AIGP metric of 5 in the outbound route-map
+ towards rs200: r2 originates the AIGP attribute, and r3 receives
+ 172.31.0.0/24 with an AIGP metric of 5.
+ """
+ tgen = get_topogen()
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ r1 = tgen.gears["r1"]
+ r2 = tgen.gears["r2"]
+ r3 = tgen.gears["r3"]
+
+ r1.vtysh_cmd(
+ """
+configure terminal
+router bgp 65500 vrf vrf1
+ address-family ipv4 unicast
+ no route-map vpn export aigp-vpn
+"""
+ )
+ r2.vtysh_cmd(
+ """
+configure terminal
+route-map aigp-originate permit 10
+ set aigp-metric 5
+router bgp 65500
+ address-family ipv4 vpn
+ neighbor 192.168.1.200 route-map aigp-originate out
+"""
+ )
+
+ try:
+ result = check_vpn_aigp_metric(r2, "444:1", "172.31.0.0/24", None)
+ assert result is True, result
+ result = check_vpn_aigp_metric(r3, "444:1", "172.31.0.0/24", 5)
+ assert result is True, result
+ finally:
+ r2.vtysh_cmd(
+ """
+configure terminal
+router bgp 65500
+ address-family ipv4 vpn
+ no neighbor 192.168.1.200 route-map aigp-originate out
+no route-map aigp-originate
+"""
+ )
+ r1.vtysh_cmd(
+ """
+configure terminal
+router bgp 65500 vrf vrf1
+ address-family ipv4 unicast
+ route-map vpn export aigp-vpn
+"""
+ )
+
+
def test_r3_prefixes_removed():
"""
Remove BGP redistributed updates from r3.