Skip to content

Commit

Permalink
Merge pull request #16403 from lsang6WIND/vpn_leak_label
Browse files Browse the repository at this point in the history
bgpd: fix label lost when vrf loopback comes back
  • Loading branch information
riw777 authored Jul 23, 2024
2 parents fba472e + c21c597 commit ea5498e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions bgpd/bgp_mplsvpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,16 @@ int bgp_nlri_parse_vpn(struct peer *peer, struct attr *attr,
*
* Sending this vrf-label association is qualified by a) whether vrf->vpn
* exporting is active ("export vpn" is enabled, vpn-policy RD and RT list
* are set) and b) whether vpn-policy label is set.
* are set), b) whether vpn-policy label is set and c) the vrf loopback
* interface is up.
*
* If any of these conditions do not hold, then we send MPLS_LABEL_NONE
* for this vrf, which zebra interprets to mean "delete this vrf-label
* association."
*/
void vpn_leak_zebra_vrf_label_update(struct bgp *bgp, afi_t afi)
{
struct interface *ifp;
mpls_label_t label = MPLS_LABEL_NONE;
int debug = BGP_DEBUG(vpn, VPN_LEAK_LABEL);

Expand All @@ -301,7 +303,9 @@ void vpn_leak_zebra_vrf_label_update(struct bgp *bgp, afi_t afi)
}

if (vpn_leak_to_vpn_active(bgp, afi, NULL, false)) {
label = bgp->vpn_policy[afi].tovpn_label;
ifp = if_get_vrf_loopback(bgp->vrf_id);
if (ifp && if_is_vrf(ifp) && if_is_up(ifp))
label = bgp->vpn_policy[afi].tovpn_label;
}

if (debug) {
Expand Down
4 changes: 2 additions & 2 deletions bgpd/bgp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ static int bgp_ifp_up(struct interface *ifp)
hook_call(bgp_vrf_status_changed, bgp, ifp);
bgp_nht_ifp_up(ifp);

if (bgp_get_default() && if_is_loopback(ifp)) {
if (bgp_get_default() && if_is_vrf(ifp)) {
vpn_leak_zebra_vrf_label_update(bgp, AFI_IP);
vpn_leak_zebra_vrf_label_update(bgp, AFI_IP6);
vpn_leak_zebra_vrf_sid_update(bgp, AFI_IP);
Expand Down Expand Up @@ -289,7 +289,7 @@ static int bgp_ifp_down(struct interface *ifp)
hook_call(bgp_vrf_status_changed, bgp, ifp);
bgp_nht_ifp_down(ifp);

if (bgp_get_default() && if_is_loopback(ifp)) {
if (bgp_get_default() && if_is_vrf(ifp)) {
vpn_leak_zebra_vrf_label_withdraw(bgp, AFI_IP);
vpn_leak_zebra_vrf_label_withdraw(bgp, AFI_IP6);
vpn_leak_zebra_vrf_sid_withdraw(bgp, AFI_IP);
Expand Down

0 comments on commit ea5498e

Please sign in to comment.