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 /eigrpd | |
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 'eigrpd')
-rw-r--r-- | eigrpd/eigrp_filter.c | 4 | ||||
-rw-r--r-- | eigrpd/eigrp_network.c | 4 | ||||
-rw-r--r-- | eigrpd/eigrp_vty.c | 4 | ||||
-rw-r--r-- | eigrpd/eigrpd.c | 4 |
4 files changed, 8 insertions, 8 deletions
diff --git a/eigrpd/eigrp_filter.c b/eigrpd/eigrp_filter.c index b74127aa4..fd2e71466 100644 --- a/eigrpd/eigrp_filter.c +++ b/eigrpd/eigrp_filter.c @@ -295,10 +295,10 @@ void eigrp_distribute_update_interface(struct interface *ifp) */ void eigrp_distribute_update_all(struct prefix_list *notused) { + struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); struct interface *ifp; - struct listnode *node, *nnode; - for (ALL_LIST_ELEMENTS(vrf_iflist(VRF_DEFAULT), node, nnode, ifp)) + RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) eigrp_distribute_update_interface(ifp); } diff --git a/eigrpd/eigrp_network.c b/eigrpd/eigrp_network.c index 50e6b7b3b..56b63597e 100644 --- a/eigrpd/eigrp_network.c +++ b/eigrpd/eigrp_network.c @@ -231,9 +231,9 @@ int eigrp_if_drop_allspfrouters(struct eigrp *top, struct prefix *p, int eigrp_network_set(struct eigrp *eigrp, struct prefix *p) { + struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); struct route_node *rn; struct interface *ifp; - struct listnode *node; rn = route_node_get(eigrp->networks, (struct prefix *)p); if (rn->info) { @@ -251,7 +251,7 @@ int eigrp_network_set(struct eigrp *eigrp, struct prefix *p) eigrp_router_id_update(eigrp); /* Run network config now. */ /* Get target interface. */ - for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) { + RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) { zlog_debug("Setting up %s", ifp->name); eigrp_network_run_interface(eigrp, p, ifp); } diff --git a/eigrpd/eigrp_vty.c b/eigrpd/eigrp_vty.c index 59ec57168..5ca3a3bef 100644 --- a/eigrpd/eigrp_vty.c +++ b/eigrpd/eigrp_vty.c @@ -132,11 +132,11 @@ static int config_write_interfaces(struct vty *vty, struct eigrp *eigrp) static int eigrp_write_interface(struct vty *vty) { - struct listnode *node; + struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); struct interface *ifp; struct eigrp_interface *ei; - for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) { + RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) { ei = ifp->info; if (!ei) continue; diff --git a/eigrpd/eigrpd.c b/eigrpd/eigrpd.c index c70e198bd..1f2c59271 100644 --- a/eigrpd/eigrpd.c +++ b/eigrpd/eigrpd.c @@ -94,8 +94,8 @@ extern struct in_addr router_id_zebra; */ void eigrp_router_id_update(struct eigrp *eigrp) { + struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT); struct interface *ifp; - struct listnode *node; u_int32_t router_id, router_id_old; router_id_old = eigrp->router_id; @@ -116,7 +116,7 @@ void eigrp_router_id_update(struct eigrp *eigrp) // inet_ntoa(eigrp->router_id)); /* update eigrp_interface's */ - for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) + RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) eigrp_if_update(ifp); } } |