[iptables PATCH 09/17] xtables: Merge nft_ipv{4,6}_parse_target()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Both functions are identical, replace them by a common one in
nft-shared.c.

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 iptables/nft-ipv4.c   | 9 +--------
 iptables/nft-ipv6.c   | 9 +--------
 iptables/nft-shared.c | 7 +++++++
 iptables/nft-shared.h | 1 +
 4 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/iptables/nft-ipv4.c b/iptables/nft-ipv4.c
index 9db828172ae20..2afb1453bdc86 100644
--- a/iptables/nft-ipv4.c
+++ b/iptables/nft-ipv4.c
@@ -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,
diff --git a/iptables/nft-ipv6.c b/iptables/nft-ipv6.c
index 018f1d3f73aa0..ddaeb2b4264ed 100644
--- a/iptables/nft-ipv6.c
+++ b/iptables/nft-ipv6.c
@@ -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,
diff --git a/iptables/nft-shared.c b/iptables/nft-shared.c
index 24287e9762a9a..7abe158bdc55f 100644
--- a/iptables/nft-shared.c
+++ b/iptables/nft-shared.c
@@ -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)
 {
diff --git a/iptables/nft-shared.h b/iptables/nft-shared.h
index 8172c8731151a..deded06b633ac 100644
--- a/iptables/nft-shared.h
+++ b/iptables/nft-shared.h
@@ -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);
 
-- 
2.18.0

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux