summaryrefslogtreecommitdiff
path: root/ldpd/interface.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/interface.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/interface.c')
-rw-r--r--ldpd/interface.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/ldpd/interface.c b/ldpd/interface.c
index a064a58b2e..527a6bc963 100644
--- a/ldpd/interface.c
+++ b/ldpd/interface.c
@@ -26,7 +26,7 @@
#include "sockopt.h"
-static __inline int iface_compare(struct iface *, struct iface *);
+static __inline int iface_compare(const struct iface *, const struct iface *);
static struct if_addr *if_addr_new(struct kaddr *);
static struct if_addr *if_addr_lookup(struct if_addr_head *, struct kaddr *);
static int if_start(struct iface *, int);
@@ -43,7 +43,7 @@ static int if_leave_ipv6_group(struct iface *, struct in6_addr *);
RB_GENERATE(iface_head, iface, entry, iface_compare)
static __inline int
-iface_compare(struct iface *a, struct iface *b)
+iface_compare(const struct iface *a, const struct iface *b)
{
return (strcmp(a->name, b->name));
}
@@ -81,12 +81,12 @@ ldpe_if_init(struct iface *iface)
/* ipv4 */
iface->ipv4.iface = iface;
iface->ipv4.state = IF_STA_DOWN;
- RB_INIT(&iface->ipv4.adj_tree);
+ RB_INIT(iface_head, &iface->ipv4.adj_tree);
/* ipv6 */
iface->ipv6.iface = iface;
iface->ipv6.state = IF_STA_DOWN;
- RB_INIT(&iface->ipv6.adj_tree);
+ RB_INIT(iface_head, &iface->ipv6.adj_tree);
}
void
@@ -305,7 +305,7 @@ if_reset(struct iface *iface, int af)
ia = iface_af_get(iface, af);
if_stop_hello_timer(ia);
- while ((adj = RB_ROOT(&ia->adj_tree)) != NULL)
+ while ((adj = RB_ROOT(iface_head, &ia->adj_tree)) != NULL)
adj_del(adj, S_SHUTDOWN);
/* try to cleanup */