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: fix crash when unconfiguring a network with per-nexthop allocation mode #18150

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
6 changes: 6 additions & 0 deletions bgpd/bgp_labelpool.c
Original file line number Diff line number Diff line change
Expand Up @@ -1734,6 +1734,12 @@ bgp_label_per_nexthop_find(struct bgp_label_per_nexthop_cache_head *tree,

void bgp_label_per_nexthop_free(struct bgp_label_per_nexthop_cache *blnc)
{
if (blnc->allocation_in_progress) {
blnc->allocation_in_progress = false;
bgp_label_per_nexthop_cache_del(blnc->tree, blnc);
return;
}

if (blnc->label != MPLS_INVALID_LABEL) {
bgp_zebra_send_nexthop_label(ZEBRA_MPLS_LABELS_DELETE,
blnc->label, blnc->nh->ifindex,
Expand Down
2 changes: 2 additions & 0 deletions bgpd/bgp_labelpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ struct bgp_label_per_nexthop_cache {

/* Back pointer to the cache tree this entry belongs to. */
struct bgp_label_per_nexthop_cache_head *tree;

bool allocation_in_progress;
};

DECLARE_RBTREE_UNIQ(bgp_label_per_nexthop_cache,
Expand Down
6 changes: 6 additions & 0 deletions bgpd/bgp_mplsvpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,11 @@ static int bgp_mplsvpn_get_label_per_nexthop_cb(mpls_label_t label,
*/
blnc->label = MPLS_INVALID_LABEL;

if (!blnc->allocation_in_progress) {
bgp_label_per_nexthop_free(blnc);
return 0;
}

if (old_label == blnc->label)
return 0; /* no change */

Expand Down Expand Up @@ -1478,6 +1483,7 @@ _vpn_leak_from_vrf_get_per_nexthop_label(struct bgp_path_info *pi,
/* request a label to zebra for this nexthop
* the response from zebra will trigger the callback
*/
blnc->allocation_in_progress = true;
bgp_lp_get(LP_TYPE_NEXTHOP, blnc, from_bgp->vrf_id,
bgp_mplsvpn_get_label_per_nexthop_cb);
}
Expand Down
Loading