]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Trust onlink flag for nexthop active resolution
authorvivek <vivek@cumulusnetworks.com>
Fri, 15 May 2020 23:22:01 +0000 (16:22 -0700)
committervivek <vivek@cumulusnetworks.com>
Fri, 15 May 2020 23:22:01 +0000 (16:22 -0700)
When checking if a nexthop is active, if it has been marked as onlink,
just check on the presence and status of the nexthop's interface. When
handling client request to create a route, if the client says that the
nexthop is onlink, trust it; when internally (in zebra) determining
that the nexthop is onlink, ensure it is only done in the case of an
interface with a /32 IP address which is the case for OSPF unnumbered.

Signed-off-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
Reviewed-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Stephen Worley <sworley@cumulusnetworks.com>
zebra/zapi_msg.c
zebra/zebra_nhg.c

index 092b5dd3c203be3992147e3b4c8f31076d92ef61..5db455528411fdccdb73c2903a1c27ac49d462bd 100644 (file)
@@ -1451,10 +1451,6 @@ static struct nexthop *nexthop_from_zapi(struct route_entry *re,
                        &api_nh->gate.ipv4, NULL, api_nh->ifindex,
                        api_nh->vrf_id);
 
-               ifp = if_lookup_by_index(api_nh->ifindex, api_nh->vrf_id);
-               if (ifp && connected_is_unnumbered(ifp))
-                       SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK);
-
                /* Special handling for IPv4 routes sourced from EVPN:
                 * the nexthop and associated MAC need to be installed.
                 */
@@ -1516,8 +1512,16 @@ static struct nexthop *nexthop_from_zapi(struct route_entry *re,
                goto done;
        }
 
+       /* Mark nexthop as onlink either if client has explicitly told us
+        * to or if the nexthop is on an 'unnumbered' interface.
+        */
        if (CHECK_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_ONLINK))
                SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK);
+       else if (api_nh->type == NEXTHOP_TYPE_IPV4_IFINDEX) {
+               ifp = if_lookup_by_index(api_nh->ifindex, api_nh->vrf_id);
+               if (ifp && connected_is_unnumbered(ifp))
+                       SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK);
+       }
 
        if (CHECK_FLAG(api_nh->flags, ZAPI_NEXTHOP_FLAG_WEIGHT))
                nexthop->weight = api_nh->weight;
index f24552c80bd6b4b6a8a4b9920e9a6e627b8849f0..fdbeac88e1c553545ced43a17df3559f95319124 100644 (file)
@@ -1776,33 +1776,24 @@ static int nexthop_active(afi_t afi, struct route_entry *re,
                return 1;
 
        /*
-        * Check to see if we should trust the passed in information
-        * for UNNUMBERED interfaces as that we won't find the GW
-        * address in the routing table.
-        * This check should suffice to handle IPv4 or IPv6 routes
-        * sourced from EVPN routes which are installed with the
-        * next hop as the remote VTEP IP.
+        * If the nexthop has been marked as 'onlink' we just need to make
+        * sure the nexthop's interface is known and is operational.
         */
        if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK)) {
                ifp = if_lookup_by_index(nexthop->ifindex, nexthop->vrf_id);
                if (!ifp) {
-                       if (IS_ZEBRA_DEBUG_RIB_DETAILED)
-                               zlog_debug(
-                                       "        %s: Onlink and interface: %u[%u] does not exist",
-                                       __func__, nexthop->ifindex,
-                                       nexthop->vrf_id);
+                       if (IS_ZEBRA_DEBUG_NHG_DETAIL)
+                               zlog_debug("nexthop %pNHv marked onlink but nhif %u doesn't exist",
+                                          nexthop, nexthop->ifindex);
                        return 0;
                }
-
-               if (if_is_operative(ifp))
-                       return 1;
-               else {
-                       if (IS_ZEBRA_DEBUG_RIB_DETAILED)
-                               zlog_debug(
-                                       "        %s: Onlink and interface %s is not operative",
-                                       __func__, ifp->name);
+               if (!if_is_operative(ifp)) {
+                       if (IS_ZEBRA_DEBUG_NHG_DETAIL)
+                               zlog_debug("nexthop %pNHv marked onlink but nhif %s is not operational",
+                                          nexthop, ifp->name);
                        return 0;
                }
+               return 1;
        }
 
        if ((top->p.family == AF_INET && top->p.prefixlen == 32