zebra: mrib: Include BGP routes in RPF lookups
The rib_match_ipv4() function was previously used only for iBGP
recursive nexthop lookups, which ignore eBGP routes. This is not
desirable for PIM RPF lookups, which may well use an eBGP route.
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/rib.h b/zebra/rib.h
index 13011e2..aef7150 100644
--- a/zebra/rib.h
+++ b/zebra/rib.h
@@ -419,7 +419,7 @@
u_int32_t, safi_t safi);
extern struct rib *rib_match_ipv4 (struct in_addr);
-extern struct rib *rib_match_ipv4_safi (struct in_addr addr, safi_t safi);
+extern struct rib *rib_match_ipv4_safi (struct in_addr addr, safi_t safi, int skip_bgp);
extern struct rib *rib_lookup_ipv4 (struct prefix_ipv4 *);
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 469c10b..f4a9155 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -721,11 +721,11 @@
struct rib *
rib_match_ipv4 (struct in_addr addr)
{
- return rib_match_ipv4_safi (addr, SAFI_UNICAST);
+ return rib_match_ipv4_safi (addr, SAFI_UNICAST, 1);
}
struct rib *
-rib_match_ipv4_safi (struct in_addr addr, safi_t safi)
+rib_match_ipv4_safi (struct in_addr addr, safi_t safi, int skip_bgp)
{
struct route_table *table;
struct route_node *rn;
@@ -755,8 +755,7 @@
/* If there is no selected route or matched route is EGP, go up
tree. */
- if (! match
- || match->type == ZEBRA_ROUTE_BGP)
+ if (!match || (skip_bgp && (match->type == ZEBRA_ROUTE_BGP)))
{
do {
rn = rn->parent;
diff --git a/zebra/zserv.c b/zebra/zserv.c
index 89eb266..1b69315 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -612,16 +612,17 @@
unsigned long nump;
u_char num;
struct nexthop *nexthop;
+ int skip_bgp = 0; /* bool */
/* Lookup nexthop. */
- rib = rib_match_ipv4_safi (addr, SAFI_MULTICAST);
+ rib = rib_match_ipv4_safi (addr, SAFI_MULTICAST, skip_bgp);
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_safi (addr, SAFI_UNICAST);
+ rib = rib_match_ipv4_safi (addr, SAFI_UNICAST, skip_bgp);
if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV)
zlog_debug("%s: %s rib entry found.", __func__, rib ? "Matching" : "No matching");
}