diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2016-10-29 02:26:04 +0200 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2016-11-28 19:18:35 +0100 |
commit | 51bdc5f85ceb5d597924fc5f9b550257972a38fd (patch) | |
tree | beb96514a56fb04befb18b89d81eb44d904b8ea4 | |
parent | lib: fix creation of pre-provisioned VRFs (diff) | |
download | frr-51bdc5f85ceb5d597924fc5f9b550257972a38fd.tar.xz frr-51bdc5f85ceb5d597924fc5f9b550257972a38fd.zip |
zebra: nuke zvrf_list and always use vrf_list instead
zvrf_list doesn't need to exist, it's basically a duplicate version
of vrf_list.
Also, zebra_vrf_delete() wasn't removing zvrf from zvrf_list, which was
a bug.
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
-rw-r--r-- | zebra/zebra_vrf.c | 24 | ||||
-rw-r--r-- | zebra/zebra_vrf.h | 2 | ||||
-rw-r--r-- | zebra/zebra_vty.c | 22 |
3 files changed, 27 insertions, 21 deletions
diff --git a/zebra/zebra_vrf.c b/zebra/zebra_vrf.c index a4e5eabbc..915849c05 100644 --- a/zebra/zebra_vrf.c +++ b/zebra/zebra_vrf.c @@ -36,7 +36,6 @@ #include "zebra/zebra_mpls.h" extern struct zebra_t zebrad; -struct list *zvrf_list; /* VRF information update. */ static void @@ -96,7 +95,6 @@ zebra_vrf_new (vrf_id_t vrf_id, const char *name, void **info) zvrf->zns = zebra_ns_lookup (NS_DEFAULT); /* Point to the global (single) NS */ *info = (void *)zvrf; router_id_init (zvrf); - listnode_add_sort (zvrf_list, zvrf); } else { @@ -346,21 +344,19 @@ zebra_vrf_lookup (vrf_id_t vrf_id) return vrf_info_lookup (vrf_id); } -/* Lookup the zvrf in the zvrf_list. */ +/* Lookup VRF by name. */ struct zebra_vrf * zebra_vrf_list_lookup_by_name (const char *name) { - struct listnode *node; - struct zebra_vrf *zvrf; + struct vrf *vrf; if (!name) name = VRF_DEFAULT_NAME; - for (ALL_LIST_ELEMENTS_RO (zvrf_list, node, zvrf)) - { - if (strcmp(name, zvrf->name) == 0) - return zvrf; - } + vrf = vrf_list_lookup_by_name (name); + if (vrf) + return ((struct zebra_vrf *) vrf->info); + return NULL; } @@ -452,11 +448,13 @@ static int vrf_config_write (struct vty *vty) { struct listnode *node; + struct vrf *vrf; struct zebra_vrf *zvrf; - for (ALL_LIST_ELEMENTS_RO (zvrf_list, node, zvrf)) + for (ALL_LIST_ELEMENTS_RO (vrf_list, node, vrf)) { - if (strcmp(zvrf->name, VRF_DEFAULT_NAME)) + zvrf = vrf->info; + if (! zvrf || strcmp (zvrf->name, VRF_DEFAULT_NAME)) { vty_out (vty, "vrf %s%s", zvrf->name, VTY_NEWLINE); vty_out (vty, "!%s", VTY_NEWLINE); @@ -481,8 +479,6 @@ zebra_vrf_init (void) vrf_add_hook (VRF_DISABLE_HOOK, zebra_vrf_disable); vrf_add_hook (VRF_DELETE_HOOK, zebra_vrf_delete); - zvrf_list = list_new (); - vrf_init (); install_node (&vrf_node, vrf_config_write); diff --git a/zebra/zebra_vrf.h b/zebra/zebra_vrf.h index 0baddc1b6..8dffe27dc 100644 --- a/zebra/zebra_vrf.h +++ b/zebra/zebra_vrf.h @@ -86,8 +86,6 @@ struct zebra_vrf #define MPLS_FLAG_SCHEDULE_LSPS (1 << 0) }; -extern struct list *zvrf_list; - struct route_table * zebra_vrf_table_with_table_id (afi_t afi, safi_t safi, vrf_id_t vrf_id, u_int32_t table_id); diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 9b0fad93e..74f64dd05 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -3673,13 +3673,18 @@ static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd) struct route_node *rn; struct static_route *si; struct route_table *stable; + struct vrf *vrf; struct zebra_vrf *zvrf; char buf[BUFSIZ]; int write =0; struct listnode *node; - for (ALL_LIST_ELEMENTS_RO (zvrf_list, node, zvrf)) + for (ALL_LIST_ELEMENTS_RO (vrf_list, node, vrf)) { + zvrf = vrf->info; + if (! zvrf) + continue; + if ((stable = zvrf->stable[AFI_IP][safi]) == NULL) continue; @@ -5782,11 +5787,16 @@ static_config_ipv6 (struct vty *vty) int write = 0; char buf[PREFIX_STRLEN]; struct route_table *stable; + struct vrf *vrf; struct zebra_vrf *zvrf; struct listnode *node; - for (ALL_LIST_ELEMENTS_RO (zvrf_list, node, zvrf)) + for (ALL_LIST_ELEMENTS_RO (vrf_list, node, vrf)) { + zvrf = vrf->info; + if (! zvrf) + continue; + if ((stable = zvrf->stable[AFI_IP6][SAFI_UNICAST]) == NULL) continue; @@ -5874,13 +5884,15 @@ DEFUN (show_vrf, SHOW_STR "VRF\n") { + struct vrf *vrf; struct zebra_vrf *zvrf; struct listnode *node; - for (ALL_LIST_ELEMENTS_RO (zvrf_list, node, zvrf)) + for (ALL_LIST_ELEMENTS_RO (vrf_list, node, vrf)) { - if (!zvrf->vrf_id) - continue; + zvrf = vrf->info; + if (! zvrf || ! zvrf->vrf_id) + continue; vty_out (vty, "vrf %s ", zvrf->name); if (zvrf->vrf_id == VRF_UNKNOWN) |