summaryrefslogtreecommitdiff
path: root/ldpd/l2vpn.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2016-12-13 16:19:15 -0200
committerRenato Westphal <renato@opensourcerouting.org>2017-01-03 22:07:13 -0200
commit7989cdba45f631fb14d1bcaf7103c9db25605971 (patch)
treea2cb210a1b0904d3ca01e5d5722e6acfff0f3b91 /ldpd/l2vpn.c
parent7d3d7491a0bc4b04ee6f65e26ae5f115df5a34f1 (diff)
ldpd: use red-black trees to store 'tnbr' elements
Using red-black trees instead of linked lists brings the following benefits: 1 - Elements are naturally ordered (no need to reorder anything before outputting data to the user); 2 - Faster lookups/deletes: O(log n) time complexity against O(n). The insert operation with red-black trees is more expensive though, but that's not a big issue since lookups are much more frequent. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'ldpd/l2vpn.c')
-rw-r--r--ldpd/l2vpn.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ldpd/l2vpn.c b/ldpd/l2vpn.c
index c0f6586854..dc9879ef23 100644
--- a/ldpd/l2vpn.c
+++ b/ldpd/l2vpn.c
@@ -530,7 +530,7 @@ ldpe_l2vpn_pw_init(struct l2vpn_pw *pw)
if (tnbr == NULL) {
tnbr = tnbr_new(pw->af, &pw->addr);
tnbr_update(tnbr);
- LIST_INSERT_HEAD(&leconf->tnbr_list, tnbr, entry);
+ RB_INSERT(tnbr_head, &leconf->tnbr_tree, tnbr);
}
tnbr->pw_count++;
@@ -544,6 +544,6 @@ ldpe_l2vpn_pw_exit(struct l2vpn_pw *pw)
tnbr = tnbr_find(leconf, pw->af, &pw->addr);
if (tnbr) {
tnbr->pw_count--;
- tnbr_check(tnbr);
+ tnbr_check(leconf, tnbr);
}
}