From: Philippe Guibert Date: Thu, 1 Jun 2023 05:20:06 +0000 (+0200) Subject: bgpd: fix use nexthop tracking for exported vpn paths X-Git-Tag: base_9.1~351^2~2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=b9c7e7a1a9ab22e83571652ff092bb519a7386f7;p=mirror%2Ffrr.git bgpd: fix use nexthop tracking for exported vpn paths When exporting redistributed prefixes from a given VRF to an MPLS VPN network, the paths are always considered as valid whereas it should not always be the case. At exportation, a new MPLS VPN path is built in. Then nexthop tracking is applied to the new path, and the SAFI_MPLS_VPN parameter is used to tell the NHT code to just check for the next-hop reachability. The previous commit was wrongly considering that nexthop tracking was never applied to mpls vpn networks. Ensure that nexthop tracking for exported paths behaves as usual. Fix this by not returning always 1 in the 'bgp_find_or_add_nexthop()' function if the passed 'pi' parameter is a 'BGP_IMPORTED_ROUTE' sub-type entry. Fixes: 74be3f3ea9ec ("bgpd: track mpls vpn nexthops") Signed-off-by: Philippe Guibert --- diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index 4770434b62..ba5b0c7a7d 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -468,10 +468,12 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop, pi->sub_type == BGP_ROUTE_IMPORTED && pi->extra && pi->extra->num_labels && !bnc->is_evpn_gwip_nexthop) return bgp_isvalid_nexthop_for_mpls(bnc, pi); - else if (safi == SAFI_MPLS_VPN) + else if (safi == SAFI_MPLS_VPN && pi && + pi->sub_type != BGP_ROUTE_IMPORTED) /* avoid not redistributing mpls vpn routes */ return 1; else + /* mpls-vpn routes with BGP_ROUTE_IMPORTED subtype */ return (bgp_isvalid_nexthop(bnc)); } @@ -1194,10 +1196,12 @@ void evaluate_paths(struct bgp_nexthop_cache *bnc) bnc_is_valid_nexthop = bgp_isvalid_nexthop_for_mpls(bnc, path) ? true : false; - } else if (safi == SAFI_MPLS_VPN) { + } else if (safi == SAFI_MPLS_VPN && + path->sub_type != BGP_ROUTE_IMPORTED) { /* avoid not redistributing mpls vpn routes */ bnc_is_valid_nexthop = true; } else { + /* mpls-vpn routes with BGP_ROUTE_IMPORTED subtype */ if (bgp_update_martian_nexthop( bnc->bgp, afi, safi, path->type, path->sub_type, path->attr, dest)) {