Skip to contentSkip to conversation

netfilter: nft_nat: use the right enum members for nat type switch

PATCH In review Fernando Fernandez Mancera 2 participants 2 messages Sep 22

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: nft_nat: use the right enum members for nat type switch

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.

---
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(-)
net/netfilter/nft_nat.c +4 -4
index e32cd9fbc7c2..2691cfb10290 100644
@@ -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));
Signature · 1 line
2.55.0
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · 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.

Fixes 3ff7ddb1353d ("netfilter: nft_nat: add netmap support")