diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c index 92e436478948..55ee74085e3f 100644 --- a/lib/nexthop_group.c +++ b/lib/nexthop_group.c @@ -261,17 +261,15 @@ DEFPY(ecmp_nexthops, nhop.type = NEXTHOP_TYPE_IPV6; } - if (no) { - nh = nexthop_exists(&nhgc->nhg, &nhop); - if (nh) { - nexthop_del(&nhgc->nhg, nh); - nexthop_free(nh); - - if (nhg_hooks.del_nexthop) - nhg_hooks.del_nexthop(nhgc->name); - } - } - else { + nh = nexthop_exists(&nhgc->nhg, &nhop); + + if (no && nh) { + nexthop_del(&nhgc->nhg, nh); + nexthop_free(nh); + + if (nhg_hooks.del_nexthop) + nhg_hooks.del_nexthop(nhgc->name); + } else if (!nh) { /* must be adding new nexthop since !no and !nexthop_exists */ nh = nexthop_new();