Skip to content

Commit

Permalink
zebra: Actually free all memory associated ctx->u.iptable.interface_n…
Browse files Browse the repository at this point in the history
…ame_list

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
  • Loading branch information
donaldsharp committed Dec 9, 2022
1 parent 63e6e11 commit 1cc3806
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions zebra/zebra_dplane.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,20 +833,8 @@ static void dplane_ctx_free_internal(struct zebra_dplane_ctx *ctx)
break;
case DPLANE_OP_IPTABLE_ADD:
case DPLANE_OP_IPTABLE_DELETE:
if (ctx->u.iptable.interface_name_list) {
struct listnode *node, *nnode;
char *ifname;

for (ALL_LIST_ELEMENTS(
ctx->u.iptable.interface_name_list, node,
nnode, ifname)) {
LISTNODE_DETACH(
ctx->u.iptable.interface_name_list,
node);
XFREE(MTYPE_DP_NETFILTER, ifname);
}
if (ctx->u.iptable.interface_name_list)
list_delete(&ctx->u.iptable.interface_name_list);
}
break;
case DPLANE_OP_GRE_SET:
case DPLANE_OP_INTF_NETCONFIG:
Expand Down Expand Up @@ -3476,6 +3464,11 @@ static int dplane_ctx_rule_init(struct zebra_dplane_ctx *ctx,
return AOK;
}

static void zebra_dplane_interface_name_list_deletion(void *data)
{
XFREE(MTYPE_DP_NETFILTER, data);
}

/**
* dplane_ctx_iptable_init() - Initialize a context block for a PBR iptable
* update.
Expand Down Expand Up @@ -3509,9 +3502,10 @@ static int dplane_ctx_iptable_init(struct zebra_dplane_ctx *ctx,

ctx->zd_vrf_id = iptable->vrf_id;
memcpy(&ctx->u.iptable, iptable, sizeof(struct zebra_pbr_iptable));
ctx->u.iptable.interface_name_list = NULL;
if (iptable->nb_interface > 0) {
ctx->u.iptable.interface_name_list = list_new();
ctx->u.iptable.interface_name_list->del =
zebra_dplane_interface_name_list_deletion;
for (ALL_LIST_ELEMENTS_RO(iptable->interface_name_list, node,
ifname)) {
listnode_add(ctx->u.iptable.interface_name_list,
Expand Down

0 comments on commit 1cc3806

Please sign in to comment.