Skip to content

Commit 1cc3806

Browse files
committed
zebra: Actually free all memory associated ctx->u.iptable.interface_name_list
Signed-off-by: Donald Sharp <[email protected]>
1 parent 63e6e11 commit 1cc3806

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

zebra/zebra_dplane.c

+8-14
Original file line numberDiff line numberDiff line change
@@ -833,20 +833,8 @@ static void dplane_ctx_free_internal(struct zebra_dplane_ctx *ctx)
833833
break;
834834
case DPLANE_OP_IPTABLE_ADD:
835835
case DPLANE_OP_IPTABLE_DELETE:
836-
if (ctx->u.iptable.interface_name_list) {
837-
struct listnode *node, *nnode;
838-
char *ifname;
839-
840-
for (ALL_LIST_ELEMENTS(
841-
ctx->u.iptable.interface_name_list, node,
842-
nnode, ifname)) {
843-
LISTNODE_DETACH(
844-
ctx->u.iptable.interface_name_list,
845-
node);
846-
XFREE(MTYPE_DP_NETFILTER, ifname);
847-
}
836+
if (ctx->u.iptable.interface_name_list)
848837
list_delete(&ctx->u.iptable.interface_name_list);
849-
}
850838
break;
851839
case DPLANE_OP_GRE_SET:
852840
case DPLANE_OP_INTF_NETCONFIG:
@@ -3476,6 +3464,11 @@ static int dplane_ctx_rule_init(struct zebra_dplane_ctx *ctx,
34763464
return AOK;
34773465
}
34783466

3467+
static void zebra_dplane_interface_name_list_deletion(void *data)
3468+
{
3469+
XFREE(MTYPE_DP_NETFILTER, data);
3470+
}
3471+
34793472
/**
34803473
* dplane_ctx_iptable_init() - Initialize a context block for a PBR iptable
34813474
* update.
@@ -3509,9 +3502,10 @@ static int dplane_ctx_iptable_init(struct zebra_dplane_ctx *ctx,
35093502

35103503
ctx->zd_vrf_id = iptable->vrf_id;
35113504
memcpy(&ctx->u.iptable, iptable, sizeof(struct zebra_pbr_iptable));
3512-
ctx->u.iptable.interface_name_list = NULL;
35133505
if (iptable->nb_interface > 0) {
35143506
ctx->u.iptable.interface_name_list = list_new();
3507+
ctx->u.iptable.interface_name_list->del =
3508+
zebra_dplane_interface_name_list_deletion;
35153509
for (ALL_LIST_ELEMENTS_RO(iptable->interface_name_list, node,
35163510
ifname)) {
35173511
listnode_add(ctx->u.iptable.interface_name_list,

0 commit comments

Comments
 (0)