]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib: assert if someone adds to nexthop list to nhg
authorStephen Worley <sworley@cumulusnetworks.com>
Mon, 13 Jan 2020 19:28:29 +0000 (14:28 -0500)
committerStephen Worley <sworley@cumulusnetworks.com>
Wed, 15 Jan 2020 18:35:29 +0000 (13:35 -0500)
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>
lib/nexthop_group.c

index 0051cba62572f6bc9d6e45afb985b6339ae6ce94..d7aceb55b9781935fa6c7df2d78ccb78d86a5016 100644 (file)
@@ -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
         */