summaryrefslogtreecommitdiffstats
path: root/zebra/zebra_vty.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2016-10-30 00:30:57 +0200
committerRenato Westphal <renato@opensourcerouting.org>2016-11-28 19:18:35 +0100
commit806f87607e6b41f67cd1550bc8a9b579522fb15c (patch)
tree04145132076e24f72a6ebec63599920349414161 /zebra/zebra_vty.c
parent*: rename two vrf functions (diff)
downloadfrr-806f87607e6b41f67cd1550bc8a9b579522fb15c.tar.xz
frr-806f87607e6b41f67cd1550bc8a9b579522fb15c.zip
lib/zebra: convert vrf_list to a red-black tree
Since we're already using a red-black tree to store VRFs sorted by their vrf_id's, create a new tree to store VRFs sorted by their names. The biggest advantage of doing this is that we reduce the time complexity of vrf_list_lookup_by_name() from O(n) to O(log n). Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'zebra/zebra_vty.c')
-rw-r--r--zebra/zebra_vty.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 444d25135..3aa7ada91 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -3677,9 +3677,8 @@ static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd)
struct zebra_vrf *zvrf;
char buf[BUFSIZ];
int write =0;
- struct listnode *node;
- for (ALL_LIST_ELEMENTS_RO (vrf_list, node, vrf))
+ RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
{
zvrf = vrf->info;
if (! zvrf)
@@ -5789,9 +5788,8 @@ static_config_ipv6 (struct vty *vty)
struct route_table *stable;
struct vrf *vrf;
struct zebra_vrf *zvrf;
- struct listnode *node;
- for (ALL_LIST_ELEMENTS_RO (vrf_list, node, vrf))
+ RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
{
zvrf = vrf->info;
if (! zvrf)
@@ -5886,9 +5884,8 @@ DEFUN (show_vrf,
{
struct vrf *vrf;
struct zebra_vrf *zvrf;
- struct listnode *node;
- for (ALL_LIST_ELEMENTS_RO (vrf_list, node, vrf))
+ RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name)
{
zvrf = vrf->info;
if (! zvrf || ! zvrf->vrf_id)