forked from Mirror/frr
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>
This commit is contained in:
parent
1d049aba72
commit
89ca64c90a
|
@ -250,8 +250,7 @@ static void _nexthop_add_sorted(struct nexthop **head,
|
||||||
{
|
{
|
||||||
struct nexthop *position, *prev;
|
struct nexthop *position, *prev;
|
||||||
|
|
||||||
/* Ensure this gets set */
|
assert(!nexthop->next);
|
||||||
nexthop->next = NULL;
|
|
||||||
|
|
||||||
for (position = *head, prev = NULL; position;
|
for (position = *head, prev = NULL; position;
|
||||||
prev = position, position = position->next) {
|
prev = position, position = position->next) {
|
||||||
|
@ -281,6 +280,8 @@ void nexthop_group_add_sorted(struct nexthop_group *nhg,
|
||||||
{
|
{
|
||||||
struct nexthop *tail;
|
struct nexthop *tail;
|
||||||
|
|
||||||
|
assert(!nexthop->next);
|
||||||
|
|
||||||
/* Try to just append to the end first;
|
/* Try to just append to the end first;
|
||||||
* trust the list is already sorted
|
* trust the list is already sorted
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue