summaryrefslogtreecommitdiffstats
path: root/lib/nexthop_group.c
diff options
context:
space:
mode:
authorStephen Worley <sworley@cumulusnetworks.com>2020-01-13 20:28:29 +0100
committerStephen Worley <sworley@cumulusnetworks.com>2020-01-15 19:35:29 +0100
commit89ca64c90acfc144d2f1802844abd7571a1e162c (patch)
tree22258827a222dad91af884407803a76149302e02 /lib/nexthop_group.c
parentzebra: just set nexthop member in handle_recursive_depend() (diff)
downloadfrr-89ca64c90acfc144d2f1802844abd7571a1e162c.tar.xz
frr-89ca64c90acfc144d2f1802844abd7571a1e162c.zip
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.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c
index 0051cba62..d7aceb55b 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
*/