netfilter: nft_nat: use the right enum members for nat type switch
Subsystems (2)
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
@@ -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
Quoted 9 lines · Fernando Fernandez Mancera
The member 'type' from struct '
nft_nat' is of type enumnf_nat_manip_typebut at the switch statements fornft_nat_setup_netmap()andnft_nat_validate()functions the members fromnft_nat_typesenum were used instead.This does not cause any problem but is worth fixing for correctness.
Signed-off-by Fernando Fernandez Mancera <[email protected]>