diff options
Diffstat (limited to 'nest')
-rw-r--r-- | nest/route.h | 1 | ||||
-rw-r--r-- | nest/rt-attr.c | 20 |
2 files changed, 20 insertions, 1 deletions
diff --git a/nest/route.h b/nest/route.h index 9959ea69..8d799454 100644 --- a/nest/route.h +++ b/nest/route.h @@ -631,6 +631,7 @@ int nexthop__same(struct nexthop *x, struct nexthop *y); /* Compare multipath ne static inline int nexthop_same(struct nexthop *x, struct nexthop *y) { return (x == y) || nexthop__same(x, y); } struct nexthop *nexthop_merge(struct nexthop *x, struct nexthop *y, int rx, int ry, int max, linpool *lp); +struct nexthop *nexthop_sort(struct nexthop *x); static inline void nexthop_link(struct rta *a, struct nexthop *from) { memcpy(&a->nh, from, nexthop_size(from)); } void nexthop_insert(struct nexthop **n, struct nexthop *y); diff --git a/nest/rt-attr.c b/nest/rt-attr.c index 9c38e3ca..8620d321 100644 --- a/nest/rt-attr.c +++ b/nest/rt-attr.c @@ -202,7 +202,7 @@ nexthop__same(struct nexthop *x, struct nexthop *y) } static int -nexthop_compare_node(struct nexthop *x, struct nexthop *y) +nexthop_compare_node(const struct nexthop *x, const struct nexthop *y) { int r; @@ -320,6 +320,24 @@ nexthop_insert(struct nexthop **n, struct nexthop *x) *n = x; } +struct nexthop * +nexthop_sort(struct nexthop *x) +{ + struct nexthop *s = NULL; + + /* Simple insert-sort */ + while (x) + { + struct nexthop *n = x; + x = n->next; + n->next = NULL; + + nexthop_insert(&s, n); + } + + return s; +} + int nexthop_is_sorted(struct nexthop *x) { |