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 /ospfd/ospfd.c | |
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 'ospfd/ospfd.c')
-rw-r--r-- | ospfd/ospfd.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/ospfd/ospfd.c b/ospfd/ospfd.c index 24d3abf2a..e6d58d7a3 100644 --- a/ospfd/ospfd.c +++ b/ospfd/ospfd.c @@ -86,6 +86,7 @@ static void ospf_finish_final(struct ospf *); void ospf_router_id_update(struct ospf *ospf) { + struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id); struct in_addr router_id, router_id_old; struct ospf_interface *oi; struct interface *ifp; @@ -209,7 +210,7 @@ void ospf_router_id_update(struct ospf *ospf) ospf_router_lsa_update(ospf); /* update ospf_interface's */ - for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf->vrf_id), node, ifp)) + RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) ospf_if_update(ospf, ifp); } } @@ -581,6 +582,7 @@ void ospf_finish(struct ospf *ospf) /* Final cleanup of ospf instance */ static void ospf_finish_final(struct ospf *ospf) { + struct vrf *vrf = vrf_lookup_by_id(ospf->vrf_id); struct route_node *rn; struct ospf_nbr_nbma *nbr_nbma; struct ospf_lsa *lsa; @@ -591,7 +593,6 @@ static void ospf_finish_final(struct ospf *ospf) struct listnode *node, *nnode; int i; u_short instance = 0; - struct vrf *vrf = NULL; QOBJ_UNREG(ospf); @@ -623,7 +624,7 @@ static void ospf_finish_final(struct ospf *ospf) list_delete_and_null(&ospf->vlinks); /* Remove any ospf interface config params */ - for (ALL_LIST_ELEMENTS_RO(vrf_iflist(ospf->vrf_id), node, ifp)) { + RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) { struct ospf_if_params *params; params = IF_DEF_PARAMS(ifp); @@ -1252,15 +1253,15 @@ static void ospf_network_run_interface(struct ospf *ospf, struct interface *ifp, static void ospf_network_run(struct prefix *p, struct ospf_area *area) { + struct vrf *vrf = vrf_lookup_by_id(area->ospf->vrf_id); struct interface *ifp; - struct listnode *node; /* Schedule Router ID Update. */ if (area->ospf->router_id.s_addr == 0) ospf_router_id_update(area->ospf); /* Get target interface. */ - for (ALL_LIST_ELEMENTS_RO(vrf_iflist(area->ospf->vrf_id), node, ifp)) + RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) ospf_network_run_interface(area->ospf, ifp, p, area); } |