diff options
| author | Renato Westphal <renato@opensourcerouting.org> | 2016-12-03 21:14:44 -0200 | 
|---|---|---|
| committer | Renato Westphal <renato@opensourcerouting.org> | 2017-01-03 22:07:13 -0200 | 
| commit | d3e1887ad6b5ae2199710b3278c277838e6ef913 (patch) | |
| tree | 36470ff324cefc0af07208863ec81f5e805f48c6 /ldpd/l2vpn.c | |
| parent | 607c1cbfd290e4e19c983c43dae22bd9a0ab827f (diff) | |
ldpd: use red-black trees to store 'lde_map' 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.c | 4 | 
1 files changed, 2 insertions, 2 deletions
diff --git a/ldpd/l2vpn.c b/ldpd/l2vpn.c index 851ff77b73..c0f6586854 100644 --- a/ldpd/l2vpn.c +++ b/ldpd/l2vpn.c @@ -459,7 +459,7 @@ l2vpn_binding_ctl(pid_t pid)  		fn = (struct fec_node *)f;  		if (fn->local_label == NO_LABEL && -		    LIST_EMPTY(&fn->downstream)) +		    RB_EMPTY(&fn->downstream))  			continue;  		memset(&pwctl, 0, sizeof(pwctl)); @@ -477,7 +477,7 @@ l2vpn_binding_ctl(pid_t pid)  		} else  			pwctl.local_label = NO_LABEL; -		LIST_FOREACH(me, &fn->downstream, entry) +		RB_FOREACH(me, lde_map_head, &fn->downstream)  			if (f->u.pwid.lsr_id.s_addr == me->nexthop->id.s_addr)  				break;  | 
