bgpd: Fix SRv6 SID export route-map update not taking effect #21283
frrbot / frrbot
completed
Mar 22, 2026 in 9s
Style and/or linter errors found
Style and/or linter errors found
Details
Thanks for your contribution to FRR!
Click for style suggestions
diff --git a/tests/topotests/bgp_srv6_unicast/test_bgp_srv6_unicast.py b/tests/topotests/bgp_srv6_unicast/test_bgp_srv6_unicast.py
index 388360aeba..34cb02a873 100644
--- a/tests/topotests/bgp_srv6_unicast/test_bgp_srv6_unicast.py
+++ b/tests/topotests/bgp_srv6_unicast/test_bgp_srv6_unicast.py
@@ -48,9 +48,15 @@ pytestmark = [pytest.mark.bgpd]
r1_unicast_sid = None
r3_unicast_sid = None
+
def setup_module(mod):
- topodef = {"s1": ("r1", "r2"), "s2": ("r1", "r3"), "s3": ("r1", "r4"),
- "s4": ("c1", "r2"), "s5": ("r3", "c2")}
+ topodef = {
+ "s1": ("r1", "r2"),
+ "s2": ("r1", "r3"),
+ "s3": ("r1", "r4"),
+ "s4": ("c1", "r2"),
+ "s5": ("r3", "c2"),
+ }
tgen = Topogen(topodef, mod.__name__)
tgen.start_topology()
@@ -82,6 +88,7 @@ def setup_module(mod):
tgen.start_router()
+
@retry(retry_timeout=10)
def get_unicast_sid(afi):
global r1_unicast_sid, r3_unicast_sid
@@ -105,6 +112,7 @@ def get_unicast_sid(afi):
return True
+
@retry(retry_timeout=10)
def check_route(router, cmd, expect_route, expect_sid, expect_installed=True):
tgen = get_topogen()
@@ -122,8 +130,11 @@ def check_route(router, cmd, expect_route, expect_sid, expect_installed=True):
return "route is installed on %s" % router.name
route = route[0]
- if expect_sid and route["nexthops"][0].get("seg6", {}).get("segs", "") != expect_sid:
- error = "%s: expecting" % router.name
+ if (
+ expect_sid
+ and route["nexthops"][0].get("seg6", {}).get("segs", "") != expect_sid
+ ):
+ error = "%s: expecting" % router.name
if expect_sid:
error = "%s %s sid" % (error, expect_sid)
@@ -133,6 +144,7 @@ def check_route(router, cmd, expect_route, expect_sid, expect_installed=True):
return True
+
def test_bgp_srv6_encap():
"""
For static prefix 10.0.0.1/32:
@@ -145,22 +157,35 @@ def test_bgp_srv6_encap():
res = get_unicast_sid("AFI_IP")
assert res is True, res
- logger.info("R1 sid[AFI_IP]: %s, R3 sid[AFI_IP]: %s" % (r1_unicast_sid, r3_unicast_sid))
+ logger.info(
+ "R1 sid[AFI_IP]: %s, R3 sid[AFI_IP]: %s" % (r1_unicast_sid, r3_unicast_sid)
+ )
logger.info("Check prefix 10.0.0.1/32 SRv6 encap on R2")
- res = check_route(tgen.gears["r2"], "show ip route 10.0.0.1/32 json", "10.0.0.1/32", r1_unicast_sid)
+ res = check_route(
+ tgen.gears["r2"],
+ "show ip route 10.0.0.1/32 json",
+ "10.0.0.1/32",
+ r1_unicast_sid,
+ )
assert res is True, res
logger.info("Check prefix 10.0.0.1/32 SRv6 encap on R3")
- res = check_route(tgen.gears["r3"], "show ip route 10.0.0.1/32 json", "10.0.0.1/32", r1_unicast_sid)
+ res = check_route(
+ tgen.gears["r3"],
+ "show ip route 10.0.0.1/32 json",
+ "10.0.0.1/32",
+ r1_unicast_sid,
+ )
assert res is True, res
logger.info("Check prefix 10.0.0.1/32 no SRv6 encap on R4")
- res = check_route(tgen.gears["r4"], "show ip route 10.0.0.1/32 json", "10.0.0.1/32", "")
+ res = check_route(
+ tgen.gears["r4"], "show ip route 10.0.0.1/32 json", "10.0.0.1/32", ""
+ )
assert res is True, res
-
def test_bgp_srv6_update1():
"""
Configure a static prefix 10.0.0.2/32 on R2:
@@ -180,15 +205,24 @@ def test_bgp_srv6_update1():
)
logger.info("Check prefix 10.0.0.2/32 no SRv6 encap on R1")
- res = check_route(tgen.gears["r1"], "show ip route 10.0.0.2/32 json", "10.0.0.2/32", "")
+ res = check_route(
+ tgen.gears["r1"], "show ip route 10.0.0.2/32 json", "10.0.0.2/32", ""
+ )
assert res is True, res
logger.info("Check prefix 10.0.0.2/32 SRv6 encap on R3")
- res = check_route(tgen.gears["r3"], "show ip route 10.0.0.2/32 json", "10.0.0.2/32", r1_unicast_sid)
+ res = check_route(
+ tgen.gears["r3"],
+ "show ip route 10.0.0.2/32 json",
+ "10.0.0.2/32",
+ r1_unicast_sid,
+ )
assert res is True, res
logger.info("Check prefix 10.0.0.2/32 no SRv6 encap on R4")
- res = check_route(tgen.gears["r4"], "show ip route 10.0.0.2/32 json", "10.0.0.2/32", "")
+ res = check_route(
+ tgen.gears["r4"], "show ip route 10.0.0.2/32 json", "10.0.0.2/32", ""
+ )
assert res is True, res
@@ -211,17 +245,30 @@ def test_bgp_srv6_update2():
)
logger.info("Check prefix 10.0.0.3/32 SRv6 encap on R1")
- res = check_route(tgen.gears["r1"], "show ip route 10.0.0.3/32 json", "10.0.0.3/32", r3_unicast_sid)
+ res = check_route(
+ tgen.gears["r1"],
+ "show ip route 10.0.0.3/32 json",
+ "10.0.0.3/32",
+ r3_unicast_sid,
+ )
assert res is True, res
logger.info("Check prefix 10.0.0.3/32 SRv6 encap on R2")
- res = check_route(tgen.gears["r2"], "show ip route 10.0.0.3/32 json", "10.0.0.3/32", r3_unicast_sid)
+ res = check_route(
+ tgen.gears["r2"],
+ "show ip route 10.0.0.3/32 json",
+ "10.0.0.3/32",
+ r3_unicast_sid,
+ )
assert res is True, res
logger.info("Check prefix 10.0.0.3/32 no SRv6 encap on R4")
- res = check_route(tgen.gears["r4"], "show ip route 10.0.0.3/32 json", "10.0.0.3/32", "")
+ res = check_route(
+ tgen.gears["r4"], "show ip route 10.0.0.3/32 json", "10.0.0.3/32", ""
+ )
assert res is True, res
+
def test_bgp_srv6_sid_rmap():
"""
Configure prefix 172.16.0.0/24 on r1 and check it is blocked.
@@ -237,13 +284,19 @@ def test_bgp_srv6_sid_rmap():
)
logger.info("Check prefix 172.16.0.0/24 no SRv6 encap on R2")
- res = check_route(tgen.gears["r2"], "show ip route 172.16.0.0/24 json",
- "172.16.0.0/24", "")
+ res = check_route(
+ tgen.gears["r2"], "show ip route 172.16.0.0/24 json", "172.16.0.0/24", ""
+ )
assert res is True, res
logger.info("Check prefix 172.16.0.0/24 is not installed on R3")
- res = check_route(tgen.gears["r3"], "show ip route 172.16.0.0/24 json",
- "172.16.0.0/24", "", expect_installed=False)
+ res = check_route(
+ tgen.gears["r3"],
+ "show ip route 172.16.0.0/24 json",
+ "172.16.0.0/24",
+ "",
+ expect_installed=False,
+ )
assert res is True, res
@@ -334,16 +387,24 @@ def test_bgp_srv6_sid_unexport():
logger.info("Check 10.0.0.1/32 and 10.0.0.3/32 are installed on R2")
for prefix in prefixes:
- res = check_route(tgen.gears["r2"], "show ip route %s json" % prefix, prefix, "")
+ res = check_route(
+ tgen.gears["r2"], "show ip route %s json" % prefix, prefix, ""
+ )
assert res is True, res
prefixes = ["10.0.0.1/32", "10.0.0.2/32", "10.0.0.3/32"]
logger.info("Check 10.0.0.1-3/32 are not installed on R3")
for prefix in prefixes:
- res = check_route(tgen.gears["r3"], "show ip route %s json" % prefix, prefix,
- "", expect_installed=False)
+ res = check_route(
+ tgen.gears["r3"],
+ "show ip route %s json" % prefix,
+ prefix,
+ "",
+ expect_installed=False,
+ )
assert res is True, res
+
def test_bgp_srv6_sid_export():
"""
Enable sid export explicit on R1 and recheck prefixes 10.0.0.1-3/32 srv6 encap.
@@ -361,23 +422,44 @@ def test_bgp_srv6_sid_export():
res = get_unicast_sid("AFI_IP")
assert res is True, res
- logger.info("R1 sid[AFI_IP]: %s, R3 sid[AFI_IP]: %s" % (r1_unicast_sid, r3_unicast_sid))
+ logger.info(
+ "R1 sid[AFI_IP]: %s, R3 sid[AFI_IP]: %s" % (r1_unicast_sid, r3_unicast_sid)
+ )
logger.info("Check 10.0.0.1/32 sid %s installed on R2" % r1_unicast_sid)
- res = check_route(tgen.gears["r2"], "show ip route 10.0.0.1/32 json", "10.0.0.1/32", r1_unicast_sid)
+ res = check_route(
+ tgen.gears["r2"],
+ "show ip route 10.0.0.1/32 json",
+ "10.0.0.1/32",
+ r1_unicast_sid,
+ )
assert res is True, res
logger.info("Check 10.0.0.1/32 sid %s installed on R3" % r1_unicast_sid)
- res = check_route(tgen.gears["r3"], "show ip route 10.0.0.1/32 json", "10.0.0.1/32", r1_unicast_sid)
+ res = check_route(
+ tgen.gears["r3"],
+ "show ip route 10.0.0.1/32 json",
+ "10.0.0.1/32",
+ r1_unicast_sid,
+ )
assert res is True, res
-
logger.info("Check 10.0.0.3/32 sid %s installed on R2" % r3_unicast_sid)
- res = check_route(tgen.gears["r2"], "show ip route 10.0.0.3/32 json", "10.0.0.3/32", r3_unicast_sid)
+ res = check_route(
+ tgen.gears["r2"],
+ "show ip route 10.0.0.3/32 json",
+ "10.0.0.3/32",
+ r3_unicast_sid,
+ )
assert res is True, res
logger.info("Check 10.0.0.3/32 sid %s installed on R1" % r3_unicast_sid)
- res = check_route(tgen.gears["r1"], "show ip route 10.0.0.3/32 json", "10.0.0.3/32", r3_unicast_sid)
+ res = check_route(
+ tgen.gears["r1"],
+ "show ip route 10.0.0.3/32 json",
+ "10.0.0.3/32",
+ r3_unicast_sid,
+ )
assert res is True, res
@@ -406,37 +488,57 @@ def test_bgp_srv6_sid_v6_update():
res = get_unicast_sid("AFI_IP6")
assert res is True, res
- logger.info("R1 sid[AFI_IP6]: %s, R3 sid[AFI_IP6]: %s" % (r1_unicast_sid, r3_unicast_sid))
+ logger.info(
+ "R1 sid[AFI_IP6]: %s, R3 sid[AFI_IP6]: %s" % (r1_unicast_sid, r3_unicast_sid)
+ )
logger.info("Check fd00:200::/64 sid %s installed on R2" % r1_unicast_sid)
- res = check_route(tgen.gears["r2"], "show ipv6 route fd00:200::/64 json",
- "fd00:200::/64", r1_unicast_sid)
+ res = check_route(
+ tgen.gears["r2"],
+ "show ipv6 route fd00:200::/64 json",
+ "fd00:200::/64",
+ r1_unicast_sid,
+ )
assert res is True, res
logger.info("Check fd00:200::/64 sid %s installed on R3" % r1_unicast_sid)
- res = check_route(tgen.gears["r3"], "show ipv6 route fd00:200::/64 json",
- "fd00:200::/64", r1_unicast_sid)
+ res = check_route(
+ tgen.gears["r3"],
+ "show ipv6 route fd00:200::/64 json",
+ "fd00:200::/64",
+ r1_unicast_sid,
+ )
assert res is True, res
logger.info("Check fd00:300::/64 sid %s installed on R1" % r3_unicast_sid)
- res = check_route(tgen.gears["r1"], "show ipv6 route fd00:300::/64 json",
- "fd00:300::/64", r3_unicast_sid)
+ res = check_route(
+ tgen.gears["r1"],
+ "show ipv6 route fd00:300::/64 json",
+ "fd00:300::/64",
+ r3_unicast_sid,
+ )
assert res is True, res
logger.info("Check fd00:300::/64 sid %s installed on R2" % r3_unicast_sid)
- res = check_route(tgen.gears["r2"], "show ipv6 route fd00:300::/64 json",
- "fd00:300::/64", r3_unicast_sid)
+ res = check_route(
+ tgen.gears["r2"],
+ "show ipv6 route fd00:300::/64 json",
+ "fd00:300::/64",
+ r3_unicast_sid,
+ )
assert res is True, res
logger.info("Check fd00:200::/64 sid %s is not installed on R4" % r1_unicast_sid)
- res = check_route(tgen.gears["r4"], "show ipv6 route fd00:200::/64 json",
- "fd00:200::/64", "")
+ res = check_route(
+ tgen.gears["r4"], "show ipv6 route fd00:200::/64 json", "fd00:200::/64", ""
+ )
assert res is True, res
logger.info("Check fd00:300::/64 sid %s is not installed on R4" % r3_unicast_sid)
- res = check_route(tgen.gears["r4"], "show ipv6 route fd00:300::/64 json",
- "fd00:300::/64", "")
+ res = check_route(
+ tgen.gears["r4"], "show ipv6 route fd00:300::/64 json", "fd00:300::/64", ""
+ )
assert res is True, res
@@ -473,23 +575,43 @@ def test_srv6_withdraw():
)
logger.info("Check 10.0.0.1/32 is withdrawn on R3")
- res = check_route(tgen.gears["r3"], "show ip route 10.0.0.1/32 json",
- "10.0.0.1/32", r1_unicast_sid, expect_installed=False)
+ res = check_route(
+ tgen.gears["r3"],
+ "show ip route 10.0.0.1/32 json",
+ "10.0.0.1/32",
+ r1_unicast_sid,
+ expect_installed=False,
+ )
assert res is True, res
logger.info("Check 10.0.0.3/32 is withdrawn on R2")
- res = check_route(tgen.gears["r2"], "show ip route 10.0.0.3/32 json",
- "10.0.0.3/32", r3_unicast_sid, expect_installed=False)
+ res = check_route(
+ tgen.gears["r2"],
+ "show ip route 10.0.0.3/32 json",
+ "10.0.0.3/32",
+ r3_unicast_sid,
+ expect_installed=False,
+ )
assert res is True, res
logger.info("Check fd00:200::/64 is withdrawn on R3")
- res = check_route(tgen.gears["r3"], "show ipv6 route fd00:200::/64 json",
- "fd00:200::/64", r1_unicast_sid, expect_installed=False)
+ res = check_route(
+ tgen.gears["r3"],
+ "show ipv6 route fd00:200::/64 json",
+ "fd00:200::/64",
+ r1_unicast_sid,
+ expect_installed=False,
+ )
assert res is True, res
logger.info("Check fd00:300::/64 is withdrawn on R2")
- res = check_route(tgen.gears["r2"], "show ipv6 route fd00:300::/64 json",
- "fd00:300::/64", r3_unicast_sid, expect_installed=False)
+ res = check_route(
+ tgen.gears["r2"],
+ "show ipv6 route fd00:300::/64 json",
+ "fd00:300::/64",
+ r3_unicast_sid,
+ expect_installed=False,
+ )
assert res is True, res
To apply the style suggestions:
curl https://gist.githubusercontent.com/polychaeta/3e9093410630a9d6f641e842c8941e98/raw/c58ea992006c6a7ae72be0d8ab866f8db7f25d39/style.diff | git apply -
If you are a new contributor to FRR, please see our contributing guidelines.
After making changes, you do not need to create a new PR. You should perform an amend or interactive rebase followed by a force push.
Loading