mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-08 14:04:32 +00:00
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>
This commit is contained in:
parent
cd36b87d8c
commit
d3a3513811
@ -212,15 +212,11 @@ void nexthop_group_copy(struct nexthop_group *to, struct nexthop_group *from)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void nexthop_group_delete(struct nexthop_group **nhg)
|
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)
|
if ((*nhg)->nexthop)
|
||||||
nexthops_free((*nhg)->nexthop);
|
nexthops_free((*nhg)->nexthop);
|
||||||
nexthop_group_delete(nhg);
|
|
||||||
|
XFREE(MTYPE_NEXTHOP_GROUP, *nhg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add nexthop to the end of a nexthop list. */
|
/* Add nexthop to the end of a nexthop list. */
|
||||||
|
@ -41,7 +41,6 @@ struct nexthop_group {
|
|||||||
|
|
||||||
struct nexthop_group *nexthop_group_new(void);
|
struct nexthop_group *nexthop_group_new(void);
|
||||||
void nexthop_group_delete(struct nexthop_group **nhg);
|
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,
|
void nexthop_group_copy(struct nexthop_group *to,
|
||||||
struct nexthop_group *from);
|
struct nexthop_group *from);
|
||||||
|
@ -578,8 +578,6 @@ void pbr_nht_delete_individual_nexthop(struct pbr_map_sequence *pbrms)
|
|||||||
|
|
||||||
hash_release(pbr_nhg_hash, pnhgc);
|
hash_release(pbr_nhg_hash, pnhgc);
|
||||||
|
|
||||||
_nexthop_del(pbrms->nhg, nh);
|
|
||||||
nexthop_free(nh);
|
|
||||||
nexthop_group_delete(&pbrms->nhg);
|
nexthop_group_delete(&pbrms->nhg);
|
||||||
XFREE(MTYPE_TMP, pbrms->internal_nhg_name);
|
XFREE(MTYPE_TMP, pbrms->internal_nhg_name);
|
||||||
}
|
}
|
||||||
|
@ -1537,7 +1537,6 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
|
|||||||
EC_ZEBRA_NEXTHOP_CREATION_FAILED,
|
EC_ZEBRA_NEXTHOP_CREATION_FAILED,
|
||||||
"%s: Nexthops Specified: %d but we failed to properly create one",
|
"%s: Nexthops Specified: %d but we failed to properly create one",
|
||||||
__PRETTY_FUNCTION__, api.nexthop_num);
|
__PRETTY_FUNCTION__, api.nexthop_num);
|
||||||
nexthops_free(re->ng->nexthop);
|
|
||||||
nexthop_group_delete(&re->ng);
|
nexthop_group_delete(&re->ng);
|
||||||
XFREE(MTYPE_RE, re);
|
XFREE(MTYPE_RE, re);
|
||||||
return;
|
return;
|
||||||
@ -1580,7 +1579,6 @@ static void zread_route_add(ZAPI_HANDLER_ARGS)
|
|||||||
flog_warn(EC_ZEBRA_RX_SRCDEST_WRONG_AFI,
|
flog_warn(EC_ZEBRA_RX_SRCDEST_WRONG_AFI,
|
||||||
"%s: Received SRC Prefix but afi is not v6",
|
"%s: Received SRC Prefix but afi is not v6",
|
||||||
__PRETTY_FUNCTION__);
|
__PRETTY_FUNCTION__);
|
||||||
nexthops_free(re->ng->nexthop);
|
|
||||||
nexthop_group_delete(&re->ng);
|
nexthop_group_delete(&re->ng);
|
||||||
XFREE(MTYPE_RE, re);
|
XFREE(MTYPE_RE, re);
|
||||||
return;
|
return;
|
||||||
|
@ -769,7 +769,7 @@ static int nhg_ctx_process_new(struct nhg_ctx *ctx)
|
|||||||
if (zebra_nhg_process_grp(nhg, &nhg_depends,
|
if (zebra_nhg_process_grp(nhg, &nhg_depends,
|
||||||
nhg_ctx_get_grp(ctx), count)) {
|
nhg_ctx_get_grp(ctx), count)) {
|
||||||
depends_decrement_free(&nhg_depends);
|
depends_decrement_free(&nhg_depends);
|
||||||
nexthop_group_free_delete(&nhg);
|
nexthop_group_delete(&nhg);
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -778,7 +778,7 @@ static int nhg_ctx_process_new(struct nhg_ctx *ctx)
|
|||||||
depends_decrement_free(&nhg_depends);
|
depends_decrement_free(&nhg_depends);
|
||||||
|
|
||||||
/* These got copied over in zebra_nhg_alloc() */
|
/* These got copied over in zebra_nhg_alloc() */
|
||||||
nexthop_group_free_delete(&nhg);
|
nexthop_group_delete(&nhg);
|
||||||
} else
|
} else
|
||||||
nhe = zebra_nhg_find_nexthop(id, nhg_ctx_get_nh(ctx), afi,
|
nhe = zebra_nhg_find_nexthop(id, nhg_ctx_get_nh(ctx), afi,
|
||||||
type);
|
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)
|
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 */
|
/* Decrement to remove connection ref */
|
||||||
nhg_connected_tree_decrement_ref(&nhe->nhg_depends);
|
nhg_connected_tree_decrement_ref(&nhe->nhg_depends);
|
||||||
nhg_connected_tree_free(&nhe->nhg_depends);
|
nhg_connected_tree_free(&nhe->nhg_depends);
|
||||||
|
@ -2431,7 +2431,7 @@ void rib_unlink(struct route_node *rn, struct route_entry *re)
|
|||||||
if (nhe)
|
if (nhe)
|
||||||
zebra_nhg_decrement_ref(nhe);
|
zebra_nhg_decrement_ref(nhe);
|
||||||
} else if (re->ng)
|
} else if (re->ng)
|
||||||
nexthop_group_free_delete(&re->ng);
|
nexthop_group_delete(&re->ng);
|
||||||
|
|
||||||
nexthops_free(re->fib_ng.nexthop);
|
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);
|
table = zebra_vrf_table_with_table_id(afi, safi, re->vrf_id, re->table);
|
||||||
if (!table) {
|
if (!table) {
|
||||||
if (re->ng)
|
if (re->ng)
|
||||||
nexthop_group_free_delete(&re->ng);
|
nexthop_group_delete(&re->ng);
|
||||||
XFREE(MTYPE_RE, re);
|
XFREE(MTYPE_RE, re);
|
||||||
return 0;
|
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,
|
* The nexthops got copied over into an nhe,
|
||||||
* so free them now.
|
* so free them now.
|
||||||
*/
|
*/
|
||||||
nexthop_group_free_delete(&re->ng);
|
nexthop_group_delete(&re->ng);
|
||||||
|
|
||||||
if (!nhe) {
|
if (!nhe) {
|
||||||
char buf[PREFIX_STRLEN] = "";
|
char buf[PREFIX_STRLEN] = "";
|
||||||
|
@ -940,7 +940,6 @@ static void free_state(vrf_id_t vrf_id, struct route_entry *re,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
/* free RE and nexthops */
|
/* free RE and nexthops */
|
||||||
nexthops_free(re->ng->nexthop);
|
|
||||||
nexthop_group_delete(&re->ng);
|
nexthop_group_delete(&re->ng);
|
||||||
XFREE(MTYPE_RE, re);
|
XFREE(MTYPE_RE, re);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user