zebra: return route_node from rib_match_ipv4_safi
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>
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 @@
#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 @@
}
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;