]> git.puffer.fish Git - mirror/frr.git/commitdiff
zebra: return route_node from rib_match_ipv4_safi
authorDavid Lamparter <equinox@opensourcerouting.org>
Thu, 22 Jan 2015 18:09:36 +0000 (19:09 +0100)
committerDonald Sharp <sharpd@cumulusnetwroks.com>
Thu, 26 May 2016 00:38:31 +0000 (20:38 -0400)
The multicast code needs to know the route_node in addition to the rib
entry in order to perform distance or prefix-length comparisons.  Add it
as optional "out" pointer parameter.

Cc: Everton Marques <everton.marques@gmail.com>
Cc: Balaji G <balajig81@gmail.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
zebra/rib.h
zebra/zebra_rib.c
zebra/zserv.c

index e912cfb2053fae13b96b767cd7d0757171ebc77c..8f23c57c1792b2e1d67cec0ae30f5e0d152f166c 100644 (file)
@@ -369,7 +369,8 @@ extern int rib_delete_ipv4 (int type, u_short instance, int flags, struct prefix
                            struct in_addr *gate, unsigned int ifindex, 
                            vrf_id_t, u_int32_t, safi_t safi);
 
-extern struct rib *rib_match_ipv4 (struct in_addr, safi_t safi, vrf_id_t);
+extern struct rib *rib_match_ipv4 (struct in_addr, safi_t safi, vrf_id_t,
+                                  struct route_node **rn_out);
 
 extern struct rib *rib_lookup_ipv4 (struct prefix_ipv4 *, vrf_id_t);
 
index e428471564362ad0e6da17cc55a00e7328e0bd86..87b0ebd79ad9e6a80aeb32b15b64699ec0d74489 100644 (file)
@@ -733,7 +733,8 @@ nexthop_active_ipv6 (struct rib *rib, struct nexthop *nexthop, int set,
 }
 
 struct rib *
-rib_match_ipv4 (struct in_addr addr, safi_t safi, vrf_id_t vrf_id)
+rib_match_ipv4 (struct in_addr addr, safi_t safi, vrf_id_t vrf_id,
+               struct route_node **rn_out)
 {
   struct prefix_ipv4 p;
   struct route_table *table;
@@ -779,16 +780,22 @@ rib_match_ipv4 (struct in_addr addr, safi_t safi, vrf_id_t vrf_id)
        }
       else
        {
-         if (match->type == ZEBRA_ROUTE_CONNECT)
-           /* Directly point connected route. */
-           return match;
-         else
+         if (match->type != ZEBRA_ROUTE_CONNECT)
            {
+             int found = 0;
              for (ALL_NEXTHOPS_RO(match->nexthop, newhop, tnewhop, recursing))
                if (CHECK_FLAG (newhop->flags, NEXTHOP_FLAG_FIB))
-                 return match;
-             return NULL;
+                 {
+                   found = 1;
+                   break;
+                 }
+             if (!found)
+               return NULL;
            }
+
+         if (rn_out)
+           *rn_out = rn;
+         return match;
        }
     }
   return NULL;
index eb616b0405f838f12d889716cb529583e66f6a1f..79da6ba7ab38c6b488dc1841a5765f7e5f169691 100644 (file)
@@ -788,7 +788,7 @@ zsend_ipv4_nexthop_lookup (struct zserv *client, struct in_addr addr,
   struct nexthop *nexthop;
 
   /* Lookup nexthop. */
-  rib = rib_match_ipv4 (addr, SAFI_UNICAST, vrf_id);
+  rib = rib_match_ipv4 (addr, SAFI_UNICAST, vrf_id, NULL);
 
   /* Get output stream. */
   s = client->obuf;
@@ -974,14 +974,14 @@ zsend_ipv4_nexthop_lookup_mrib (struct zserv *client, struct in_addr addr, struc
   struct nexthop *nexthop;
 
   /* Lookup nexthop. */
-  rib = rib_match_ipv4 (addr, SAFI_MULTICAST, zvrf->vrf_id);
+  rib = rib_match_ipv4 (addr, SAFI_MULTICAST, zvrf->vrf_id, NULL);
 
   if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV)
     zlog_debug("%s: %s mrib entry found.", __func__, rib ? "Matching" : "No matching");
 
   if (!rib) {
     /* Retry lookup with unicast rib */
-    rib = rib_match_ipv4 (addr, SAFI_UNICAST, zvrf->vrf_id);
+    rib = rib_match_ipv4 (addr, SAFI_UNICAST, zvrf->vrf_id, NULL);
     if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV)
       zlog_debug("%s: %s rib entry found.", __func__, rib ? "Matching" : "No matching");
   }