Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -10259,6 +10259,16 @@ DEFPY(sid_export,
!strcmp(rmap_str, bgp->srv6_unicast[afi].rmap_name)))
return CMD_SUCCESS;

if (bgp->srv6_unicast[afi].rmap_name) {
route_map_counter_decrement(
route_map_lookup_by_name(bgp->srv6_unicast[afi].rmap_name));
XFREE(MTYPE_ROUTE_MAP_NAME, bgp->srv6_unicast[afi].rmap_name);
}

bgp->srv6_unicast[afi].rmap_name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str);
route_map_counter_increment(
route_map_lookup_by_name(bgp->srv6_unicast[afi].rmap_name));

/* apply route-map change */
bgp_srv6_unicast_announce(bgp, afi);

Expand Down
66 changes: 66 additions & 0 deletions tests/topotests/bgp_srv6_unicast/test_bgp_srv6_unicast.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,72 @@ def test_bgp_srv6_sid_rmap():
assert res is True, res


def test_bgp_srv6_sid_rmap_update():
"""
Update sid export route-map on an already configured sid export and verify
policy really changes.
"""
tgen = get_topogen()

tgen.gears["r1"].vtysh_multicmd(
"""
configure
ip prefix-list BLOCK2 seq 1 deny 10.0.0.1/32
ip prefix-list BLOCK2 seq 255 permit any
route-map filter2 permit 20
match ip address prefix-list BLOCK2
router bgp 65001
address-family ipv4 unicast
sid export auto route-map filter2
"""
)

logger.info("Check prefix 10.0.0.1/32 no SRv6 encap on R2 after route-map update")
res = check_route(
tgen.gears["r2"], "show ip route 10.0.0.1/32 json", "10.0.0.1/32", ""
)
assert res is True, res

logger.info(
"Check prefix 10.0.0.1/32 is not installed on R3 after route-map update"
)
res = check_route(
tgen.gears["r3"],
"show ip route 10.0.0.1/32 json",
"10.0.0.1/32",
"",
expect_installed=False,
)
assert res is True, res

tgen.gears["r1"].vtysh_multicmd(
"""
configure
router bgp 65001
address-family ipv4 unicast
sid export auto route-map filter
"""
)

logger.info("Check prefix 10.0.0.1/32 SRv6 encap restored 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,
)
assert res is True, res

logger.info("Check prefix 10.0.0.1/32 SRv6 encap restored 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,
)
assert res is True, res


def test_bgp_srv6_sid_unexport():
"""
Unconfigure sid export on R1, then check prefixes 10.0.0.1-3/32
Expand Down
Loading