Skip to contentSkip to conversation

netfilter: nft_nat: Fix inet l4-only NAT

PATCH In review Phil Sutter 2 participants 3 messages Jun 1, 2022

Subsystems (2)
lore
Share & tools
lore

Phil Sutter

author reviewer
#0 lore raw

PATCH 1/1 netfilter: nft_nat: Fix inet l4-only NAT

If nat expression does not specify an address, its family value is NFPROTO_INET. Disable the check against the packet's family in that case.

Fixes a33f387ecd5aa ("netfilter: nft_nat: allow to specify layer 4 protocol NAT only")
---
 net/netfilter/nft_nat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nft_nat.c +1 -1
index 4394df4bc99b4..4ee690bdbf392 100644
@@ -335,7 +335,7 @@ 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 == NFPROTO_INET || priv->family == nft_pf(pkt))
 		nft_nat_eval(expr, regs, pkt);
 }
 
Signature · 1 line
2.34.1
author reviewer
#1 lore raw
Quoted 6 lines · Phil Sutter

If nat expression does not specify an address, its family value is NFPROTO_INET. Disable the check against the packet's family in that case.

Fixes a33f387ecd5aa ("netfilter: nft_nat: allow to specify layer 4 protocol NAT only")

Argh. Duplicate work with Florian (message-ID [email protected]), please use his patch - it adds a test as well.

Sorry for the noise!

#2 lore raw
In reply to Phil Sutter
Quoted 6 lines · Phil Sutter

If nat expression does not specify an address, its family value is NFPROTO_INET. Disable the check against the packet's family in that case.

Fixes a33f387ecd5aa ("netfilter: nft_nat: allow to specify layer 4 protocol NAT only")

Florian posted this:

https://patchwork.ozlabs.org/project/netfilter-devel/patch/[email protected]/

Quoted 20 lines
---
 net/netfilter/nft_nat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nft_nat.c +1 -1
index 4394df4bc99b4..4ee690bdbf392 100644
@@ -335,7 +335,7 @@ 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 == NFPROTO_INET || priv->family == nft_pf(pkt))
 		nft_nat_eval(expr, regs, pkt);
 }
 
Signature · 1 line
2.34.1