netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: leroy christophe <christophe.leroy@c-s.fr>
To: Pablo Neira Ayuso <pablo@netfilter.org>, netfilter-devel@vger.kernel.org
Cc: kaber@trash.net
Subject: Re: [PATCH] netfilter: nf_tables: fix port natting in little endian archs
Date: Tue, 23 Dec 2014 15:24:30 +0100	[thread overview]
Message-ID: <54997B1E.7010706@c-s.fr> (raw)
In-Reply-To: <1419253182-3590-1-git-send-email-pablo@netfilter.org>


Le 22/12/2014 13:59, Pablo Neira Ayuso a écrit :
> From: leroy christophe <christophe.leroy@c-s.fr>
>
> Make sure this fetches 16-bits port data from the register.
> Remove casting to make sparse happy, not needed anymore.
>
> Signed-off-by: leroy christophe <christophe.leroy@c-s.fr>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
> @Christophe: I have also mangled other spots where this problems will show up
> and remove casting (not required anymore to make sparse happy). Please, test
> and will submit this to mainstream. I have included you as author, I wanted
> to speed up the submission process. Thanks.

It works OK, both for NAT and REDIRECT. Tested on ipv4, not tested with 
ipv6.

Christophe

>
>   net/ipv4/netfilter/nft_redir_ipv4.c |    8 ++++----
>   net/ipv6/netfilter/nft_redir_ipv6.c |    8 ++++----
>   net/netfilter/nft_nat.c             |    8 ++++----
>   3 files changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/net/ipv4/netfilter/nft_redir_ipv4.c b/net/ipv4/netfilter/nft_redir_ipv4.c
> index ff2d23d..6ecfce6 100644
> --- a/net/ipv4/netfilter/nft_redir_ipv4.c
> +++ b/net/ipv4/netfilter/nft_redir_ipv4.c
> @@ -27,10 +27,10 @@ static void nft_redir_ipv4_eval(const struct nft_expr *expr,
>   
>   	memset(&mr, 0, sizeof(mr));
>   	if (priv->sreg_proto_min) {
> -		mr.range[0].min.all = (__force __be16)
> -					data[priv->sreg_proto_min].data[0];
> -		mr.range[0].max.all = (__force __be16)
> -					data[priv->sreg_proto_max].data[0];
> +		mr.range[0].min.all =
> +			*(__be16 *)&data[priv->sreg_proto_min].data[0];
> +		mr.range[0].max.all =
> +			*(__be16 *)&data[priv->sreg_proto_max].data[0];
>   		mr.range[0].flags |= NF_NAT_RANGE_PROTO_SPECIFIED;
>   	}
>   
> diff --git a/net/ipv6/netfilter/nft_redir_ipv6.c b/net/ipv6/netfilter/nft_redir_ipv6.c
> index 2433a6b..11820b6 100644
> --- a/net/ipv6/netfilter/nft_redir_ipv6.c
> +++ b/net/ipv6/netfilter/nft_redir_ipv6.c
> @@ -27,10 +27,10 @@ static void nft_redir_ipv6_eval(const struct nft_expr *expr,
>   
>   	memset(&range, 0, sizeof(range));
>   	if (priv->sreg_proto_min) {
> -		range.min_proto.all = (__force __be16)
> -					data[priv->sreg_proto_min].data[0];
> -		range.max_proto.all = (__force __be16)
> -					data[priv->sreg_proto_max].data[0];
> +		range.min_proto.all =
> +			*(__be16 *)&data[priv->sreg_proto_min].data[0];
> +		range.max_proto.all =
> +			*(__be16 *)&data[priv->sreg_proto_max].data[0];
>   		range.flags |= NF_NAT_RANGE_PROTO_SPECIFIED;
>   	}
>   
> diff --git a/net/netfilter/nft_nat.c b/net/netfilter/nft_nat.c
> index afe2b0b..aff54fb1 100644
> --- a/net/netfilter/nft_nat.c
> +++ b/net/netfilter/nft_nat.c
> @@ -65,10 +65,10 @@ static void nft_nat_eval(const struct nft_expr *expr,
>   	}
>   
>   	if (priv->sreg_proto_min) {
> -		range.min_proto.all = (__force __be16)
> -					data[priv->sreg_proto_min].data[0];
> -		range.max_proto.all = (__force __be16)
> -					data[priv->sreg_proto_max].data[0];
> +		range.min_proto.all =
> +			*(__be16 *)&data[priv->sreg_proto_min].data[0];
> +		range.max_proto.all =
> +			*(__be16 *)&data[priv->sreg_proto_max].data[0];
>   		range.flags |= NF_NAT_RANGE_PROTO_SPECIFIED;
>   	}
>   

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      reply	other threads:[~2014-12-23 14:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-22 12:59 [PATCH] netfilter: nf_tables: fix port natting in little endian archs Pablo Neira Ayuso
2014-12-23 14:24 ` leroy christophe [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54997B1E.7010706@c-s.fr \
    --to=christophe.leroy@c-s.fr \
    --cc=kaber@trash.net \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).