Skip to contentSkip to conversation

netfilter: nft_compat: set IP6T_F_PROTO flag if protocol is set

PATCH In review Pablo Neira Ayuso 2 participants 3 messages Mar 21, 2015

Subsystems (2)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 netfilter: nft_compat: set IP6T_F_PROTO flag if protocol is set

ip6tables extensions check for this flag to restrict match/target to a given protocol. Without this flag set, SYNPROXY6 returns an error.

---
 net/netfilter/nft_compat.c |    6 ++++++
 1 file changed, 6 insertions(+)
net/netfilter/nft_compat.c +6 -0
index 213584c..65f3e2b 100644
@@ -133,6 +133,9 @@ nft_target_set_tgchk_param(struct xt_tgchk_param *par,
 		entry->e4.ip.invflags = inv ? IPT_INV_PROTO : 0;
 		break;
 	case AF_INET6:
+		if (proto)
+			entry->e6.ipv6.flags |= IP6T_F_PROTO;
+
 		entry->e6.ipv6.proto = proto;
 		entry->e6.ipv6.invflags = inv ? IP6T_INV_PROTO : 0;
 		break;
@@ -344,6 +347,9 @@ nft_match_set_mtchk_param(struct xt_mtchk_param *par, const struct nft_ctx *ctx,
 		entry->e4.ip.invflags = inv ? IPT_INV_PROTO : 0;
 		break;
 	case AF_INET6:
+		if (proto)
+			entry->e6.ipv6.flags |= IP6T_F_PROTO;
+
 		entry->e6.ipv6.proto = proto;
 		entry->e6.ipv6.invflags = inv ? IP6T_INV_PROTO : 0;
 		break;
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 2 lines · Pablo Neira Ayuso

ip6tables extensions check for this flag to restrict match/target to a given protocol. Without this flag set, SYNPROXY6 returns an error.

That looks like the correct solution to me, thanks!

I guess we should also fix all the ip6_tables extensions that think they're matching on the L4 protocol but are actually not enforcing this.

Quoted 38 lines
---
 net/netfilter/nft_compat.c |    6 ++++++
 1 file changed, 6 insertions(+)
net/netfilter/nft_compat.c +6 -0
index 213584c..65f3e2b 100644
@@ -133,6 +133,9 @@ nft_target_set_tgchk_param(struct xt_tgchk_param *par,
 		entry->e4.ip.invflags = inv ? IPT_INV_PROTO : 0;
 		break;
 	case AF_INET6:
+		if (proto)
+			entry->e6.ipv6.flags |= IP6T_F_PROTO;
+
 		entry->e6.ipv6.proto = proto;
 		entry->e6.ipv6.invflags = inv ? IP6T_INV_PROTO : 0;
 		break;
@@ -344,6 +347,9 @@ nft_match_set_mtchk_param(struct xt_mtchk_param *par, const struct nft_ctx *ctx,
 		entry->e4.ip.invflags = inv ? IPT_INV_PROTO : 0;
 		break;
 	case AF_INET6:
+		if (proto)
+			entry->e6.ipv6.flags |= IP6T_F_PROTO;
+
 		entry->e6.ipv6.proto = proto;
 		entry->e6.ipv6.invflags = inv ? IP6T_INV_PROTO : 0;
 		break;
Signature · 6 lines
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author maintainer
#2 lore raw
Quoted 9 lines · Patrick McHardy
Quoted 2 lines · Pablo Neira Ayuso

ip6tables extensions check for this flag to restrict match/target to a given protocol. Without this flag set, SYNPROXY6 returns an error.

That looks like the correct solution to me, thanks!

I guess we should also fix all the ip6_tables extensions that think they're matching on the L4 protocol but are actually not enforcing this.

I'll send a follow up patch to fix this. Thanks for reviewing!