diff options
| -rw-r--r-- | zebra/zapi_msg.c | 1 | ||||
| -rw-r--r-- | zebra/zebra_pbr.c | 28 | ||||
| -rw-r--r-- | zebra/zebra_pbr.h | 2 | 
3 files changed, 13 insertions, 18 deletions
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 7cd64b1edc..fc78f87eb1 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -3878,6 +3878,7 @@ static inline void zread_iptable(ZAPI_HANDLER_ARGS)  	s = msg;  	zpi->interface_name_list = list_new(); +	zpi->interface_name_list->del = zebra_pbr_iptable_interface_name_list_free;  	zpi->sock = client->sock;  	zpi->vrf_id = zvrf->vrf->vrf_id;  	STREAM_GETL(s, zpi->unique); diff --git a/zebra/zebra_pbr.c b/zebra/zebra_pbr.c index ae15b0dad7..49846a00c8 100644 --- a/zebra/zebra_pbr.c +++ b/zebra/zebra_pbr.c @@ -383,22 +383,15 @@ bool zebra_pbr_ipset_entry_hash_equal(const void *arg1, const void *arg2)  static void _zebra_pbr_iptable_free_all(void *arg, bool all)  {  	struct zebra_pbr_iptable *iptable; -	struct listnode *node, *nnode; -	char *name;  	iptable = (struct zebra_pbr_iptable *)arg;  	if (all)  		hook_call(zebra_pbr_iptable_update, 0, iptable); -	if (iptable->interface_name_list) { -		for (ALL_LIST_ELEMENTS(iptable->interface_name_list, node, -				       nnode, name)) { -			XFREE(MTYPE_PBR_IPTABLE_IFNAME, name); -			list_delete_node(iptable->interface_name_list, node); -		} +	if (iptable->interface_name_list)  		list_delete(&iptable->interface_name_list); -	} +  	XFREE(MTYPE_PBR_IPTABLE, iptable);  } @@ -1003,6 +996,13 @@ void zebra_pbr_del_ipset_entry(struct zebra_pbr_ipset_entry *ipset)  			   __func__);  } +void zebra_pbr_iptable_interface_name_list_free(void *arg) +{ +	char *name = arg; + +	XFREE(MTYPE_PBR_IPTABLE_IFNAME, name); +} +  static void *pbr_iptable_alloc_intern(void *arg)  {  	struct zebra_pbr_iptable *zpi; @@ -1017,6 +1017,7 @@ static void *pbr_iptable_alloc_intern(void *arg)  	/* Deep structure copy */  	memcpy(new, zpi, sizeof(*zpi));  	new->interface_name_list = list_new(); +	new->interface_name_list->del = zebra_pbr_iptable_interface_name_list_free;  	if (zpi->interface_name_list) {  		for (ALL_LIST_ELEMENTS_RO(zpi->interface_name_list, ln, ifname)) @@ -1043,16 +1044,7 @@ void zebra_pbr_del_iptable(struct zebra_pbr_iptable *iptable)  	lookup = hash_lookup(zrouter.iptable_hash, iptable);  	(void)dplane_pbr_iptable_delete(iptable);  	if (lookup) { -		struct listnode *node, *nnode; -		char *name; -  		hash_release(zrouter.iptable_hash, lookup); -		for (ALL_LIST_ELEMENTS(lookup->interface_name_list, -				       node, nnode, name)) { -			XFREE(MTYPE_PBR_IPTABLE_IFNAME, name); -			list_delete_node(lookup->interface_name_list, -					 node); -		}  		list_delete(&lookup->interface_name_list);  		XFREE(MTYPE_PBR_IPTABLE, lookup);  	} else diff --git a/zebra/zebra_pbr.h b/zebra/zebra_pbr.h index b4bfb7a726..25868a6c1e 100644 --- a/zebra/zebra_pbr.h +++ b/zebra/zebra_pbr.h @@ -196,6 +196,8 @@ struct zebra_pbr_ipset *zebra_pbr_lookup_ipset_pername(char *ipsetname);  void zebra_pbr_add_ipset_entry(struct zebra_pbr_ipset_entry *ipset);  void zebra_pbr_del_ipset_entry(struct zebra_pbr_ipset_entry *ipset); +void zebra_pbr_iptable_interface_name_list_free(void *arg); +  void zebra_pbr_add_iptable(struct zebra_pbr_iptable *iptable);  void zebra_pbr_del_iptable(struct zebra_pbr_iptable *iptable);  void zebra_pbr_process_iptable(struct zebra_dplane_ctx *ctx);  | 
