Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bgpd: Release SID on router deletion #17913

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
24 changes: 20 additions & 4 deletions bgpd/bgpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -4038,13 +4039,28 @@ 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 `no sid vpn export` command.
*/
if (!CHECK_FLAG(bgp->vrf_flags, BGP_VRF_TOVPN_SID_AUTO)) {
/* Set index to 0 like in no bgp_sid_vpn_export_cmd. */
bgp->tovpn_sid_index = 0;
delete_vrf_tovpn_sid_per_vrf(bgp_default, bgp);
}
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
if (!CHECK_FLAG(bgp->vpn_policy[afi].flags, BGP_VPN_POLICY_TOVPN_SID_AUTO)) {
/* Set index to 0 like in no af_sid_vpn_export_cmd. */
bgp->vpn_policy[afi].tovpn_sid_index = 0;
delete_vrf_tovpn_sid_per_af(bgp_default, bgp, afi);
}
}

bgp_vpn_release_label(bgp, AFI_IP, true);
bgp_vpn_release_label(bgp, AFI_IP6, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Loading