]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: fix use nexthop tracking for exported vpn paths
authorPhilippe Guibert <philippe.guibert@6wind.com>
Thu, 1 Jun 2023 05:20:06 +0000 (07:20 +0200)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 16 Jun 2023 08:55:17 +0000 (10:55 +0200)
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 <philippe.guibert@6wind.com>
bgpd/bgp_nht.c

index 4770434b62fe69db394ebe3b6837394d1752fc7a..ba5b0c7a7d011a59ab8b6b48abcb531ba05b2c60 100644 (file)
@@ -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)) {