Skip to content

Commit

Permalink
bgpd: Fix issue of SRv6 routes not withdrawn
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
cscarpitta committed Apr 3, 2024
1 parent da975a5 commit 11ad5c4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
11 changes: 8 additions & 3 deletions bgpd/bgp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down
12 changes: 10 additions & 2 deletions bgpd/bgp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -3531,6 +3537,8 @@ static int bgp_zebra_process_srv6_locator_delete(ZAPI_CALLBACK_ARGS)
}
}

vpn_leak_postchange_all();

return 0;
}

Expand Down

0 comments on commit 11ad5c4

Please sign in to comment.