]> git.proxmox.com Git - mirror_frr.git/commitdiff
*: call if_init()/if_terminate() from vrf_init()/vrf_terminate()
authorFeng Lu <lu.feng@6wind.com>
Fri, 22 May 2015 09:39:58 +0000 (11:39 +0200)
committerVipin Kumar <vipin@cumulusnetworks.com>
Fri, 30 Oct 2015 00:00:32 +0000 (17:00 -0700)
Later, an interface will belong to a specific VRF, and the interface
initialization will be a part of the VRF initialization. So now call
if_init() from vrf_init(), and if_terminate() from vrf_terminate().

Daemons have the according changes:
- if if_init() was called or "iflist" was initialized, now call
  vrf_init() instead;
- if if_terminate() was called or "iflist" was destroyed, now call
  vrf_terminate() instead.

Signed-off-by: Feng Lu <lu.feng@6wind.com>
Reviewed-by: Alain Ritoux <alain.ritoux@6wind.com>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Acked-by: Vincent JARDIN <vincent.jardin@6wind.com>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Conflicts:
bgpd/bgp_main.c
pimd/pim_iface.c
pimd/pim_iface.h
pimd/pim_main.c
pimd/pimd.c

14 files changed:
bgpd/bgp_main.c
bgpd/bgp_zebra.c
isisd/isis_circuit.c
isisd/isis_main.c
lib/vrf.c
ospf6d/ospf6_main.c
ospfd/ospf_interface.c
ospfd/ospf_main.c
ripd/rip_interface.c
ripd/rip_main.c
ripngd/ripng_interface.c
ripngd/ripng_main.c
zebra/interface.c
zebra/test_main.c

index 49712fcf99fb2d554c8eda84d40b9d20149d330b..bf154db046ce3b61a1e82a20b6ee8af8fd648633 100644 (file)
@@ -37,6 +37,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 #include "plist.h"
 #include "stream.h"
 #include "queue.h"
+#include "vrf.h"
 
 #include "bgpd/bgpd.h"
 #include "bgpd/bgp_attr.h"
@@ -238,17 +239,14 @@ bgp_exit (int status)
   /* reverse bgp_zebra_init/if_init */
   if (retain_mode)
     if_add_hook (IF_DELETE_HOOK, NULL);
-  for (ALL_LIST_ELEMENTS (iflist, node, nnode, ifp))
+  for (ALL_LIST_ELEMENTS_RO (iflist, node, ifp))
     {
       struct listnode *c_node, *c_nnode;
       struct connected *c;
 
       for (ALL_LIST_ELEMENTS (ifp->connected, c_node, c_nnode, c))
         bgp_connected_delete (c);
-
-      if_delete (ifp);
     }
-  list_free (iflist);
 
   /* reverse bgp_attr_init */
   bgp_attr_finish ();
@@ -280,6 +278,7 @@ bgp_exit (int status)
   /* reverse community_list_init */
   community_list_terminate (bgp_clist);
 
+  vrf_terminate ();
   cmd_terminate ();
   vty_terminate ();
   if (zclient)
@@ -412,6 +411,7 @@ main (int argc, char **argv)
   cmd_init (1);
   vty_init (bm->master);
   memory_init ();
+  vrf_init ();
 
   /* BGP related initialization.  */
   bgp_init ();
index 052c2efacb421f4f75c0c5de940de167c6edfef5..501af234a2741bbd41c76368adea96c0f2c9e0e9 100644 (file)
@@ -1738,9 +1738,6 @@ bgp_zebra_init (struct thread_master *master)
   zclient->nexthop_update = bgp_read_nexthop_update;
   zclient->import_check_update = bgp_read_import_check_update;
 
-  /* Interface related init. */
-  if_init ();
-
   bgp_nexthop_buf = stream_new(BGP_NEXTHOP_BUF_SIZE);
   bgp_ifindices_buf = stream_new(BGP_IFINDICES_BUF_SIZE);
 }
index 4f7e2ce9ce34317127dd0a5d45e2e69cd1ba0ea0..470a86e39d5ea61d3cbdf5b1ad0fa76a351afc28 100644 (file)
@@ -2739,7 +2739,6 @@ void
 isis_circuit_init ()
 {
   /* Initialize Zebra interface data structure */
-  if_init ();
   if_add_hook (IF_NEW_HOOK, isis_if_new_hook);
   if_add_hook (IF_DELETE_HOOK, isis_if_delete_hook);
 
index 75463b33bbadb50db46e9c8fef4915cdb85a3d95..a19399c5a2a66c782a8f36a0b09b7751daeee36c 100644 (file)
@@ -35,6 +35,7 @@
 #include "sigevent.h"
 #include "filter.h"
 #include "zclient.h"
+#include "vrf.h"
 
 #include "isisd/dict.h"
 #include "include-netbsd/iso.h"
@@ -335,6 +336,7 @@ main (int argc, char **argv, char **envp)
   vty_init (master);
   memory_init ();
   access_list_init();
+  vrf_init ();
   isis_init ();
   isis_circuit_init ();
   isis_spf_cmds_init ();
index 3ccbb99617e11f37dd26af0dfcc8d1494da7a2dd..51f9e3795b8bda58a07f5c92f5e7a0795a7f0eac 100644 (file)
--- a/lib/vrf.c
+++ b/lib/vrf.c
@@ -22,6 +22,7 @@
 
 #include <zebra.h>
 
+#include "if.h"
 #include "vrf.h"
 #include "prefix.h"
 #include "table.h"
@@ -249,6 +250,8 @@ vrf_init (void)
 
   /* Set the default VRF name. */
   default_vrf->name = XSTRDUP (MTYPE_VRF_NAME, "Default-IP-Routing-Table");
+
+  if_init ();
 }
 
 /* Terminate VRF module. */
