]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib, zebra: Rework vrf_add_update
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 13 Apr 2016 14:06:36 +0000 (10:06 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Fri, 15 Apr 2016 00:56:43 +0000 (20:56 -0400)
The vrf_add_update function does not need to exist.
Move it's constituent parts into the appropriate
vrf_create/vrf_enable functionality as well as
move the zebra_vrf_add_update() function call
into zebra_vrf_enable()

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Reviewed-by: Don Slice <dslice@cumulusnetworks.com>
Reviewed-by: Vivek Venkatraman <vivek@cumulusnetworks.com>
lib/vrf.c
zebra/interface.c
zebra/main.c
zebra/rt_netlink.c

index eab720fe1d19b19a1be78a4f6c5ce2eb42aaa3b0..90f8fa86ba704b70831a239418787b8aca6199fe 100644 (file)
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -231,20 +231,16 @@ vrf_is_enabled (struct vrf *vrf)
 int
 vrf_enable (struct vrf *vrf)
 {
-//Pending: see if VRF lib had a reason to leave it for default only
-// /* Till now, only the default VRF can be enabled. */
-//  if (vrf->vrf_id == VRF_DEFAULT)
-//    {
   if (debug_vrf)
     zlog_debug ("VRF %u is enabled.", vrf->vrf_id);
 
-      if (vrf_master.vrf_enable_hook)
-        (*vrf_master.vrf_enable_hook) (vrf->vrf_id, vrf->name, &vrf->info);
+  if (!CHECK_FLAG (vrf->status, VRF_ACTIVE))
+    SET_FLAG (vrf->status, VRF_ACTIVE);
 
-      return 1;
-//    }
+  if (vrf_master.vrf_enable_hook)
+    (*vrf_master.vrf_enable_hook) (vrf->vrf_id, vrf->name, &vrf->info);
 
-//  return 0;
+  return 1;
 }
 
 /*
index cd5f1d9f0de09cc13359ec1372622df6a28d8edc..df6848f05aca50ee100562b195c78407518ac689 100644 (file)
@@ -714,31 +714,6 @@ if_handle_vrf_change (struct interface *ifp, vrf_id_t vrf_id)
   rib_update (ifp->vrf_id, RIB_UPDATE_IF_CHANGE);
 }
 
-
-/* Handle VRF addition */
-void
-vrf_add_update (struct vrf *vrfp)
-{
-  zebra_vrf_add_update (vrf_info_lookup (vrfp->vrf_id));
-
-  if (! CHECK_FLAG (vrfp->status, VRF_ACTIVE))
-    {
-      SET_FLAG (vrfp->status, VRF_ACTIVE);
-
-     //Pending: Check if the equivalent of if_addr_wakeup (ifp) is needed here.
-
-      if (IS_ZEBRA_DEBUG_KERNEL)
-       zlog_debug ("VRF %s id %u becomes active.",
-                   vrfp->name, vrfp->vrf_id);
-    }
-  else
-    {
-      if (IS_ZEBRA_DEBUG_KERNEL)
-       zlog_debug ("VRF %s id %u is added.",
-                   vrfp->name, vrfp->vrf_id);
-    }
-}
-
 static void
 ipv6_ll_address_to_mac (struct in6_addr *address, u_char *mac)
 {
index eb46aad6ca0d886a9fad181f995953358e8d9bd8..5da91042d3133172870c6c79146b107b351c3962 100644 (file)
@@ -43,6 +43,7 @@
 #include "zebra/rtadv.h"
 #include "zebra/zebra_fpm.h"
 #include "zebra/zebra_ptm.h"
+#include "zebra/redistribute.h"
 
 #define ZEBRA_PTM_SUPPORT
 
@@ -276,6 +277,8 @@ zebra_vrf_enable (vrf_id_t vrf_id, const char *name, void **info)
 
   assert (zvrf);
 
+  zebra_vrf_add_update (zvrf);
+
   return 0;
 }
 
index 41db582df4785560a8a39aa124bc6f2b0a5805e0..499881877ee5c15fddf56025f40bb9b52d65af92 100644 (file)
@@ -556,6 +556,9 @@ netlink_vrf_change (struct nlmsghdr *h, struct rtattr *tb, const char *name)
         zlog_debug ("RTM_NEWLINK for VRF %s(%u) table %u",
                     name, ifi->ifi_index, nl_table_id);
 
+      /*
+       * vrf_get is implied creation if it does not exist
+       */
       vrf = vrf_get((vrf_id_t)ifi->ifi_index, name); // It would create vrf
       if (!vrf)
         {
@@ -570,11 +573,14 @@ netlink_vrf_change (struct nlmsghdr *h, struct rtattr *tb, const char *name)
           return;
         }
 
-      /*Pending: See if you want to optimize this code.. vrf, zvrf all have name */
-      zvrf = vrf->info;
+      /*
+       * This is the only place that we get the actual kernel table_id
+       * being used.  We need it to set the table_id of the routes
+       * we are passing to the kernel.... And to throw some totally
+       * awesome parties. that too.
+       */
+      zvrf = (struct zebra_vrf *)vrf->info;
       zvrf->table_id = nl_table_id;
-
-      vrf_add_update(vrf);
     }
   else //h->nlmsg_type == RTM_DELLINK
     {