Commit ea714da3b3 for frr
commit ea714da3b318eab3747639480c0dcc9f1d3c2be7
Author: Philippe Guibert <philippe.guibert@6wind.com>
Date: Mon Oct 12 14:20:42 2026 +0200
topotests: check aigp with inter-as vpn in bgp_vpnv4_asbr
AIGP is only tested with IPv4 unicast, whereas an inter-AS setup, where
ASBRs exchange labeled routes, is the typical use case of RFC 7311.
The AIGP attribute is encoded and decoded independently of the address
family, and the aigp flag of the eBGP sessions applies to all address
families, including IPv4 VPN.
Fix this by setting an AIGP metric on the VPN routes exported by r3, and
by enabling AIGP on the eBGP sessions between r3, the rs200 route server
and r2. Check that r2 receives the AIGP metric from the other AS, and
that r1 receives it through the route reflector.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
diff --git a/tests/topotests/bgp_vpnv4_asbr/r2/bgpd.conf b/tests/topotests/bgp_vpnv4_asbr/r2/bgpd.conf
index c7244c0e1f..8966089cc5 100644
--- a/tests/topotests/bgp_vpnv4_asbr/r2/bgpd.conf
+++ b/tests/topotests/bgp_vpnv4_asbr/r2/bgpd.conf
@@ -9,6 +9,7 @@ router bgp 65500
neighbor 192.0.2.100 update-source lo
neighbor 192.168.0.100 remote-as 65500
neighbor 192.168.1.200 remote-as 65502
+ neighbor 192.168.1.200 aigp
address-family ipv4 unicast
no neighbor 192.168.0.100 activate
no neighbor 192.168.1.200 activate
diff --git a/tests/topotests/bgp_vpnv4_asbr/r3/bgpd.conf b/tests/topotests/bgp_vpnv4_asbr/r3/bgpd.conf
index b7592e444d..a8b2583da4 100644
--- a/tests/topotests/bgp_vpnv4_asbr/r3/bgpd.conf
+++ b/tests/topotests/bgp_vpnv4_asbr/r3/bgpd.conf
@@ -3,6 +3,7 @@ router bgp 65501
no bgp ebgp-requires-policy
no bgp enforce-first-as
neighbor 192.168.1.200 remote-as 65502
+ neighbor 192.168.1.200 aigp
address-family ipv4 unicast
no neighbor 192.168.1.200 activate
exit-address-family
@@ -17,10 +18,14 @@ router bgp 65501 vrf vrf1
label vpn export 102
rd vpn export 444:3
rt vpn both 52:100
+ route-map vpn export aigp
export vpn
import vpn
exit-address-family
!
+route-map aigp permit 10
+ set aigp-metric 30
+!
interface r3-eth0
mpls bgp forwarding
!
diff --git a/tests/topotests/bgp_vpnv4_asbr/rs200/bgpd.conf b/tests/topotests/bgp_vpnv4_asbr/rs200/bgpd.conf
index 299262dd21..ca2dc4c772 100644
--- a/tests/topotests/bgp_vpnv4_asbr/rs200/bgpd.conf
+++ b/tests/topotests/bgp_vpnv4_asbr/rs200/bgpd.conf
@@ -6,6 +6,8 @@ router bgp 65502
no bgp ebgp-requires-policy
neighbor 192.168.1.3 remote-as 65501
neighbor 192.168.1.2 remote-as 65500
+ neighbor 192.168.1.3 aigp
+ neighbor 192.168.1.2 aigp
address-family ipv4 unicast
no neighbor 192.168.1.2 activate
no neighbor 192.168.1.3 activate
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 a5c32a0d1d..fb1868c46e 100644
--- a/tests/topotests/bgp_vpnv4_asbr/test_bgp_vpnv4_asbr.py
+++ b/tests/topotests/bgp_vpnv4_asbr/test_bgp_vpnv4_asbr.py
@@ -9,29 +9,32 @@
#
"""
- test_bgp_vpnv4_asbr.py: Test the FRR BGP daemon with rfc4364 option 10b
- r1, r2, and r100 are in an iBGP AS, while r2, r3 do an eBGP peering
- h1 is a host behind r1 VRF1, and {h2,h3} are hosts behind r3 VRF1
- The test demonstrates the connectivity across the network between h1 and h3.
-
-
- +----------+ +----+--------+ +--------+ +--------+-----+
- | |172.31.0.0|vrf | r1 |192.168.0.0/24| r2 |192.168.1.0/24|r3 | vrf |
- | h1 +----------+ | 1+------+-------+ +------+-------+3 | +--- 172.31.3.0/24
- | 10 | |VRF1|AS65500 | | | AS65500| | |AS65501 |VRF1 |
- +----------+ +-------------+ | +--------+ | +--------+--+-++
- 192.0.2.1 | 192.0.2.2 | 172| |
- +----------+ +----+--------+ 31| |
- |rr100 | |rs200/AS65502| 1| |
- +----------+ +-------------+ 0| |
- 192.0.2.100 +--------+ /24| |
- | | +----------+----+ |
- |h3 | | | |
- |10 | | h2 | |
- +---+----+ | 10 | |
- | +----------+ |
- |172.31.2.0/24 |
- +--------------------------------+
+test_bgp_vpnv4_asbr.py: Test the FRR BGP daemon with rfc4364 option 10b
+r1, r2, and r100 are in an iBGP AS, while r2, r3 do an eBGP peering
+h1 is a host behind r1 VRF1, and {h2,h3} are hosts behind r3 VRF1
+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.
+
+
++----------+ +----+--------+ +--------+ +--------+-----+
+| |172.31.0.0|vrf | r1 |192.168.0.0/24| r2 |192.168.1.0/24|r3 | vrf |
+| h1 +----------+ | 1+------+-------+ +------+-------+3 | +--- 172.31.3.0/24
+| 10 | |VRF1|AS65500 | | | AS65500| | |AS65501 |VRF1 |
++----------+ +-------------+ | +--------+ | +--------+--+-++
+ 192.0.2.1 | 192.0.2.2 | 172| |
+ +----------+ +----+--------+ 31| |
+ |rr100 | |rs200/AS65502| 1| |
+ +----------+ +-------------+ 0| |
+ 192.0.2.100 +--------+ /24| |
+ | | +----------+----+ |
+ |h3 | | | |
+ |10 | | h2 | |
+ +---+----+ | 10 | |
+ | +----------+ |
+ |172.31.2.0/24 |
+ +--------------------------------+
"""
import os
@@ -55,6 +58,7 @@ from lib.bgpcheck import (
from lib.topogen import Topogen, TopoRouter, get_topogen
from lib.topolog import logger
from lib.checkping import check_ping
+from lib.common_config import retry
# Required to instantiate the topology builder class.
@@ -424,6 +428,28 @@ def test_mpls_setup_ok():
check_ping("h1", "172.31.2.10", True, 20, 0.5)
+def test_aigp_vpn_inter_as():
+ """
+ Check that r2 and r1 receive 172.31.3.0/24 from r3 with the AIGP metric
+ """
+ tgen = get_topogen()
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ @retry(retry_timeout=30)
+ def check_vpn_aigp_metric(router):
+ output = router.vtysh_cmd("show bgp ipv4 vpn 172.31.3.0/24 json", isjson=True)
+ expected = {"444:3": {"paths": [{"aigpMetric": 30}]}}
+ result = topotest.json_cmp(output, expected)
+ if result is not None:
+ return "{}, {}".format(router.name, result)
+ return True
+
+ for rname in ("r2", "r1"):
+ result = check_vpn_aigp_metric(tgen.gears[rname])
+ assert result is True, result
+
+
def test_r3_prefixes_removed():
"""
Remove BGP redistributed updates from r3.