1
0
mirror of https://gitlab.labs.nic.cz/labs/bird.git synced 2024-05-11 16:54:54 +00:00

Nest: Keep multipath next hops sorted

This commit is contained in:
Ondrej Zajicek (work)
2016-08-30 17:17:27 +02:00
parent a1839f3c61
commit 84cac51a51
5 changed files with 39 additions and 8 deletions

View File

@@ -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)