summaryrefslogtreecommitdiffstats
path: root/iptables/xshared.c
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2022-11-25 21:42:20 +0100
committerPhil Sutter <phil@nwl.cc>2022-12-02 01:44:17 +0100
commit365647ef056828bc3cb56efef12114951fcb730d (patch)
tree0db3ee2b2d7167d7de0ce24a7254e9c068c309bd /iptables/xshared.c
parentfb63f8b7337aa11a667537e6a3b399062ede2eb5 (diff)
xtables: Introduce xtables_clear_iptables_command_state()
This is nft_clear_iptables_command_state() but in a location reachable by legacy iptables, too. Changes callers in non-family-specific code to use clear_cs callback instead of directly calling it - ebtables still has a custom variant. Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'iptables/xshared.c')
-rw-r--r--iptables/xshared.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/iptables/xshared.c b/iptables/xshared.c
index d400dc59..2a894c19 100644
--- a/iptables/xshared.c
+++ b/iptables/xshared.c
@@ -1356,6 +1356,23 @@ static const char *optstring_lookup(int family)
return "";
}
+void xtables_clear_iptables_command_state(struct iptables_command_state *cs)
+{
+ xtables_rule_matches_free(&cs->matches);
+ if (cs->target) {
+ free(cs->target->t);
+ cs->target->t = NULL;
+
+ free(cs->target->udata);
+ cs->target->udata = NULL;
+
+ if (cs->target == cs->target->next) {
+ free(cs->target);
+ cs->target = NULL;
+ }
+ }
+}
+
void do_parse(int argc, char *argv[],
struct xt_cmd_parse *p, struct iptables_command_state *cs,
struct xtables_args *args)