public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV•linux.org.uk>
To: Rahul Lakkireddy <rahul.lakkireddy@chelsio•com>
Cc: netdev@vger•kernel.org, "David S. Miller" <davem@davemloft•net>
Subject: Re: [endianness bug?] cxgb4_next_header .match_val/.match_mask should be net-endian
Date: Sun, 5 Aug 2018 16:49:49 +0100	[thread overview]
Message-ID: <20180805154949.GG15082@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20180805152811.GF15082@ZenIV.linux.org.uk>

On Sun, Aug 05, 2018 at 04:28:11PM +0100, Al Viro wrote:
> On little-endian host those do yield the right values - e.g. 0x1100 is
> {0, 17, 0, 0}, etc.  On big-endian, though, these will end up checking
> in IPv4 case the octet at offset 10 (i.e. upper 16 bits of checksum) and for IPv6
> - the octet at offset 5 (i.e.  the lower 8 bits of payload length).
> 
> Unless I'm misreading that code, it needs the following to do the right
> thing both on l-e and b-e.  Comments?

... and it looks like the same story with ->mask - it's compared to ->offmask,
which is __be16.  For little-endian hosts the values make sense (htons(0x0f00),
with offoff 0 and shift 6, i.e. "take the first two octets, treat them as
net-endian, clear everything except IHL bits and shift down by 6, which'd
yield IHL*4"), for big-endian they don't - you'd get TOS * 4 instead...

  reply	other threads:[~2018-08-05 17:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-05 15:28 [endianness bug?] cxgb4_next_header .match_val/.match_mask should be net-endian Al Viro
2018-08-05 15:49 ` Al Viro [this message]
2018-08-06 12:12 ` Rahul Lakkireddy
2018-08-06 19:51 ` kbuild test robot
2018-08-06 21:08   ` Al Viro

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=20180805154949.GG15082@ZenIV.linux.org.uk \
    --to=viro@zeniv$(echo .)linux.org.uk \
    --cc=davem@davemloft$(echo .)net \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=rahul.lakkireddy@chelsio$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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