Browse Source

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>
Everton Marques 5 years ago
parent
commit
83d711234a
3 changed files with 7 additions and 7 deletions
  1. 1 1
      zebra/rib.h
  2. 3 4
      zebra/zebra_rib.c
  3. 3 2
      zebra/zserv.c

+ 1 - 1
zebra/rib.h

@@ -419,7 +419,7 @@ extern int rib_delete_ipv4 (int type, int flags, struct prefix_ipv4 *p,
 		            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 *);
 

+ 3 - 4
zebra/zebra_rib.c

@@ -721,11 +721,11 @@ nexthop_active_ipv6 (struct rib *rib, struct nexthop *nexthop, int set,
 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 @@ rib_match_ipv4_safi (struct in_addr addr, safi_t safi)
 
       /* 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;

+ 3 - 2
zebra/zserv.c

@@ -612,16 +612,17 @@ zsend_ipv4_nexthop_lookup_mrib (struct zserv *client, struct in_addr addr)
   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");
   }