From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Jakub Sitnicki <jakub@cloudflare.com>
Cc: Alexander Lobakin <alobakin@pm.me>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andriin@fb.com>,
Davide Caratti <dcaratti@redhat.com>,
Guillaume Nault <gnault@redhat.com>, wenxu <wenxu@ucloud.cn>,
Eran Ben Elisha <eranbe@nvidia.com>,
Matteo Croce <mcroce@redhat.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH net] flow_dissector: fix byteorder of dissected ICMP ID
Date: Sun, 14 Mar 2021 20:44:49 +0000 [thread overview]
Message-ID: <20210314204449.6ogfogeiqfwwqfso@skbuf> (raw)
In-Reply-To: <87wnu932qz.fsf@cloudflare.com>
On Sun, Mar 14, 2021 at 09:21:40PM +0100, Jakub Sitnicki wrote:
> On Fri, Mar 12, 2021 at 09:08 PM CET, Alexander Lobakin wrote:
> > flow_dissector_key_icmp::id is of type u16 (CPU byteorder),
> > ICMP header has its ID field in network byteorder obviously.
> > Sparse says:
> >
> > net/core/flow_dissector.c:178:43: warning: restricted __be16 degrades to integer
> >
> > Convert ID value to CPU byteorder when storing it into
> > flow_dissector_key_icmp.
> >
> > Fixes: 5dec597e5cd0 ("flow_dissector: extract more ICMP information")
> > Signed-off-by: Alexander Lobakin <alobakin@pm.me>
> > ---
> > net/core/flow_dissector.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
> > index 2ef2224b3bff..a96a4f5de0ce 100644
> > --- a/net/core/flow_dissector.c
> > +++ b/net/core/flow_dissector.c
> > @@ -176,7 +176,7 @@ void skb_flow_get_icmp_tci(const struct sk_buff *skb,
> > * avoid confusion with packets without such field
> > */
> > if (icmp_has_id(ih->type))
> > - key_icmp->id = ih->un.echo.id ? : 1;
> > + key_icmp->id = ih->un.echo.id ? ntohs(ih->un.echo.id) : 1;
> > else
> > key_icmp->id = 0;
> > }
>
> Smells like a breaking change for existing consumers of this value.
>
> How about we change the type of flow_dissector_key_icmp{}.id to __be16
> instead to make sparse happy?
The struct flow_dissector_key_icmp::id only appears to be used in
bond_xmit_hash, and there, the exact value doesn't seem to matter.
This appears to be a real bug and not just to appease sparse:
ih->un.echo.id has one endianness and "1" has another. Both cannot
be correct.
next prev parent reply other threads:[~2021-03-14 20:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-12 20:08 [PATCH net] flow_dissector: fix byteorder of dissected ICMP ID Alexander Lobakin
2021-03-14 20:21 ` Jakub Sitnicki
2021-03-14 20:44 ` Vladimir Oltean [this message]
2021-03-14 21:31 ` David Miller
2021-03-14 22:40 ` patchwork-bot+netdevbpf
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=20210314204449.6ogfogeiqfwwqfso@skbuf \
--to=vladimir.oltean@nxp.com \
--cc=alobakin@pm.me \
--cc=andriin@fb.com \
--cc=ast@kernel.org \
--cc=davem@davemloft.net \
--cc=dcaratti@redhat.com \
--cc=eranbe@nvidia.com \
--cc=gnault@redhat.com \
--cc=jakub@cloudflare.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcroce@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=wenxu@ucloud.cn \
/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).