]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: clean pbr_iptable interface_name_list free
authorLouis Scalbert <louis.scalbert@6wind.com>
Fri, 11 Apr 2025 13:13:23 +0000 (15:13 +0200)
committerLouis Scalbert <louis.scalbert@6wind.com>
Fri, 11 Apr 2025 13:52:42 +0000 (15:52 +0200)
Clean up code related to pbr_iptable->interface_name_list free. This is
a cosmetic change.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
zebra/zapi_msg.c
zebra/zebra_pbr.c
zebra/zebra_pbr.h

index 7cd64b1edc0d160ab6fdf6217b252049d9fc8642..fc78f87eb1dea462d65137fcf31d4387b25bca35 100644 (file)
@@ -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);
index ae15b0dad7aa2421857cfde72b171c972acd4971..49846a00c86f6fff995b6d06f997d2623c7bc431 100644 (file)
@@ -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
index b4bfb7a726b9581947d7d5ee6d84bb18356d4dee..25868a6c1e0ffd96e2c5b1411b973b48b89f02cf 100644 (file)
@@ -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);