bgpd: fix label allocation per next-hop applied to unicast

The label allocation per next-hop functionality is calling
the 'bgp_find_or_add_nexthop()' method using the SAFI_MPLS_VPN
safi parameter, whereas the call is supposed to apply to
unicast paths.

Fix this by using the SAFI_UNICAST safi parameter in the call.
Simplify the vpn_leak_from_vrf_get_per_nexthop_label() API by
removing the safi parameter from the function.

Fixes: 577be36a41 ("bgpd: add support for l3vpn per-nexthop label")
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
This commit is contained in:
Philippe Guibert 2023-05-24 13:50:37 +02:00
parent ef1fc25431
commit 658c5ebe38

View File

@ -1404,9 +1404,10 @@ static int bgp_mplsvpn_get_label_per_nexthop_cb(mpls_label_t label,
* - else allocate a new per label nexthop cache entry and request a
* label to zebra. Return MPLS_INVALID_LABEL
*/
static mpls_label_t _vpn_leak_from_vrf_get_per_nexthop_label(
struct bgp_path_info *pi, struct bgp *to_bgp, struct bgp *from_bgp,
afi_t afi, safi_t safi)
static mpls_label_t
_vpn_leak_from_vrf_get_per_nexthop_label(struct bgp_path_info *pi,
struct bgp *to_bgp,
struct bgp *from_bgp, afi_t afi)
{
struct bgp_nexthop_cache *bnc = pi->nexthop;
struct bgp_label_per_nexthop_cache *blnc;
@ -1489,9 +1490,10 @@ static mpls_label_t _vpn_leak_from_vrf_get_per_nexthop_label(
* - return the per VRF label when the per nexthop label is not supported
* Otherwise, find or request a per label nexthop.
*/
static mpls_label_t vpn_leak_from_vrf_get_per_nexthop_label(
afi_t afi, safi_t safi, struct bgp_path_info *pi, struct bgp *from_bgp,
struct bgp *to_bgp)
static mpls_label_t
vpn_leak_from_vrf_get_per_nexthop_label(afi_t afi, struct bgp_path_info *pi,
struct bgp *from_bgp,
struct bgp *to_bgp)
{
struct bgp_path_info *bpi_ultimate = bgp_get_imported_bpi_ultimate(pi);
struct bgp *bgp_nexthop = NULL;
@ -1549,8 +1551,8 @@ static mpls_label_t vpn_leak_from_vrf_get_per_nexthop_label(
bgp_nexthop = from_bgp;
nh_afi = BGP_ATTR_NH_AFI(afi, pi->attr);
nh_valid = bgp_find_or_add_nexthop(from_bgp, bgp_nexthop, nh_afi, safi,
pi, NULL, 0, NULL);
nh_valid = bgp_find_or_add_nexthop(from_bgp, bgp_nexthop, nh_afi,
SAFI_UNICAST, pi, NULL, 0, NULL);
if (!nh_valid && is_bgp_static_route &&
!CHECK_FLAG(from_bgp->flags, BGP_FLAG_IMPORT_CHECK)) {
@ -1586,7 +1588,7 @@ static mpls_label_t vpn_leak_from_vrf_get_per_nexthop_label(
}
return _vpn_leak_from_vrf_get_per_nexthop_label(pi, to_bgp, from_bgp,
afi, safi);
afi);
}
/* cf vnc_import_bgp_add_route_mode_nvegroup() and add_vnc_route() */
@ -1785,7 +1787,7 @@ void vpn_leak_from_vrf_update(struct bgp *to_bgp, /* to */
BGP_VPN_POLICY_TOVPN_LABEL_PER_NEXTHOP))
/* per nexthop label mode */
label_val = vpn_leak_from_vrf_get_per_nexthop_label(
afi, safi, path_vrf, from_bgp, to_bgp);
afi, path_vrf, from_bgp, to_bgp);
else
/* per VRF label mode */
label_val = from_bgp->vpn_policy[afi].tovpn_label;