summaryrefslogtreecommitdiff
path: root/ldpd/ldpe.c
diff options
context:
space:
mode:
authorRafael Zalamena <rzalamena@gmail.com>2017-06-16 10:44:31 -0300
committerRafael Zalamena <rzalamena@gmail.com>2017-06-16 10:44:31 -0300
commit45926e58749924a6ff207cf211de3e6457578ecc (patch)
tree36fc6b1e0f38826a3cc809e77e39d54c0588832a /ldpd/ldpe.c
parentf43cd318b26a3dc57a0e6f40bcccdd5ce1886432 (diff)
lib: improve the RB implementation
Switch the RB tree implementation completely to the new dlg@'s version that uses pre-declared functions instead of macros for tree functions. Original e-mail/diff: https://marc.info/?l=openbsd-tech&m=147087487111068&w=2 Pros: * Reduces the amount of code that the usage of those macros generate * Allows the compiler to do a better compile-time check job * Might have better i-cache utilization since the tree code is shared Con: * dlg@ benchmarks shows it has 'very slightly slower' insertions * imported RB_* code must adapt the following calls: RB_INIT(), RB_GENERATE(), RB_ROOT(), RB_EMPTY(), make compare functions use 'const' (if not already) and maybe others.
Diffstat (limited to 'ldpd/ldpe.c')
-rw-r--r--ldpd/ldpe.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c
index 451d637bcf..ba153dfde2 100644
--- a/ldpd/ldpe.c
+++ b/ldpd/ldpe.c
@@ -152,7 +152,7 @@ ldpe_init(struct ldpd_init *init)
control_listen();
LIST_INIT(&global.addr_list);
- RB_INIT(&global.adj_tree);
+ RB_INIT(global_adj_head, &global.adj_tree);
TAILQ_INIT(&global.pending_conns);
if (inet_pton(AF_INET, AllRouters_v4, &global.mcast_addr_v4) != 1)
fatal("inet_pton");
@@ -216,7 +216,7 @@ ldpe_shutdown(void)
LIST_REMOVE(if_addr, entry);
free(if_addr);
}
- while ((adj = RB_ROOT(&global.adj_tree)) != NULL)
+ while ((adj = RB_ROOT(global_adj_head, &global.adj_tree)) != NULL)
adj_del(adj, S_SHUTDOWN);
/* clean up */
@@ -456,10 +456,10 @@ ldpe_dispatch_main(struct thread *thread)
fatal(NULL);
memcpy(nconf, imsg.data, sizeof(struct ldpd_conf));
- RB_INIT(&nconf->iface_tree);
- RB_INIT(&nconf->tnbr_tree);
- RB_INIT(&nconf->nbrp_tree);
- RB_INIT(&nconf->l2vpn_tree);
+ RB_INIT(iface_head, &nconf->iface_tree);
+ RB_INIT(tnbr_head, &nconf->tnbr_tree);
+ RB_INIT(nbrp_head, &nconf->nbrp_tree);
+ RB_INIT(l2vpn_head, &nconf->l2vpn_tree);
break;
case IMSG_RECONF_IFACE:
if ((niface = malloc(sizeof(struct iface))) == NULL)
@@ -487,9 +487,9 @@ ldpe_dispatch_main(struct thread *thread)
fatal(NULL);
memcpy(nl2vpn, imsg.data, sizeof(struct l2vpn));
- RB_INIT(&nl2vpn->if_tree);
- RB_INIT(&nl2vpn->pw_tree);
- RB_INIT(&nl2vpn->pw_inactive_tree);
+ RB_INIT(l2vpn_if_head, &nl2vpn->if_tree);
+ RB_INIT(l2vpn_pw_head, &nl2vpn->pw_tree);
+ RB_INIT(l2vpn_pw_head, &nl2vpn->pw_inactive_tree);
RB_INSERT(l2vpn_head, &nconf->l2vpn_tree, nl2vpn);
break;
@@ -876,8 +876,8 @@ ldpe_adj_detail_ctl(struct ctl_conn *c)
continue;
strlcpy(ictl.name, iface->name, sizeof(ictl.name));
- if (RB_EMPTY(&iface->ipv4.adj_tree) &&
- RB_EMPTY(&iface->ipv6.adj_tree))
+ if (RB_EMPTY(ia_adj_head, &iface->ipv4.adj_tree) &&
+ RB_EMPTY(ia_adj_head, &iface->ipv6.adj_tree))
ictl.no_adj = 1;
imsg_compose_event(&c->iev, IMSG_CTL_SHOW_DISC_IFACE, 0, 0,
-1, &ictl, sizeof(ictl));