From ddc7b97f1cd2a6543272fd0ad5b9c1703c5ff45a Mon Sep 17 00:00:00 2001 From: Don Slice Date: Wed, 21 Feb 2018 21:47:39 +0000 Subject: [PATCH] pbrd: fix duplicate nexthop entries under nexthop-group Signed-off-by: Don Slice --- lib/nexthop_group.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) 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();