All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [nftables-kernel PATCH] netfilter: nftables: Fix sparse endianness issue on nft_nat.c
Date: Mon, 28 Oct 2013 09:41:11 +0000	[thread overview]
Message-ID: <20131028094111.GA9725@macbook.localnet> (raw)
In-Reply-To: <1382086853-14251-1-git-send-email-tomasz.bursztyka@linux.intel.com>

On Fri, Oct 18, 2013 at 12:00:53PM +0300, Tomasz Bursztyka wrote:
> Fixes this:
> 
> CHECK   net/netfilter/nft_nat.c
> net/netfilter/nft_nat.c:50:43: warning: incorrect type in assignment (different base types)
> net/netfilter/nft_nat.c:50:43:    expected restricted __be32 [addressable] [usertype] ip
> net/netfilter/nft_nat.c:50:43:    got unsigned int [unsigned] [usertype] <noident>
> net/netfilter/nft_nat.c:51:43: warning: incorrect type in assignment (different base types)
> net/netfilter/nft_nat.c:51:43:    expected restricted __be32 [addressable] [usertype] ip
> net/netfilter/nft_nat.c:51:43:    got unsigned int [unsigned] [usertype] <noident>
> net/netfilter/nft_nat.c:65:37: warning: incorrect type in assignment (different base types)
> net/netfilter/nft_nat.c:65:37:    expected restricted __be16 [addressable] [assigned] [usertype] all
> net/netfilter/nft_nat.c:65:37:    got unsigned int [unsigned] <noident>
> net/netfilter/nft_nat.c:66:37: warning: incorrect type in assignment (different base types)
> net/netfilter/nft_nat.c:66:37:    expected restricted __be16 [addressable] [assigned] [usertype] all
> net/netfilter/nft_nat.c:66:37:    got unsigned int [unsigned] <noident>
> 
> Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
> ---
> 
> Hi,
> 
> looks a bit ugly, would there be another way to fix this?
> 
> Tomasz
> 
>  net/netfilter/nft_nat.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/net/netfilter/nft_nat.c b/net/netfilter/nft_nat.c
> index b0b87b2..f9d488f 100644
> --- a/net/netfilter/nft_nat.c
> +++ b/net/netfilter/nft_nat.c
> @@ -47,8 +47,12 @@ static void nft_nat_eval(const struct nft_expr *expr,
>  	memset(&range, 0, sizeof(range));
>  	if (priv->sreg_addr_min) {
>  		if (priv->family == AF_INET) {
> -			range.min_addr.ip = data[priv->sreg_addr_min].data[0];
> -			range.max_addr.ip = data[priv->sreg_addr_max].data[0];
> +			range.min_addr.ip =
> +				be32_to_cpup((__be32 *)
> +					data[priv->sreg_addr_min].data);
> +			range.max_addr.ip =
> +				be32_to_cpup((__be32 *)
> +					data[priv->sreg_addr_max].data);

That doesn't seem correct, we don't want to actually switch the byteorder of
the data. I'd suggest to simply use (__force __be32).

  parent reply	other threads:[~2013-10-28  9:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-18  9:00 [nftables-kernel PATCH] netfilter: nftables: Fix sparse endianness issue on nft_nat.c Tomasz Bursztyka
2013-10-28  7:18 ` Tomasz Bursztyka
2013-10-28  9:41 ` Patrick McHardy [this message]
2013-10-28 10:13   ` Tomasz Bursztyka

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=20131028094111.GA9725@macbook.localnet \
    --to=kaber@trash.net \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=tomasz.bursztyka@linux.intel.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.