*: call if_init()/if_terminate() from vrf_init()/vrf_terminate()

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>
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index 5026b5e..ad4de79 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -36,6 +36,7 @@
 #include "filter.h"
 #include "plist.h"
 #include "stream.h"
+#include "vrf.h"
 
 #include "bgpd/bgpd.h"
 #include "bgpd/bgp_attr.h"
@@ -248,17 +249,14 @@
   /* 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 ();
@@ -293,6 +291,7 @@
   /* reverse community_list_init */
   community_list_terminate (bgp_clist);
 
+  vrf_terminate ();
   cmd_terminate ();
   vty_terminate ();
   if (zclient)
@@ -427,6 +426,7 @@
   cmd_init (1);
   vty_init (master);
   memory_init ();
+  vrf_init ();
 
   /* BGP related initialization.  */
   bgp_init ();