This commit is contained in:
Philippe Guibert 2025-04-29 16:20:43 +00:00 committed by GitHub
commit adacd46246
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 0 deletions

View file

@ -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,

View file

@ -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,

View file

@ -1414,6 +1414,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 */
@ -1487,6 +1492,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);
}