From: James Li <[email protected]>

When a routing protocol sends a NEXTHOP_TYPE_IPV4_IFINDEX
and the interface is unnumbered, treat the nexthop as ONLINK.

Additionally trust the passed route does not need to be
tested for correctness.

This patch originated from Denis Ovsienko <[email protected]>
https://github.com/Quagga-RE/quagga-RE/commit/b9c1e9ac3e261231d8f1f72e3942c9be775ff2de
  -> At this point in time it is mainly historical as that we've had
     to massage the patch multiple times to get it to work properly

Signed-off-by: James Li <[email protected]>
Signed-off-by: Dinesh Dutt <[email protected]>
Signed-off-by: Donald Sharp <[email protected]>
Reviewed-by: JR Rivers <[email protected]>
---
 zebra/connected.c | 16 ++++++++++++++++
 zebra/connected.h |  1 +
 zebra/zebra_rib.c | 27 +++++++++++++++++++++++++++
 3 files changed, 44 insertions(+)

diff --git a/zebra/connected.c b/zebra/connected.c
index 77e94d1..f2f523f 100644
--- a/zebra/connected.c
+++ b/zebra/connected.c
@@ -479,4 +479,20 @@ connected_delete_ipv6 (struct interface *ifp, struct 
in6_addr *address,
 
   rib_update (ifp->vrf_id);
 }
+
+int
+connected_is_unnumbered (struct interface *ifp)
+{
+  struct connected *connected;
+  struct listnode *node;
+
+  for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected))
+    {
+      if (CHECK_FLAG (connected->conf, ZEBRA_IFC_REAL) &&
+         connected->address->family == AF_INET)
+       return CHECK_FLAG(connected->flags, ZEBRA_IFA_UNNUMBERED);
+    }
+  return 0;
+}
+
 #endif /* HAVE_IPV6 */
diff --git a/zebra/connected.h b/zebra/connected.h
index 9595ddb..c589bd6 100644
--- a/zebra/connected.h
+++ b/zebra/connected.h
@@ -52,4 +52,5 @@ extern void connected_down_ipv6 (struct interface *ifp, 
struct connected *);
 
 #endif /* HAVE_IPV6 */
 
+extern int connected_is_unnumbered (struct interface *);
 #endif /*_ZEBRA_CONNECTED_H */
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index a3b915b..8c49554 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -37,6 +37,7 @@
 #include "vrf.h"
 #include "nexthop.h"
 
+#include "zebra/connected.h"
 #include "zebra/rib.h"
 #include "zebra/rt.h"
 #include "zebra/zserv.h"
@@ -251,11 +252,17 @@ rib_nexthop_ipv6_ifindex_add (struct rib *rib, struct 
in6_addr *ipv6,
                              unsigned int ifindex)
 {
   struct nexthop *nexthop;
+  struct interface *ifp;
 
   nexthop = nexthop_new ();
   nexthop->type = NEXTHOP_TYPE_IPV6_IFINDEX;
   nexthop->gate.ipv6 = *ipv6;
   nexthop->ifindex = ifindex;
+  ifp = if_lookup_by_index (nexthop->ifindex);
+  if (connected_is_unnumbered(ifp))
+    {
+      SET_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK);
+    }
 
   rib_nexthop_add (rib, nexthop);
 
@@ -511,6 +518,7 @@ nexthop_active_ipv6 (struct rib *rib, struct nexthop 
*nexthop, int set,
   struct nexthop *newhop, *tnewhop;
   int recursing = 0;
   struct nexthop *resolved_hop;
+  struct interface *ifp;
 
   if (nexthop->type == NEXTHOP_TYPE_IPV6)
     nexthop->ifindex = 0;
@@ -529,6 +537,25 @@ nexthop_active_ipv6 (struct rib *rib, struct nexthop 
*nexthop, int set,
   if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_FILTERED))
     return 0;
 
+  /*
+   * Check to see if we should trust the passed in information
+   * for UNNUMBERED interfaces as that we won't find the GW
+   * address in the routing table.
+   */
+  if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ONLINK))
+    {
+      ifp = if_lookup_by_index (nexthop->ifindex);
+      if (ifp && connected_is_unnumbered(ifp))
+       {
+         if (if_is_operative(ifp))
+           return 1;
+         else
+           return 0;
+       }
+      else
+       return 0;
+    }
+
   /* Make lookup prefix. */
   memset (&p, 0, sizeof (struct prefix_ipv6));
   p.family = AF_INET6;
-- 
1.9.1


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

Reply via email to