summaryrefslogtreecommitdiff
path: root/ripd/rip_interface.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2017-10-02 22:06:01 -0300
committerRenato Westphal <renato@opensourcerouting.org>2017-10-10 09:05:02 -0300
commitf4e14fdba7de19ca660278a0b8c750140db5868b (patch)
tree58eb2d22e84b24672ddff1dd786f18e5bc555b15 /ripd/rip_interface.c
parent5d56066e4645ce1104f766cb2a2b767b483c9ce5 (diff)
*: 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 'ripd/rip_interface.c')
-rw-r--r--ripd/rip_interface.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index 1b2cbb61c3..fe72de229f 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -336,10 +336,10 @@ static int rip_if_ipv4_address_check(struct interface *ifp)
/* Does this address belongs to me ? */
int if_check_address(struct in_addr addr)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
struct listnode *cnode;
struct connected *connected;
@@ -490,10 +490,10 @@ static void rip_interface_clean(struct rip_interface *ri)
void rip_interfaces_clean(void)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
rip_interface_clean(ifp->info);
}
@@ -542,10 +542,10 @@ static void rip_interface_reset(struct rip_interface *ri)
void rip_interfaces_reset(void)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
rip_interface_reset(ifp->info);
}
@@ -583,10 +583,10 @@ int rip_if_down(struct interface *ifp)
/* Needed for stop RIP process. */
void rip_if_down_all()
{
+ 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)
rip_if_down(ifp);
}
@@ -977,11 +977,11 @@ void rip_enable_apply(struct interface *ifp)
/* Apply network configuration to all interface. */
void rip_enable_apply_all()
{
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- struct listnode *node, *nnode;
/* Check each interface. */
- for (ALL_LIST_ELEMENTS(vrf_iflist(VRF_DEFAULT), node, nnode, ifp))
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name)
rip_enable_apply(ifp);
}
@@ -1091,10 +1091,10 @@ void rip_passive_interface_apply(struct interface *ifp)
static void rip_passive_interface_apply_all(void)
{
+ 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)
rip_passive_interface_apply(ifp);
}
@@ -1728,10 +1728,10 @@ DEFUN (no_rip_passive_interface,
/* Write rip configuration of each interface. */
static int rip_interface_config_write(struct vty *vty)
{
- struct listnode *node;
+ struct vrf *vrf = vrf_lookup_by_id(VRF_DEFAULT);
struct interface *ifp;
- for (ALL_LIST_ELEMENTS_RO(vrf_iflist(VRF_DEFAULT), node, ifp)) {
+ RB_FOREACH (ifp, if_name_head, &vrf->ifaces_by_name) {
struct rip_interface *ri;
if (ifp->ifindex == IFINDEX_DELETED)