summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--zebra/main.c40
-rw-r--r--zebra/rib.h1
-rw-r--r--zebra/test_main.c37
-rw-r--r--zebra/zebra_rib.c2
4 files changed, 79 insertions, 1 deletions
diff --git a/zebra/main.c b/zebra/main.c
index c7e3b68c..1e9757b6 100644
--- a/zebra/main.c
+++ b/zebra/main.c
@@ -221,11 +221,51 @@ zebra_vrf_new (vrf_id_t vrf_id, void **info)
return 0;
}
+/* Callback upon enabling a VRF. */
+static int
+zebra_vrf_enable (vrf_id_t vrf_id, void **info)
+{
+ struct zebra_vrf *zvrf = (struct zebra_vrf *) (*info);
+
+ assert (zvrf);
+
+ return 0;
+}
+
+/* Callback upon disabling a VRF. */
+static int
+zebra_vrf_disable (vrf_id_t vrf_id, void **info)
+{
+ struct zebra_vrf *zvrf = (struct zebra_vrf *) (*info);
+ struct listnode *list_node;
+ struct interface *ifp;
+
+ assert (zvrf);
+
+ rib_close_table (zvrf->table[AFI_IP][SAFI_UNICAST]);
+ rib_close_table (zvrf->table[AFI_IP6][SAFI_UNICAST]);
+
+ for (ALL_LIST_ELEMENTS_RO (vrf_iflist (vrf_id), list_node, ifp))
+ {
+ int operative = if_is_operative (ifp);
+ UNSET_FLAG (ifp->flags, IFF_UP);
+ if (operative)
+ if_down (ifp);
+ }
+
+ list_delete_all_node (zvrf->rid_all_sorted_list);
+ list_delete_all_node (zvrf->rid_lo_sorted_list);
+
+ return 0;
+}
+
/* Zebra VRF initialization. */
static void
zebra_vrf_init (void)
{
vrf_add_hook (VRF_NEW_HOOK, zebra_vrf_new);
+ vrf_add_hook (VRF_ENABLE_HOOK, zebra_vrf_enable);
+ vrf_add_hook (VRF_DISABLE_HOOK, zebra_vrf_disable);
vrf_init ();
}
diff --git a/zebra/rib.h b/zebra/rib.h
index 06aa3535..5663f303 100644
--- a/zebra/rib.h
+++ b/zebra/rib.h
@@ -473,6 +473,7 @@ extern struct rib *rib_lookup_ipv4 (struct prefix_ipv4 *, vrf_id_t);
extern void rib_update (vrf_id_t);
extern void rib_weed_tables (void);
extern void rib_sweep_route (void);
+extern void rib_close_table (struct route_table *);
extern void rib_close (void);
extern void rib_init (void);
extern unsigned long rib_score_proto (u_char proto);
diff --git a/zebra/test_main.c b/zebra/test_main.c
index aad616f7..17014ea7 100644
--- a/zebra/test_main.c
+++ b/zebra/test_main.c
@@ -212,11 +212,48 @@ zebra_vrf_new (vrf_id_t vrf_id, void **info)
return 0;
}
+/* Callback upon enabling a VRF. */
+static int
+zebra_vrf_enable (vrf_id_t vrf_id, void **info)
+{
+ struct zebra_vrf *zvrf = (struct zebra_vrf *) (*info);
+
+ assert (zvrf);
+
+ return 0;
+}
+
+/* Callback upon disabling a VRF. */
+static int
+zebra_vrf_disable (vrf_id_t vrf_id, void **info)
+{
+ struct zebra_vrf *zvrf = (struct zebra_vrf *) (*info);
+ struct listnode *list_node;
+ struct interface *ifp;
+
+ assert (zvrf);
+
+ rib_close_table (zvrf->table[AFI_IP][SAFI_UNICAST]);
+ rib_close_table (zvrf->table[AFI_IP6][SAFI_UNICAST]);
+
+ for (ALL_LIST_ELEMENTS_RO (vrf_iflist (vrf_id), list_node, ifp))
+ {
+ int operative = if_is_operative (ifp);
+ UNSET_FLAG (ifp->flags, IFF_UP);
+ if (operative)
+ if_down (ifp);
+ }
+
+ return 0;
+}
+
/* Zebra VRF initialization. */
static void
zebra_vrf_init (void)
{
vrf_add_hook (VRF_NEW_HOOK, zebra_vrf_new);
+ vrf_add_hook (VRF_ENABLE_HOOK, zebra_vrf_enable);
+ vrf_add_hook (VRF_DISABLE_HOOK, zebra_vrf_disable);
vrf_init ();
}
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 68ae397b..9d966a0f 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -3270,7 +3270,7 @@ rib_score_proto (u_char proto)
}
/* Close RIB and clean up kernel routes. */
-static void
+void
rib_close_table (struct route_table *table)
{
struct route_node *rn;