]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
ebtables: Free statically loaded extensions again
authorPhil Sutter <phil@nwl.cc>
Tue, 5 May 2020 11:45:06 +0000 (13:45 +0200)
committerPhil Sutter <phil@nwl.cc>
Mon, 11 May 2020 12:28:29 +0000 (14:28 +0200)
All ebtables extensions are loaded upon program start as due to the lack
of '-m' parameters, loading on demand is not possible. Introduce
nft_fini_eb() to counteract nft_init_eb() and free dynamic memory in
matches and targets from there.

Signed-off-by: Phil Sutter <phil@nwl.cc>
iptables/nft.h
iptables/xtables-eb-standalone.c
iptables/xtables-eb.c
iptables/xtables-restore.c

index aeacc608fcb9f4fd50947ab07ae0076c9bd17610..bd783231156b78f5606280d7bc8d80a07d583a9f 100644 (file)
@@ -225,6 +225,7 @@ int nft_init_arp(struct nft_handle *h, const char *pname);
 int do_commandarp(struct nft_handle *h, int argc, char *argv[], char **table, bool restore);
 /* For xtables-eb.c */
 int nft_init_eb(struct nft_handle *h, const char *pname);
+void nft_fini_eb(struct nft_handle *h);
 int ebt_get_current_chain(const char *chain);
 int do_commandeb(struct nft_handle *h, int argc, char *argv[], char **table, bool restore);
 
index ff74ddbb37334d9f21ed1a003897a22d948e0a7a..181cf2d0cbe1109e91ea65a2e59f5a27c5e80c47 100644 (file)
@@ -53,7 +53,7 @@ int xtables_eb_main(int argc, char *argv[])
        if (ret)
                ret = nft_bridge_commit(&h);
 
-       nft_fini(&h);
+       nft_fini_eb(&h);
 
        if (!ret)
                fprintf(stderr, "ebtables: %s\n", nft_strerror(errno));
index 07ed651370913ab5843ee7ba1e5bb5c1b58be57d..0df1345ae5cd359160fda873a8795da577f1f9c2 100644 (file)
@@ -752,6 +752,23 @@ int nft_init_eb(struct nft_handle *h, const char *pname)
        return 0;
 }
 
+void nft_fini_eb(struct nft_handle *h)
+{
+       struct xtables_match *match;
+       struct xtables_target *target;
+
+       for (match = xtables_matches; match; match = match->next) {
+               free(match->m);
+       }
+       for (target = xtables_targets; target; target = target->next) {
+               free(target->t);
+       }
+
+       free(opts);
+
+       nft_fini(h);
+}
+
 int do_commandeb(struct nft_handle *h, int argc, char *argv[], char **table,
                 bool restore)
 {
index 418a7400c8ce00c06fadada632e85c9217e26ca8..0d6fd64271f516727f69c9df010407be3330e2a6 100644 (file)
@@ -448,7 +448,7 @@ int xtables_eb_restore_main(int argc, char *argv[])
        nft_init_eb(&h, "ebtables-restore");
        h.noflush = noflush;
        xtables_restore_parse(&h, &p);
-       nft_fini(&h);
+       nft_fini_eb(&h);
 
        return 0;
 }