summaryrefslogtreecommitdiffstats
path: root/ospfd/ospf_te.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2017-10-03 03:06:01 +0200
committerRenato Westphal <renato@opensourcerouting.org>2017-10-10 14:05:02 +0200
commitf4e14fdba7de19ca660278a0b8c750140db5868b (patch)
tree58eb2d22e84b24672ddff1dd786f18e5bc555b15 /ospfd/ospf_te.c
parentlib: register 'if_var_handlers' only once (diff)
downloadfrr-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 'ospfd/ospf_te.c')
-rw-r--r--ospfd/ospf_te.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c
index 5f300daba..95610e4c7 100644
--- a/ospfd/ospf_te.c
+++ b/ospfd/ospf_te.c
@@ -2533,9 +2533,10 @@ DEFUN (show_ip_ospf_mpls_te_link,
"Interface information\n"
"Interface name\n")
{
+ struct vrf *vrf;
int idx_interface = 5;
struct interface *ifp;
- struct listnode *node, *nnode, *n1;
+ struct listnode *node;
char *vrf_name = NULL;
bool all_vrf;
int inst = 0;
@@ -2550,11 +2551,12 @@ DEFUN (show_ip_ospf_mpls_te_link,
/* vrf input is provided could be all or specific vrf*/
if (vrf_name) {
if (all_vrf) {
- for (ALL_LIST_ELEMENTS_RO(om->ospf, n1, ospf)) {
+ for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
if (!ospf->oi_running)
continue;
- for (ALL_LIST_ELEMENTS(vrf_iflist(ospf->vrf_id),
- node, nnode, ifp))
+ vrf = vrf_lookup_by_id(ospf->vrf_id);
+ RB_FOREACH (ifp, if_name_head,
+ &vrf->ifaces_by_name)
show_mpls_te_link_sub(vty, ifp);
}
return CMD_SUCCESS;
@@ -2562,18 +2564,18 @@ DEFUN (show_ip_ospf_mpls_te_link,
ospf = ospf_lookup_by_inst_name (inst, vrf_name);
if (ospf == NULL || !ospf->oi_running)
return CMD_SUCCESS;
- for (ALL_LIST_ELEMENTS(vrf_iflist(ospf->vrf_id), node,
- nnode, ifp))
+ vrf = vrf_lookup_by_id(ospf->vrf_id);
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
show_mpls_te_link_sub(vty, ifp);
return CMD_SUCCESS;
}
/* Show All Interfaces. */
if (argc == 5) {
- for (ALL_LIST_ELEMENTS_RO(om->ospf, n1, ospf)) {
+ for (ALL_LIST_ELEMENTS_RO(om->ospf, node, ospf)) {
if (!ospf->oi_running)
continue;
- for (ALL_LIST_ELEMENTS(vrf_iflist(ospf->vrf_id), node,
- nnode, ifp))
+ vrf = vrf_lookup_by_id(ospf->vrf_id);
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
show_mpls_te_link_sub(vty, ifp);
}
}