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 */ diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c index c0888e298b..2a4c708b8f 100644 --- a/zebra/zebra_nhg.c +++ b/zebra/zebra_nhg.c @@ -478,7 +478,7 @@ static void handle_recursive_depend(struct nhg_connected_tree_head *nhg_depends, struct nhg_hash_entry *depend = NULL; struct nexthop_group resolved_ng = {}; - nexthop_group_add_sorted(&resolved_ng, nh); + resolved_ng.nexthop = nh; depend = zebra_nhg_rib_find(0, &resolved_ng, afi); depends_add(nhg_depends, depend);