From f3680ab410603f17bcb2a86e7a655ca1270f218c Mon Sep 17 00:00:00 2001 From: Mikhail Sokolovskiy Date: Thu, 30 Jan 2025 01:54:31 +0300 Subject: [PATCH 1/2] bgpd: Release SID on router deletion Signed-off-by: Mikhail Sokolovskiy --- bgpd/bgpd.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index d5463f3d0ced..33c5e2f89d21 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -3985,6 +3985,7 @@ int bgp_delete(struct bgp *bgp) uint32_t a_ann_cnt = 0, a_l2_cnt = 0, a_l3_cnt = 0; struct bgp *bgp_to_proc = NULL; struct bgp *bgp_to_proc_next = NULL; + struct bgp *bgp_default = bgp_get_default(); assert(bgp); @@ -4038,13 +4039,26 @@ int bgp_delete(struct bgp *bgp) bgp_soft_reconfig_table_task_cancel(bgp, NULL, NULL); /* make sure we withdraw any exported routes */ - vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP, bgp_get_default(), - bgp); - vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP6, bgp_get_default(), - bgp); + vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP, bgp_default, bgp); + vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP6, bgp_default, bgp); bgp_vpn_leak_unimport(bgp); + /* + * Release SRv6 SIDs, like it's done in `vpn_leak_postchange()` + * and bgp_sid_vpn_export_cmd/af_sid_vpn_export_cmd commands. + */ + bgp->tovpn_sid_index = 0; + UNSET_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO); + delete_vrf_tovpn_sid_per_vrf(bgp_default, bgp); + for (afi = AFI_IP; afi < AFI_MAX; afi++) { + bgp->vpn_policy[afi].tovpn_sid_index = 0; + UNSET_FLAG(bgp->vpn_policy[afi].flags, BGP_VPN_POLICY_TOVPN_SID_AUTO); + delete_vrf_tovpn_sid_per_af(bgp_default, bgp, afi); + + vpn_leak_zebra_vrf_sid_withdraw(bgp, afi); + } + bgp_vpn_release_label(bgp, AFI_IP, true); bgp_vpn_release_label(bgp, AFI_IP6, true); From 90fe717352296c9d33d89f3e30a45bd07fdeb02f Mon Sep 17 00:00:00 2001 From: Mikhail Sokolovskiy Date: Thu, 30 Jan 2025 01:54:47 +0300 Subject: [PATCH 2/2] topotests: Router deletion in SRv6 sid reachability Signed-off-by: Mikhail Sokolovskiy --- .../test_bgp_srv6_sid_reachability.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/topotests/bgp_srv6_sid_reachability/test_bgp_srv6_sid_reachability.py b/tests/topotests/bgp_srv6_sid_reachability/test_bgp_srv6_sid_reachability.py index cf590ad01dba..5c0b90951721 100755 --- a/tests/topotests/bgp_srv6_sid_reachability/test_bgp_srv6_sid_reachability.py +++ b/tests/topotests/bgp_srv6_sid_reachability/test_bgp_srv6_sid_reachability.py @@ -159,6 +159,36 @@ def test_sid_reachable_again_bgp_update(): check_ping("c11", "192.168.2.1", True, 10, 1) +def test_sid_unreachable_no_router(): + get_topogen().gears["r2"].vtysh_cmd( + """ + configure terminal + no router bgp 65002 vrf vrf10 + """ + ) + check_ping("c11", "192.168.2.1", False, 10, 1) + + +def test_sid_reachable_again_no_router(): + get_topogen().gears["r2"].vtysh_cmd( + """ + configure terminal + router bgp 65002 vrf vrf10 + bgp router-id 192.0.2.2 + ! + address-family ipv4 unicast + redistribute connected + sid vpn export 1 + rd vpn export 65002:10 + rt vpn both 0:10 + import vpn + export vpn + exit-address-family + """ + ) + check_ping("c11", "192.168.2.1", True, 10, 1) + + if __name__ == "__main__": args = ["-s"] + sys.argv[1:] sys.exit(pytest.main(args))