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 <[email protected]>
Cc: Balaji G <[email protected]>
Signed-off-by: David Lamparter <[email protected]>
---
 zebra/rib.h       |  3 ++-
 zebra/zebra_rib.c | 21 ++++++++++++++-------
 zebra/zserv.c     |  4 ++--
 3 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/zebra/rib.h b/zebra/rib.h
index 5eedfde..347fadb 100644
--- a/zebra/rib.h
+++ b/zebra/rib.h
@@ -418,7 +418,8 @@ extern int rib_delete_ipv4 (int type, int flags, struct 
prefix_ipv4 *p,
                            struct in_addr *gate, unsigned int ifindex, 
                            u_int32_t, safi_t safi);
 
-extern struct rib *rib_match_ipv4_safi (struct in_addr addr, safi_t safi, int 
skip_bgp);
+extern struct rib *rib_match_ipv4_safi (struct in_addr addr, safi_t safi,
+                                       int skip_bgp, struct route_node 
**rn_out);
 
 extern struct rib *rib_lookup_ipv4 (struct prefix_ipv4 *);
 
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index b4ea242..abef90f 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -719,7 +719,8 @@ nexthop_active_ipv6 (struct rib *rib, struct nexthop 
*nexthop, int set,
 #endif /* HAVE_IPV6 */
 
 struct rib *
-rib_match_ipv4_safi (struct in_addr addr, safi_t safi, int skip_bgp)
+rib_match_ipv4_safi (struct in_addr addr, safi_t safi, int skip_bgp,
+                    struct route_node **rn_out)
 {
   struct route_table *table;
   struct route_node *rn;
@@ -759,16 +760,22 @@ rib_match_ipv4_safi (struct in_addr addr, safi_t safi, 
int skip_bgp)
        }
       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;
diff --git a/zebra/zserv.c b/zebra/zserv.c
index e9236de..e678f3a 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -540,7 +540,7 @@ zsend_ipv4_nexthop_lookup (struct zserv *client, struct 
in_addr addr)
   struct nexthop *nexthop;
 
   /* Lookup nexthop - eBGP excluded */
-  rib = rib_match_ipv4_safi (addr, SAFI_UNICAST, 1);
+  rib = rib_match_ipv4_safi (addr, SAFI_UNICAST, 1, NULL);
 
   /* Get output stream. */
   s = client->obuf;
@@ -615,7 +615,7 @@ zsend_ipv4_nexthop_lookup_mrib (struct zserv *client, 
struct in_addr addr)
   int skip_bgp = 0; /* bool */
 
   /* Lookup nexthop. */
-  rib = rib_match_ipv4_safi (addr, SAFI_MULTICAST, skip_bgp);
+  rib = rib_match_ipv4_safi (addr, SAFI_MULTICAST, skip_bgp, NULL);
 
   if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV)
     zlog_debug("%s: %s mrib entry found.", __func__, rib ? "Matching" : "No 
matching");
-- 
2.0.4


_______________________________________________
Quagga-dev mailing list
[email protected]
https://lists.quagga.net/mailman/listinfo/quagga-dev

Reply via email to