Skip to contentSkip to conversation

netfilter: nat: really support inet nat without l3 address

PATCH Applied Florian Westphal 2 participants 2 messages Jun 1, 2022

Subsystems (3)
lore
Share & tools
lore

Florian Westphal

author maintainer
#0 lore raw

PATCH 1/1 netfilter: nat: really support inet nat without l3 address

When no l3 address is given, priv->family is set to NFPROTO_INET and the evaluation function isn't called.

Call it too so l4-only rewrite can work.
Also add a test case for this.

Fixes a33f387ecd5aa ("netfilter: nft_nat: allow to specify layer 4 protocol NAT only")
---
 net/netfilter/nft_nat.c                      |  3 +-
 tools/testing/selftests/netfilter/nft_nat.sh | 43 ++++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletion(-)
net/netfilter/nft_nat.c +2 -1
index 4394df4bc99b..e5fd6995e4bf 100644
@@ -335,7 +335,8 @@ static void nft_nat_inet_eval(const struct nft_expr *expr,
 {
 	const struct nft_nat *priv = nft_expr_priv(expr);
 
-	if (priv->family == nft_pf(pkt))
+	if (priv->family == nft_pf(pkt) ||
+	    priv->family == NFPROTO_INET)
 		nft_nat_eval(expr, regs, pkt);
 }
 
tools/testing/selftests/netfilter/nft_nat.sh +43 -0

55 lines not on this page · raw message

Signature · 1 line
2.36.1
maintainer Applied
#1 lore raw
Quoted 5 lines · Florian Westphal

When no l3 address is given, priv->family is set to NFPROTO_INET and the evaluation function isn't called.

Call it too so l4-only rewrite can work.
Also add a test case for this.

Applied to nf, thanks