[quagga-dev 10544] [PATCH 2/3] bgpd, zebra: Support NEXTHOP_IPV4_IFINDEX in nexthop_lookup api

Christian Franke chris at opensourcerouting.org
Sat May 25 16:01:35 BST 2013


Since commit ba281d3d040, ospfd uses NEXTHOP_IPV4_IFINDEX
routes. The API between zebra and bgpd which is used to query
nexthops for recursive routes did not support this nexthop
type and therefore, ospf changes (or any other IGP changes
which use NEXTHOP_IPV4_IFINDEX) would never trigger any
recursive route update.

Signed-off-by: Christian Franke <chris at opensourcerouting.org>
---
 bgpd/bgp_nexthop.c |   13 +++++++++++++
 zebra/zserv.c      |   12 ++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c
index d469236..69440ce 100644
--- a/bgpd/bgp_nexthop.c
+++ b/bgpd/bgp_nexthop.c
@@ -122,6 +122,11 @@ bgp_nexthop_same (struct nexthop *next1, struct nexthop *next2)
       if (! IPV4_ADDR_SAME (&next1->gate.ipv4, &next2->gate.ipv4))
 	return 0;
       break;
+    case ZEBRA_NEXTHOP_IPV4_IFINDEX:
+      if (! IPV4_ADDR_SAME (&next1->gate.ipv4, &next2->gate.ipv4)
+	  || next1->ifindex != next2->ifindex)
+	return 0;
+      break;
     case ZEBRA_NEXTHOP_IFINDEX:
     case ZEBRA_NEXTHOP_IFNAME:
       if (next1->ifindex != next2->ifindex)
@@ -827,6 +832,10 @@ zlookup_read (void)
 	    case ZEBRA_NEXTHOP_IPV4:
 	      nexthop->gate.ipv4.s_addr = stream_get_ipv4 (s);
 	      break;
+	    case ZEBRA_NEXTHOP_IPV4_IFINDEX:
+	      nexthop->gate.ipv4.s_addr = stream_get_ipv4 (s);
+	      nexthop->ifindex = stream_getl (s);
+	      break;
 	    case ZEBRA_NEXTHOP_IFINDEX:
 	    case ZEBRA_NEXTHOP_IFNAME:
 	      nexthop->ifindex = stream_getl (s);
@@ -1299,6 +1308,10 @@ show_ip_bgp_scan_tables (struct vty *vty, const char detail)
 	      case NEXTHOP_TYPE_IPV4:
 		vty_out (vty, "  gate %s%s", inet_ntop (AF_INET, &bnc->nexthop[i].gate.ipv4, buf, INET6_ADDRSTRLEN), VTY_NEWLINE);
 		break;
+	      case NEXTHOP_TYPE_IPV4_IFINDEX:
+		vty_out (vty, "  gate %s", inet_ntop (AF_INET, &bnc->nexthop[i].gate.ipv4, buf, INET6_ADDRSTRLEN));
+		vty_out (vty, " ifidx %u%s", bnc->nexthop[i].ifindex, VTY_NEWLINE);
+		break;
 	      case NEXTHOP_TYPE_IFINDEX:
 		vty_out (vty, "  ifidx %u%s", bnc->nexthop[i].ifindex, VTY_NEWLINE);
 		break;
diff --git a/zebra/zserv.c b/zebra/zserv.c
index cb8dbcb..bcb1680 100644
--- a/zebra/zserv.c
+++ b/zebra/zserv.c
@@ -548,6 +548,8 @@ zsend_ipv4_nexthop_lookup (struct zserv *client, struct in_addr addr)
 
   if (rib)
     {
+      if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV)
+        zlog_debug("%s: Matching rib entry found.", __func__);
       stream_putl (s, rib->metric);
       num = 0;
       nump = stream_get_endp(s);
@@ -561,6 +563,10 @@ zsend_ipv4_nexthop_lookup (struct zserv *client, struct in_addr addr)
 	      case ZEBRA_NEXTHOP_IPV4:
 		stream_put_in_addr (s, &nexthop->gate.ipv4);
 		break;
+	      case ZEBRA_NEXTHOP_IPV4_IFINDEX:
+		stream_put_in_addr (s, &nexthop->gate.ipv4);
+		stream_putl (s, nexthop->ifindex);
+		break;
 	      case ZEBRA_NEXTHOP_IFINDEX:
 	      case ZEBRA_NEXTHOP_IFNAME:
 		stream_putl (s, nexthop->ifindex);
@@ -575,6 +581,8 @@ zsend_ipv4_nexthop_lookup (struct zserv *client, struct in_addr addr)
     }
   else
     {
+      if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV)
+        zlog_debug("%s: No matching rib entry found.", __func__);
       stream_putl (s, 0);
       stream_putc (s, 0);
     }
@@ -890,8 +898,12 @@ static int
 zread_ipv4_nexthop_lookup (struct zserv *client, u_short length)
 {
   struct in_addr addr;
+  char buf[BUFSIZ];
 
   addr.s_addr = stream_get_ipv4 (client->ibuf);
+  if (IS_ZEBRA_DEBUG_PACKET && IS_ZEBRA_DEBUG_RECV)
+    zlog_debug("%s: looking up %s", __func__,
+               inet_ntop (AF_INET, &addr, buf, BUFSIZ));
   return zsend_ipv4_nexthop_lookup (client, addr);
 }
 
-- 
1.7.10.4





More information about the Quagga-dev mailing list