Linux Netfilter development
 help / color / mirror / Atom feed
* [PATCH nf-next] netfilter: nft_nat: use the right enum members for nat type switch
@ 2026-09-22 16:40 Fernando Fernandez Mancera
  2026-09-22 16:51 ` Phil Sutter
  0 siblings, 1 reply; 2+ messages in thread
From: Fernando Fernandez Mancera @ 2026-09-22 16:40 UTC (permalink / raw)
  To: netfilter-devel; +Cc: coreteam, pablo, fw, phil, Fernando Fernandez Mancera

The member 'type' from struct 'nft_nat' is of type enum
nf_nat_manip_type but at the switch statements for
nft_nat_setup_netmap() and nft_nat_validate() functions the members from
nft_nat_types enum were used instead.

This does not cause any problem but is worth fixing for correctness.

Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>
---
Note: found this while working on something else but confused for a
bit.. so I guess it is worth fixing.
---
 net/netfilter/nft_nat.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/netfilter/nft_nat.c b/net/netfilter/nft_nat.c
index e32cd9fbc7c2..2691cfb10290 100644
--- a/net/netfilter/nft_nat.c
+++ b/net/netfilter/nft_nat.c
@@ -70,7 +70,7 @@ static void nft_nat_setup_netmap(struct nf_nat_range2 *range,
 	int i, len = 0;
 
 	switch (priv->type) {
-	case NFT_NAT_SNAT:
+	case NF_NAT_MANIP_SRC:
 		if (nft_pf(pkt) == NFPROTO_IPV4) {
 			new_addr.ip = ip_hdr(skb)->saddr;
 			len = sizeof(struct in_addr);
@@ -79,7 +79,7 @@ static void nft_nat_setup_netmap(struct nf_nat_range2 *range,
 			len = sizeof(struct in6_addr);
 		}
 		break;
-	case NFT_NAT_DNAT:
+	case NF_NAT_MANIP_DST:
 		if (nft_pf(pkt) == NFPROTO_IPV4) {
 			new_addr.ip = ip_hdr(skb)->daddr;
 			len = sizeof(struct in_addr);
@@ -152,12 +152,12 @@ static int nft_nat_validate(const struct nft_ctx *ctx,
 		return err;
 
 	switch (priv->type) {
-	case NFT_NAT_SNAT:
+	case NF_NAT_MANIP_SRC:
 		err = nft_chain_validate_hooks(ctx->chain,
 					       (1 << NF_INET_POST_ROUTING) |
 					       (1 << NF_INET_LOCAL_IN));
 		break;
-	case NFT_NAT_DNAT:
+	case NF_NAT_MANIP_DST:
 		err = nft_chain_validate_hooks(ctx->chain,
 					       (1 << NF_INET_PRE_ROUTING) |
 					       (1 << NF_INET_LOCAL_OUT));
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH nf-next] netfilter: nft_nat: use the right enum members for nat type switch
  2026-09-22 16:40 [PATCH nf-next] netfilter: nft_nat: use the right enum members for nat type switch Fernando Fernandez Mancera
@ 2026-09-22 16:51 ` Phil Sutter
  0 siblings, 0 replies; 2+ messages in thread
From: Phil Sutter @ 2026-09-22 16:51 UTC (permalink / raw)
  To: Fernando Fernandez Mancera; +Cc: netfilter-devel, coreteam, pablo, fw

On Tue, Sep 22, 2026 at 06:40:59PM +0200, Fernando Fernandez Mancera wrote:
> The member 'type' from struct 'nft_nat' is of type enum
> nf_nat_manip_type but at the switch statements for
> nft_nat_setup_netmap() and nft_nat_validate() functions the members from
> nft_nat_types enum were used instead.
> 
> This does not cause any problem but is worth fixing for correctness.
> 

> Signed-off-by: Fernando Fernandez Mancera <fmancera@suse.de>

Fixes: 3ff7ddb1353d ("netfilter: nft_nat: add netmap support")
Acked-by: Phil Sutter <phil@nwl.cc>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-22 16:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-22 16:40 [PATCH nf-next] netfilter: nft_nat: use the right enum members for nat type switch Fernando Fernandez Mancera
2026-09-22 16:51 ` Phil Sutter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox