From 84cac51a51fc29349077e8cecadf1aed11f9b824 Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Tue, 30 Aug 2016 17:17:27 +0200 Subject: Nest: Keep multipath next hops sorted --- nest/rt-attr.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'nest/rt-attr.c') diff --git a/nest/rt-attr.c b/nest/rt-attr.c index 42b74f34..ab0069b5 100644 --- a/nest/rt-attr.c +++ b/nest/rt-attr.c @@ -302,6 +302,34 @@ mpnh_merge(struct mpnh *x, struct mpnh *y, int rx, int ry, int max, linpool *lp) return root; } +void +mpnh_insert(struct mpnh **n, struct mpnh *x) +{ + for (; *n; n = &((*n)->next)) + { + int cmp = mpnh_compare_node(*n, x); + + if (cmp < 0) + continue; + else if (cmp > 0) + break; + else + return; + } + + x->next = *n; + *n = x; +} + +int +mpnh_is_sorted(struct mpnh *x) +{ + for (; x && x->next; x = x->next) + if (mpnh_compare_node(x, x->next) >= 0) + return 0; + + return 1; +} static struct mpnh * mpnh_copy(struct mpnh *o) -- cgit v1.2.3