From: Feng Lu <lu.f...@6wind.com>

Later, an interface will belong to a specific VRF. Now we add a
property "vrf_id" to the "struct interface", and keep it as the
default value 0.

This property is shown when displaying interfaces information.
It is also added in some logs.

This is just the preparation to move the interace list into the
"struct vrf". The main logic is not changed.

Signed-off-by: Feng Lu <lu.f...@6wind.com>
Reviewed-by: Alain Ritoux <alain.rit...@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dich...@6wind.com>
---
 lib/if.c          |  8 ++++----
 lib/if.h          |  2 ++
 zebra/interface.c | 22 +++++++++++++---------
 3 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/lib/if.c b/lib/if.c
index 3a1f9b4150fa..f17e50863049 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -454,12 +454,12 @@ if_dump (const struct interface *ifp)
   struct connected *c __attribute__((unused));
 
   for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, c))
-    zlog_info ("Interface %s index %d metric %d mtu %d "
+    zlog_info ("Interface %s vrf %u index %d metric %d mtu %d "
 #ifdef HAVE_IPV6
                "mtu6 %d "
 #endif /* HAVE_IPV6 */
                "%s",
-               ifp->name, ifp->ifindex, ifp->metric, ifp->mtu, 
+               ifp->name, ifp->vrf_id, ifp->ifindex, ifp->metric, ifp->mtu,
 #ifdef HAVE_IPV6
                ifp->mtu6,
 #endif /* HAVE_IPV6 */
@@ -675,8 +675,8 @@ connected_log (struct connected *connected, char *str)
   ifp = connected->ifp;
   p = connected->address;
 
-  snprintf (logbuf, BUFSIZ, "%s interface %s %s %s/%d ", 
-           str, ifp->name, prefix_family_str (p),
+  snprintf (logbuf, BUFSIZ, "%s interface %s vrf %u %s %s/%d ",
+           str, ifp->name, ifp->vrf_id, prefix_family_str (p),
            inet_ntop (p->family, &p->u.prefix, buf, BUFSIZ),
            p->prefixlen);
 
diff --git a/lib/if.h b/lib/if.h
index 8081be87df0d..029f57fd7898 100644
--- a/lib/if.h
+++ b/lib/if.h
@@ -139,6 +139,8 @@ struct interface
 #ifdef HAVE_NET_RT_IFLIST
   struct if_data stats;
 #endif /* HAVE_NET_RT_IFLIST */
+
+  vrf_id_t vrf_id;
 };
 
 /* Connected address structure. */
diff --git a/zebra/interface.c b/zebra/interface.c
index 54d8b10389fa..4938fa1b9015 100644
--- a/zebra/interface.c
+++ b/zebra/interface.c
@@ -381,21 +381,23 @@ if_add_update (struct interface *ifp)
       if (if_data && if_data->shutdown == IF_ZEBRA_SHUTDOWN_ON)
        {
          if (IS_ZEBRA_DEBUG_KERNEL)
-           zlog_debug ("interface %s index %d is shutdown. Won't wake it up.",
-                       ifp->name, ifp->ifindex);
+           zlog_debug ("interface %s vrf %u index %d is shutdown. "
+                       "Won't wake it up.",
+                       ifp->name, ifp->vrf_id, ifp->ifindex);
          return;
        }
 
       if_addr_wakeup (ifp);
 
       if (IS_ZEBRA_DEBUG_KERNEL)
-       zlog_debug ("interface %s index %d becomes active.", 
-                   ifp->name, ifp->ifindex);
+       zlog_debug ("interface %s vrf %u index %d becomes active.",
+                   ifp->name, ifp->vrf_id, ifp->ifindex);
     }
   else
     {
       if (IS_ZEBRA_DEBUG_KERNEL)
-       zlog_debug ("interface %s index %d is added.", ifp->name, ifp->ifindex);
+       zlog_debug ("interface %s vrf %u index %d is added.",
+                   ifp->name, ifp->vrf_id, ifp->ifindex);
     }
 }
 
@@ -412,8 +414,8 @@ if_delete_update (struct interface *ifp)
 
   if (if_is_up(ifp))
     {
-      zlog_err ("interface %s index %d is still up while being deleted.",
-           ifp->name, ifp->ifindex);
+      zlog_err ("interface %s vrf %u index %d is still up while being 
deleted.",
+                ifp->name, ifp->vrf_id, ifp->ifindex);
       return;
     }
 
@@ -421,8 +423,8 @@ if_delete_update (struct interface *ifp)
   UNSET_FLAG (ifp->status, ZEBRA_INTERFACE_ACTIVE);
   
   if (IS_ZEBRA_DEBUG_KERNEL)
-    zlog_debug ("interface %s index %d is now inactive.",
-              ifp->name, ifp->ifindex);
+    zlog_debug ("interface %s vrf %u index %d is now inactive.",
+                ifp->name, ifp->vrf_id, ifp->ifindex);
 
   /* Delete connected routes from the kernel. */
   if (ifp->connected)
@@ -726,6 +728,8 @@ if_dump_vty (struct vty *vty, struct interface *ifp)
     vty_out (vty, "down%s", VTY_NEWLINE);
   }
 
+  vty_out (vty, "  vrf: %u%s", ifp->vrf_id, VTY_NEWLINE);
+
   if (ifp->desc)
     vty_out (vty, "  Description: %s%s", ifp->desc,
             VTY_NEWLINE);
-- 
2.2.2


_______________________________________________
Quagga-dev mailing list
Quagga-dev@lists.quagga.net
https://lists.quagga.net/mailman/listinfo/quagga-dev

Reply via email to