diff options
| author | Stephen Worley <sworley@cumulusnetworks.com> | 2020-01-13 14:28:29 -0500 |
|---|---|---|
| committer | Stephen Worley <sworley@cumulusnetworks.com> | 2020-01-15 13:35:29 -0500 |
| commit | 89ca64c90acfc144d2f1802844abd7571a1e162c (patch) | |
| tree | 22258827a222dad91af884407803a76149302e02 /lib/nexthop_group.c | |
| parent | 1d049aba721bb05ecf2f8b5978d96863330093b6 (diff) | |
lib: assert if someone adds to nexthop list to nhg
If someone tries to add a nexthop with a list of nexthops
already attached to it, let's just assert. This standardizes
the API to say we assume this is an individual nexthop
you are appending to a group.
Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
Diffstat (limited to 'lib/nexthop_group.c')
| -rw-r--r-- | lib/nexthop_group.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c index 0051cba625..d7aceb55b9 100644 --- a/lib/nexthop_group.c +++ b/lib/nexthop_group.c @@ -250,8 +250,7 @@ static void _nexthop_add_sorted(struct nexthop **head, { struct nexthop *position, *prev; - /* Ensure this gets set */ - nexthop->next = NULL; + assert(!nexthop->next); for (position = *head, prev = NULL; position; prev = position, position = position->next) { @@ -281,6 +280,8 @@ void nexthop_group_add_sorted(struct nexthop_group *nhg, { struct nexthop *tail; + assert(!nexthop->next); + /* Try to just append to the end first; * trust the list is already sorted */ |