@@ -264,5 +267,7 @@ vrf_terminate (void)
 
   route_table_finish (vrf_table);
   vrf_table = NULL;
+
+  if_terminate ();
 }
 
index 75e409357c6a4c89bb1937295339e988615a6245..af48d1fe4cfeb98d60cc178763eac9ca1d5898d3 100644 (file)
@@ -36,6 +36,7 @@
 #include "privs.h"
 #include "sigevent.h"
 #include "zclient.h"
+#include "vrf.h"
 
 #include "ospf6d.h"
 #include "ospf6_top.h"
@@ -151,7 +152,7 @@ ospf6_exit (int status)
   ospf6_asbr_terminate ();
   ospf6_lsa_terminate ();
 
-  if_terminate ();
+  vrf_terminate ();
   vty_terminate ();
   cmd_terminate ();
 
@@ -322,7 +323,7 @@ main (int argc, char *argv[], char *envp[])
   cmd_init (1);
   vty_init (master);
   memory_init ();
-  if_init ();
+  vrf_init ();
   access_list_init ();
   prefix_list_init ();
 
index b10f4fb4f7efa5f5aacfd21ee7523fa43c58cd62..c0b4e7abea698dd6d806b9c01ab7e5d7e8bc5bde 100644 (file)
@@ -1269,7 +1269,6 @@ void
 ospf_if_init ()
 {
   /* Initialize Zebra interface data structure. */
-  if_init ();
   om->iflist = iflist;
   if_add_hook (IF_NEW_HOOK, ospf_if_new_hook);
   if_add_hook (IF_DELETE_HOOK, ospf_if_delete_hook);
index e1f5a9a9bb8c9eb462a70d78b6da1c25a7b27361..4e67b20bbade75d47b5f2df708af608be4dc97bc 100644 (file)
@@ -39,6 +39,7 @@
 #include "privs.h"
 #include "sigevent.h"
 #include "zclient.h"
+#include "vrf.h"
 
 #include "ospfd/ospfd.h"
 #include "ospfd/ospf_interface.h"
@@ -300,6 +301,7 @@ main (int argc, char **argv)
   debug_init ();
   vty_init (master);
   memory_init ();
+  vrf_init ();
 
   access_list_init ();
   prefix_list_init ();
index 9a5bffe92b03ad316f02e1e5b99455e0925516ae..b12ce5ee103c961c21ee1b795df50ccdb1980720 100644 (file)
@@ -2077,7 +2077,6 @@ void
 rip_if_init (void)
 {
   /* Default initial size of interface vector. */
-  if_init();
   if_add_hook (IF_NEW_HOOK, rip_interface_new_hook);
   if_add_hook (IF_DELETE_HOOK, rip_interface_delete_hook);
   
index 0db5634840cf7bbdf8c6a6ebe2c510bc015f61d7..a5ea36a1f1b70c5112f17425b13d2a7387a31f55 100644 (file)
@@ -33,6 +33,7 @@
 #include "privs.h"
 #include "sigevent.h"
 #include "zclient.h"
+#include "vrf.h"
 
 #include "ripd/ripd.h"
 
@@ -280,6 +281,7 @@ main (int argc, char **argv)
   vty_init (master);
   memory_init ();
   keychain_init ();
+  vrf_init ();
 
   /* RIP related initialization. */
   rip_init ();
index 9517c924c65a605cea0739297d45a11a575e2e56..3f9f025975c9c500ecc57e0d8c76f770d68f4edd 100644 (file)
@@ -35,6 +35,7 @@
 #include "table.h"
 #include "thread.h"
 #include "privs.h"
+#include "vrf.h"
 
 #include "ripngd/ripngd.h"
 #include "ripngd/ripng_debug.h"
@@ -1200,7 +1201,6 @@ void
 ripng_if_init ()
 {
   /* Interface initialize. */
-  iflist = list_new ();
   if_add_hook (IF_NEW_HOOK, ripng_if_new_hook);
   if_add_hook (IF_DELETE_HOOK, ripng_if_delete_hook);
 
index 01590d96d1b3958e23c8326c32db6962702c64ba..c05da0c9ef84c4dbb8d2a07cb084a9d97795f0d9 100644 (file)
@@ -34,6 +34,7 @@
 #include "if.h"
 #include "privs.h"
 #include "sigevent.h"
+#include "vrf.h"
 
 #include "ripngd/ripngd.h"
 
@@ -276,6 +277,7 @@ main (int argc, char **argv)
   cmd_init (1);
   vty_init (master);
   memory_init ();
+  vrf_init ();
 
   /* RIPngd inits. */
   ripng_init ();
index 248f77d8f5dd7490a33f2856e9942878a407431a..d7dbb241d19901bca4a610bdb8d2e29556467a96 100644 (file)
@@ -1766,7 +1766,6 @@ void
 zebra_if_init (void)
 {
   /* Initialize interface and new hook. */
-  if_init ();
   if_add_hook (IF_NEW_HOOK, if_zebra_new_hook);
   if_add_hook (IF_DELETE_HOOK, if_zebra_delete_hook);
   
index f4a8ca2bad2bd540b15366e2fb158c96d14f70c7..0013506b9bf4997ab4f29a7ed1dcca825f6d15b2 100644 (file)
@@ -316,7 +316,6 @@ main (int argc, char **argv)
   cmd_init (1);
   vty_init (zebrad.master);
   memory_init ();
-  if_init();
   zebra_debug_init ();
   zebra_if_init ();
   test_cmd_init ();