diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2017-10-03 03:06:01 +0200 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2017-10-10 14:05:02 +0200 |
commit | f4e14fdba7de19ca660278a0b8c750140db5868b (patch) | |
tree | 58eb2d22e84b24672ddff1dd786f18e5bc555b15 /isisd | |
parent | lib: register 'if_var_handlers' only once (diff) | |
download | frr-f4e14fdba7de19ca660278a0b8c750140db5868b.tar.xz frr-f4e14fdba7de19ca660278a0b8c750140db5868b.zip |
*: use rb-trees to store interfaces instead of sorted linked-lists
This is an important optimization for users running FRR on systems with
a large number of interfaces (e.g. thousands of tunnels). Red-black
trees scale much better than sorted linked-lists and also store the
elements in an ordered way (contrary to hash tables).
This is a big patch but the interesting bits are all in lib/if.[ch].
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'isisd')
-rw-r--r-- | isisd/isis_circuit.c | 7 | ||||
-rw-r--r-- | isisd/isis_te.c | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index 4179de1c0..761e73aa8 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -932,14 +932,15 @@ void isis_circuit_print_vty(struct isis_circuit *circuit, struct vty *vty, int isis_interface_config_write(struct vty *vty) { + struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); int write = 0; - struct listnode *node, *node2; + struct listnode *node; struct interface *ifp; struct isis_area *area; struct isis_circuit *circuit; int i; - for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) { + RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) { if (ifp->ifindex == IFINDEX_DELETED) continue; @@ -952,7 +953,7 @@ int isis_interface_config_write(struct vty *vty) write++; } /* ISIS Circuit */ - for (ALL_LIST_ELEMENTS_RO(isis->area_list, node2, area)) { + for (ALL_LIST_ELEMENTS_RO(isis->area_list, node, area)) { circuit = circuit_lookup_by_ifp(ifp, area->circuit_list); if (circuit == NULL) diff --git a/isisd/isis_te.c b/isisd/isis_te.c index 5a4fe82c9..dda5781c2 100644 --- a/isisd/isis_te.c +++ b/isisd/isis_te.c @@ -1245,13 +1245,13 @@ DEFUN (show_isis_mpls_te_interface, "Interface information\n" "Interface name\n") { + struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); int idx_interface = 4; struct interface *ifp; - struct listnode *node; /* Show All Interfaces. */ if (argc == 4) { - for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) + RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) show_mpls_te_sub(vty, ifp); } /* Interface name is specified. */ |