diff options
author | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2019-07-02 18:23:06 +0200 |
---|---|---|
committer | Ondrej Zajicek (work) <santiago@crfreenet.org> | 2019-07-02 18:23:06 +0200 |
commit | 59d3a3611f05c05040cec4bf09f31c26ade0fa0a (patch) | |
tree | aab1ddc488455681058e40e277a948462f00ae93 /nest/rt-attr.c | |
parent | 1187627a1dded6a3673c0d43033f431f15cd1b8f (diff) |
Netlink: Handle alien routes with unsorted nexthops
Nest requires that nexthops are sorted, the kernel protocol have to
ensure that for alien routes.
Diffstat (limited to 'nest/rt-attr.c')
-rw-r--r-- | nest/rt-attr.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/nest/rt-attr.c b/nest/rt-attr.c index cc362cab..1803db92 100644 --- a/nest/rt-attr.c +++ b/nest/rt-attr.c @@ -200,7 +200,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; @@ -318,6 +318,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) { |