Netdev Archive on lore.kernel.org
 help / color / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Stephen Rothwell <sfr@canb.auug.org.au>,
	Pablo Neira Ayuso <pablo@netfilter.org>
Cc: David Miller <davem@davemloft.net>,
	Networking <netdev@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	NetFilter <netfilter-devel@vger.kernel.org>,
	Jiri Pirko <jiri@mellanox.com>,
	Jozsef Kadlecsik <kadlec@netfilter.org>,
	Florian Westphal <fw@strlen.de>
Subject: nf_flow on big-endian (was: Re: linux-next: build warning after merge of the net-next tree)
Date: Tue, 26 Nov 2019 12:06:03 +0100
Message-ID: <CAMuHMdX8QyGkpPXfwS0EJhC6hR+gpYfvdpGWqdb=bSwJGmF7Ew@mail.gmail.com> (raw)
In-Reply-To: <20191121183404.6e183d06@canb.auug.org.au>

On Thu, Nov 21, 2019 at 8:36 AM Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> After merging the net-next tree, today's linux-next build (powerpc
> allyesconfig) produced this warning:
>
> net/netfilter/nf_flow_table_offload.c: In function 'nf_flow_rule_match':
> net/netfilter/nf_flow_table_offload.c:80:21: warning: unsigned conversion from 'int' to '__be16' {aka 'short unsigned int'} changes value from '327680' to '0' [-Woverflow]
>    80 |   mask->tcp.flags = TCP_FLAG_RST | TCP_FLAG_FIN;
>       |                     ^~~~~~~~~~~~
>
> Introduced by commit
>
>   c29f74e0df7a ("netfilter: nf_flow_table: hardware offload support")

This is now upstream, and must be completely broken on big-endian
platforms.

The other user of the flags field looks buggy, too
(net/core/flow_dissector.c:__skb_flow_dissect_tcp()[*]):

     key_tcp->flags = (*(__be16 *) &tcp_flag_word(th) & htons(0x0FFF));

Disclaimer: I'm not familiar with the code or protocol, so below are just
my gut feelings.

     struct flow_dissector_key_tcp {
            __be16 flags;
    };

Does this have to be __be16, i.e. does it go over the wire?
If not, this should probably be __u16, and set using
"be32_to_cpu(flags) >> 16"?
If yes, "cpu_to_be16(be32_to_cpu(flags) >> 16)"?
(Ugh, needs convenience macros)

[*] ac4bb5de27010e41 ("net: flow_dissector: add support for dissection
of tcp flags")

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

  reply index

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-21  7:34 linux-next: build warning after merge of the net-next tree Stephen Rothwell
2019-11-26 11:06 ` Geert Uytterhoeven [this message]
2019-12-07 16:41   ` nf_flow on big-endian (was: Re: linux-next: build warning after merge of the net-next tree) Pablo Neira Ayuso
2019-12-08 10:33     ` Geert Uytterhoeven

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='CAMuHMdX8QyGkpPXfwS0EJhC6hR+gpYfvdpGWqdb=bSwJGmF7Ew@mail.gmail.com' \
    --to=geert@linux-m68k.org \
    --cc=davem@davemloft.net \
    --cc=fw@strlen.de \
    --cc=jiri@mellanox.com \
    --cc=kadlec@netfilter.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=sfr@canb.auug.org.au \
    /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

Netdev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netdev/0 netdev/git/0.git
	git clone --mirror https://lore.kernel.org/netdev/1 netdev/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netdev netdev/ https://lore.kernel.org/netdev \
		netdev@vger.kernel.org
	public-inbox-index netdev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netdev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git