Skip to contentSkip to conversation

nft: fix inversion of built-in selectors

PATCH New Pablo Neira Ayuso 1 participant 1 message Nov 18, 2013 netfilter

lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 nft: fix inversion of built-in selectors

(0ab045f xtables: fix missing ipt_entry for MASQUERADE target) broke inversion of built-in selectors, such as -s, -d, etc.

We need to refresh the invflags if -p is used or set it for first time if -p is not used, otherwise inversion is ignored.

---
 iptables/nft-ipv4.c |    4 ++++
 iptables/nft-ipv6.c |    4 ++++
 2 files changed, 8 insertions(+)
iptables/nft-ipv4.c +4 -0
index 2ac823f..1afe8b6 100644
@@ -343,6 +343,10 @@ static void nft_ipv4_post_parse(int command,
 				struct xtables_args *args)
 {
 	cs->fw.ip.flags = args->flags;
+	/* We already set invflags in proto_parse, but we need to refresh it
+	 * to include new parsed options.
+	 */
+	cs->fw.ip.invflags = args->invflags;
 
 	strncpy(cs->fw.ip.iniface, args->iniface, IFNAMSIZ);
 	memcpy(cs->fw.ip.iniface_mask,
iptables/nft-ipv6.c +4 -0
index b02d952..f30cec6 100644
@@ -264,6 +264,10 @@ static void nft_ipv6_post_parse(int command, struct iptables_command_state *cs,
 		args->flags |= IP6T_F_PROTO;
 
 	cs->fw6.ipv6.flags = args->flags;
+	/* We already set invflags in proto_parse, but we need to refresh it
+	 * to include new parsed options.
+	 */
+	cs->fw6.ipv6.invflags = args->invflags;
 
 	strncpy(cs->fw6.ipv6.iniface, args->iniface, IFNAMSIZ);
 	memcpy(cs->fw6.ipv6.iniface_mask,
Signature · 1 line
1.7.10.4