From 11ad5c4a86c76f460337675bda92ccb0532bb4ec Mon Sep 17 00:00:00 2001 From: Carmine Scarpitta Date: Sat, 23 Mar 2024 19:19:41 +0100 Subject: [PATCH] bgpd: Fix issue of SRv6 routes not withdrawn Currently, when an SRv6 locator is disabled in BGP, BGP does not stop advertising the SIDs allocated from the locator to the other peers. This commit fixes the issue. Signed-off-by: Carmine Scarpitta --- bgpd/bgp_vty.c | 11 ++++++++--- bgpd/bgp_zebra.c | 12 ++++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index c7d1fe95eab6..9e9a0f892d6f 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -324,6 +324,11 @@ static int bgp_srv6_locator_unset(struct bgp *bgp) if (bgp_vrf->inst_type != BGP_INSTANCE_TYPE_VRF) continue; + vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP, bgp, + bgp_vrf); + vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP6, bgp, + bgp_vrf); + /* refresh vpnv4 tovpn_sid */ XFREE(MTYPE_BGP_SRV6_SID, bgp_vrf->vpn_policy[AFI_IP].tovpn_sid); @@ -336,9 +341,6 @@ static int bgp_srv6_locator_unset(struct bgp *bgp) XFREE(MTYPE_BGP_SRV6_SID, bgp_vrf->tovpn_sid); } - /* update vpn bgp processes */ - vpn_leak_postchange_all(); - /* refresh tovpn_sid_locator */ for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp_vrf)) { if (bgp_vrf->inst_type != BGP_INSTANCE_TYPE_VRF) @@ -367,6 +369,9 @@ static int bgp_srv6_locator_unset(struct bgp *bgp) bgp->srv6_locator = NULL; } + /* update vpn bgp processes */ + vpn_leak_postchange_all(); + return 0; } diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 992c85d1cc32..64675e3d37a2 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -3408,6 +3408,9 @@ static int bgp_zebra_process_srv6_locator_delete(ZAPI_CALLBACK_ARGS) struct in6_addr *tovpn_sid; struct prefix_ipv6 tmp_prefi; + if (!bgp) + return 0; + if (zapi_srv6_locator_decode(zclient->ibuf, &loc) < 0) return -1; @@ -3442,6 +3445,11 @@ static int bgp_zebra_process_srv6_locator_delete(ZAPI_CALLBACK_ARGS) if (bgp_vrf->inst_type != BGP_INSTANCE_TYPE_VRF) continue; + vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP, bgp, + bgp_vrf); + vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN, AFI_IP6, bgp, + bgp_vrf); + // refresh vpnv4 tovpn_sid tovpn_sid = bgp_vrf->vpn_policy[AFI_IP].tovpn_sid; if (tovpn_sid) { @@ -3478,8 +3486,6 @@ static int bgp_zebra_process_srv6_locator_delete(ZAPI_CALLBACK_ARGS) } } - vpn_leak_postchange_all(); - /* refresh tovpn_sid_locator */ for (ALL_LIST_ELEMENTS_RO(bm->bgp, node, bgp_vrf)) { if (bgp_vrf->inst_type != BGP_INSTANCE_TYPE_VRF) @@ -3531,6 +3537,8 @@ static int bgp_zebra_process_srv6_locator_delete(ZAPI_CALLBACK_ARGS) } } + vpn_leak_postchange_all(); + return 0; }