diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2016-10-30 00:30:57 +0200 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2016-11-28 19:18:35 +0100 |
commit | 806f87607e6b41f67cd1550bc8a9b579522fb15c (patch) | |
tree | 04145132076e24f72a6ebec63599920349414161 /lib/vrf.h | |
parent | *: rename two vrf functions (diff) | |
download | frr-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 'lib/vrf.h')
-rw-r--r-- | lib/vrf.h | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -70,7 +70,7 @@ enum { struct vrf { - RB_ENTRY(vrf) id_entry; + RB_ENTRY(vrf) id_entry, name_entry; /* Identifier, same as the vector index */ vrf_id_t vrf_id; @@ -92,11 +92,13 @@ struct vrf }; RB_HEAD (vrf_id_head, vrf); RB_PROTOTYPE (vrf_id_head, vrf, id_entry, vrf_id_compare) +RB_HEAD (vrf_name_head, vrf); +RB_PROTOTYPE (vrf_name_head, vrf, name_entry, vrf_name_compare) DECLARE_QOBJ_TYPE(vrf) extern struct vrf_id_head vrfs_by_id; -extern struct list *vrf_list; +extern struct vrf_name_head vrfs_by_name; /* * Add a specific hook to VRF module. |