summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Worley <sworley@cumulusnetworks.com>2019-10-04 14:04:43 -0400
committerStephen Worley <sworley@cumulusnetworks.com>2019-10-25 11:13:43 -0400
commitd3a35138115f89c19d0c44776da705b52975909f (patch)
treefaa42b7560abce2b2cf7f230214e7818dd1b0c70
parentcd36b87d8c067626dce566143e7998d0a0a9b722 (diff)
lib,pbrd,zebra: Use one api to delete nexthops/group
Reduce the api for deleting nexthops and the containing group to just one call rather than having a special case and handling it separately. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
-rw-r--r--lib/nexthop_group.c8
-rw-r--r--lib/nexthop_group.h1
-rw-r--r--pbrd/pbr_nht.c2
-rw-r--r--zebra/zapi_msg.c2
-rw-r--r--zebra/zebra_nhg.c6
-rw-r--r--zebra/zebra_rib.c6
-rw-r--r--zebra/zebra_rnh.c1
7 files changed, 8 insertions, 18 deletions
diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c
index 7d8bcd1166..9552f89568 100644
--- a/lib/nexthop_group.c
+++ b/lib/nexthop_group.c
@@ -213,14 +213,10 @@ void nexthop_group_copy(struct nexthop_group *to, struct nexthop_group *from)
void nexthop_group_delete(struct nexthop_group **nhg)
{
- XFREE(MTYPE_NEXTHOP_GROUP, *nhg);
-}
-
-void nexthop_group_free_delete(struct nexthop_group **nhg)
-{
if ((*nhg)->nexthop)
nexthops_free((*nhg)->nexthop);
- nexthop_group_delete(nhg);
+
+ XFREE(MTYPE_NEXTHOP_GROUP, *nhg);
}
/* Add nexthop to the end of a nexthop list. */
diff --git a/lib/nexthop_group.h b/lib/nexthop_group.h
index 378b0ce6bb..391775c69c 100644
--- a/lib/nexthop_group.h
+++ b/lib/nexthop_group.h
@@ -41,7 +41,6 @@ struct nexthop_group {
struct nexthop_group *nexthop_group_new(void);
void nexthop_group_delete(struct nexthop_group **nhg);
-void nexthop_group_free_delete(struct nexthop_group **nhg);
void nexthop_group_copy(struct nexthop_group *to,
struct nexthop_group *from);
diff --git a/pbrd/pbr_nht.c b/pbrd/pbr_nht.c
index 062cfd0158..7ccd14d1f1 100644
--- a/pbrd/pbr_nht.c
+++ b/pbrd/pbr_nht.c
@@ -578,8 +578,6 @@ void pbr_nht_delete_individual_nexthop(struct pbr_map_sequence *pbrms)
hash_release(pbr_nhg_hash, pnhgc);
- _nexthop_del(pbrms->nhg, nh);
- nexthop_free(nh);
nexthop_group_delete(&pbrms->nhg);
XFREE(MTYPE_TMP, pbrms->internal_nhg_name);
}
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c
index ab4c246d16..d6ade783cf 100644
--- a/zebra/zapi_msg.c
+++ b/zebra/zapi_msg.c
@@ -1537,7 +1537,6 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
EC_ZEBRA_NEXTHOP_CREATION_FAILED,
"%s: Nexthops Specified: %d but we failed to properly create one",
__PRETTY_FUNCTION__, api.nexthop_num);
- nexthops_free(re->ng->nexthop);
nexthop_group_delete(&re->ng);
XFREE(MTYPE_RE, re);
return;
@@ -1580,7 +1579,6 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
flog_warn(EC_ZEBRA_RX_SRCDEST_WRONG_AFI,
"%s: Received SRC Prefix but afi is not v6",
__PRETTY_FUNCTION__);
- nexthops_free(re->ng->nexthop);
nexthop_group_delete(&re->ng);
XFREE(MTYPE_RE, re);
return;
diff --git a/zebra/zebra_nhg.c b/zebra/zebra_nhg.c
index c22ed67f80..f4fc06efc9 100644
--- a/zebra/zebra_nhg.c
+++ b/zebra/zebra_nhg.c
@@ -769,7 +769,7 @@ static int nhg_ctx_process_new(struct nhg_ctx *ctx)
if (zebra_nhg_process_grp(nhg, &nhg_depends,
nhg_ctx_get_grp(ctx), count)) {
depends_decrement_free(&nhg_depends);
- nexthop_group_free_delete(&nhg);
+ nexthop_group_delete(&nhg);
return -ENOENT;
}
@@ -778,7 +778,7 @@ static int nhg_ctx_process_new(struct nhg_ctx *ctx)
depends_decrement_free(&nhg_depends);
/* These got copied over in zebra_nhg_alloc() */
- nexthop_group_free_delete(&nhg);
+ nexthop_group_delete(&nhg);
} else
nhe = zebra_nhg_find_nexthop(id, nhg_ctx_get_nh(ctx), afi,
type);
@@ -1046,7 +1046,7 @@ zebra_nhg_rib_find(uint32_t id, struct nexthop_group *nhg, afi_t rt_afi)
void zebra_nhg_free_members(struct nhg_hash_entry *nhe)
{
- nexthop_group_free_delete(&nhe->nhg);
+ nexthop_group_delete(&nhe->nhg);
/* Decrement to remove connection ref */
nhg_connected_tree_decrement_ref(&nhe->nhg_depends);
nhg_connected_tree_free(&nhe->nhg_depends);
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index 337a2f09c5..e0bf1a58f2 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -2431,7 +2431,7 @@ void rib_unlink(struct route_node *rn, struct route_entry *re)
if (nhe)
zebra_nhg_decrement_ref(nhe);
} else if (re->ng)
- nexthop_group_free_delete(&re->ng);
+ nexthop_group_delete(&re->ng);
nexthops_free(re->fib_ng.nexthop);
@@ -2667,7 +2667,7 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
table = zebra_vrf_table_with_table_id(afi, safi, re->vrf_id, re->table);
if (!table) {
if (re->ng)
- nexthop_group_free_delete(&re->ng);
+ nexthop_group_delete(&re->ng);
XFREE(MTYPE_RE, re);
return 0;
}
@@ -2690,7 +2690,7 @@ int rib_add_multipath(afi_t afi, safi_t safi, struct prefix *p,
* The nexthops got copied over into an nhe,
* so free them now.
*/
- nexthop_group_free_delete(&re->ng);
+ nexthop_group_delete(&re->ng);
if (!nhe) {
char buf[PREFIX_STRLEN] = "";
diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c
index af3c1b818f..60e23cc4d4 100644
--- a/zebra/zebra_rnh.c
+++ b/zebra/zebra_rnh.c
@@ -940,7 +940,6 @@ static void free_state(vrf_id_t vrf_id, struct route_entry *re,
return;
/* free RE and nexthops */
- nexthops_free(re->ng->nexthop);
nexthop_group_delete(&re->ng);
XFREE(MTYPE_RE, re);
}