]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
xtables: merge nft_ipv{4,6}_parse_target()
authorPhil Sutter <phil@nwl.cc>
Thu, 19 Jul 2018 16:32:01 +0000 (18:32 +0200)
committerFlorian Westphal <fw@strlen.de>
Thu, 19 Jul 2018 21:08:55 +0000 (23:08 +0200)
Both functions are identical, replace them by a common one in
nft-shared.c.

Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Florian Westphal <fw@strlen.de>
iptables/nft-ipv4.c
iptables/nft-ipv6.c
iptables/nft-shared.c
iptables/nft-shared.h

index 9db828172ae20e2b314d2a1e440052559c726c51..2afb1453bdc866e3f9160576f9103c0fb594e276 100644 (file)
@@ -414,13 +414,6 @@ static void nft_ipv4_post_parse(int command,
                              " source or destination IP addresses");
 }
 
-static void nft_ipv4_parse_target(struct xtables_target *t, void *data)
-{
-       struct iptables_command_state *cs = data;
-
-       cs->target = t;
-}
-
 static bool nft_ipv4_rule_find(struct nft_family_ops *ops,
                               struct nftnl_rule *r, void *data)
 {
@@ -510,7 +503,7 @@ struct nft_family_ops nft_family_ops_ipv4 = {
        .save_counters          = nft_ipv4_save_counters,
        .proto_parse            = nft_ipv4_proto_parse,
        .post_parse             = nft_ipv4_post_parse,
-       .parse_target           = nft_ipv4_parse_target,
+       .parse_target           = nft_ipv46_parse_target,
        .rule_to_cs             = nft_rule_to_iptables_command_state,
        .clear_cs               = nft_clear_iptables_command_state,
        .rule_find              = nft_ipv4_rule_find,
index 018f1d3f73aa00610e07e8f9076d73785e9524c0..ddaeb2b4264ed621b4a601560217b2a99679862b 100644 (file)
@@ -367,13 +367,6 @@ static void nft_ipv6_post_parse(int command, struct iptables_command_state *cs,
                              " source or destination IP addresses");
 }
 
-static void nft_ipv6_parse_target(struct xtables_target *t, void *data)
-{
-       struct iptables_command_state *cs = data;
-
-       cs->target = t;
-}
-
 static bool nft_ipv6_rule_find(struct nft_family_ops *ops,
                               struct nftnl_rule *r, void *data)
 {
@@ -465,7 +458,7 @@ struct nft_family_ops nft_family_ops_ipv6 = {
        .save_counters          = nft_ipv6_save_counters,
        .proto_parse            = nft_ipv6_proto_parse,
        .post_parse             = nft_ipv6_post_parse,
-       .parse_target           = nft_ipv6_parse_target,
+       .parse_target           = nft_ipv46_parse_target,
        .rule_to_cs             = nft_rule_to_iptables_command_state,
        .clear_cs               = nft_clear_iptables_command_state,
        .rule_find              = nft_ipv6_rule_find,
index 24287e9762a9a655be6596bd665067c4206ae87a..7abe158bdc55fbe8974dec7417ffa1214b2d4f2d 100644 (file)
@@ -924,6 +924,13 @@ bool compare_targets(struct xtables_target *tg1, struct xtables_target *tg2)
        return true;
 }
 
+void nft_ipv46_parse_target(struct xtables_target *t, void *data)
+{
+       struct iptables_command_state *cs = data;
+
+       cs->target = t;
+}
+
 bool nft_ipv46_rule_find(struct nft_family_ops *ops,
                         struct nftnl_rule *r, struct iptables_command_state *cs)
 {
index 8172c8731151a60c5ff48f9bb17c625f4a47290b..deded06b633ac61b9e3b71bf3e34017d8694000a 100644 (file)
@@ -174,6 +174,7 @@ void save_matches_and_target(struct xtables_rule_match *m,
 struct nft_family_ops *nft_family_ops_lookup(int family);
 
 struct nft_handle;
+void nft_ipv46_parse_target(struct xtables_target *t, void *data);
 bool nft_ipv46_rule_find(struct nft_family_ops *ops, struct nftnl_rule *r,
                         struct iptables_command_state *cs);