From a7f139a6b17837f4ad4c2305b515ff1303eddc1a Mon Sep 17 00:00:00 2001 From: Don Slice Date: Wed, 21 Feb 2018 22:03:36 +0000 Subject: [PATCH] pbrd: fix problem removing nonexistent nexthop Signed-off-by: Don Slice --- lib/nexthop_group.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c index 55ee74085e3f..614e1dab759a 100644 --- a/lib/nexthop_group.c +++ b/lib/nexthop_group.c @@ -263,12 +263,14 @@ DEFPY(ecmp_nexthops, nh = nexthop_exists(&nhgc->nhg, &nhop); - if (no && nh) { - nexthop_del(&nhgc->nhg, nh); - nexthop_free(nh); + if (no) { + if (nh) { + nexthop_del(&nhgc->nhg, nh); + nexthop_free(nh); - if (nhg_hooks.del_nexthop) - nhg_hooks.del_nexthop(nhgc->name); + 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();