Browse Source

zebra: Add check to notice when an interface is unnumbered

If an interface is not a loopback and it's prefixlen == 32
assume that it is unnumbered.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Donald Sharp 4 years ago
parent
commit
4c7efde6db
3 changed files with 13 additions and 1 deletions
  1. 1 0
      lib/if.h
  2. 9 1
      zebra/connected.c
  3. 3 0
      zebra/interface.c

+ 1 - 0
lib/if.h

@@ -282,6 +282,7 @@ struct connected
   u_char flags;
 #define ZEBRA_IFA_SECONDARY    (1 << 0)
 #define ZEBRA_IFA_PEER         (1 << 1)
+#define ZEBRA_IFA_UNNUMBERED   (1 << 2)
   /* N.B. the ZEBRA_IFA_PEER flag should be set if and only if
      a peer address has been configured.  If this flag is set,
      the destination field must contain the peer address.  

+ 9 - 1
zebra/connected.c

@@ -77,7 +77,15 @@ connected_announce (struct interface *ifp, struct connected *ifc)
 {
   if (!ifc)
     return;
-  
+
+  if (!if_is_loopback(ifp) && ifc->address->family == AF_INET)
+    {
+      if (ifc->address->prefixlen == 32)
+        SET_FLAG (ifc->flags, ZEBRA_IFA_UNNUMBERED);
+      else
+        UNSET_FLAG (ifc->flags, ZEBRA_IFA_UNNUMBERED);
+    }
+
   listnode_add (ifp->connected, ifc);
 
   /* Update interface address information to protocol daemon. */

+ 3 - 0
zebra/interface.c

@@ -736,6 +736,9 @@ connected_dump_vty (struct vty *vty, struct connected *connected)
   if (CHECK_FLAG (connected->flags, ZEBRA_IFA_SECONDARY))
     vty_out (vty, " secondary");
 
+  if (CHECK_FLAG (connected->flags, ZEBRA_IFA_UNNUMBERED))
+    vty_out (vty, " unnumbered");
+
   if (connected->label)
     vty_out (vty, " %s", connected->label);