diff options
| author | Feng Lu <lu.feng@6wind.com> | 2015-05-22 11:40:09 +0200 |
|---|---|---|
| committer | Vipin Kumar <vipin@cumulusnetworks.com> | 2015-10-30 00:32:56 -0700 |
| commit | a31c5886dda74cab102671d3712fa2070e50d8ed (patch) | |
| tree | ddd57b9ba8dc7337620c7d0c1c3f0da7fdb960f4 /zebra/test_main.c | |
| parent | e5bf3e1ed718d5982d5b56209229b669dcd016c9 (diff) | |
zebra: add hooks upon enabling / disabling a VRF
zebra_vrf_enable() is the callback for VRF_ENABLE_HOOK.
It presently needs do nothing.
zebra_vrf_disable() is the callback for VRF_DISABLE_HOOK.
It presently withdraws routes, shuts down interfaces, and
clears the router-id candidates in that VRF.
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>
Diffstat (limited to 'zebra/test_main.c')
| -rw-r--r-- | zebra/test_main.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/zebra/test_main.c b/zebra/test_main.c index 0013506b9b..9b83b642d4 100644 --- a/zebra/test_main.c +++ b/zebra/test_main.c @@ -217,11 +217,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 (); } |
