Netdev List
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: Christian Marangi <ansuelsmth@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Pawel Dembicki <paweldembicki@gmail.com>,
	Lech Perczak <lech.perczak@gmail.com>
Subject: Re: [net PATCH 1/2] net: dsa: qca8k: fix inband mgmt for big-endian systems
Date: Wed, 12 Oct 2022 16:31:48 +0300	[thread overview]
Message-ID: <20221012133148.6apqbip3kvnjuafu@skbuf> (raw)
In-Reply-To: <6346ba28.050a0220.f0e18.949b@mx.google.com>

On Wed, Oct 12, 2022 at 02:59:17PM +0200, Christian Marangi wrote:
> > > Humm...
> > > 
> > > This might have the same alignment issue as the second patch. In fact,
> > > because the Ethernet header is 14 bytes in size, it is often
> > > deliberately out of alignment by 2 bytes, so that the IP header is
> > > aligned. You should probably be using get_unaligned_le32() when
> > > accessing members of mgmt_ethhdr.
> > > 
> > > 	  Andrew
> > 
> > Should I replace everything to get_unaligned_le32? Or this is only
> > needed for the mgmt_ethhdr as it's 12 bytes?
> > 
> > The skb data is all 32 bit contiguous stuff so it should be safe? Or
> > should we treat that also as unalligned just to make sure?
> > 
> > Same question for patch 2. the rest of the mib in skb data are all 32 or
> > 64 values contiguous so wonder if we just take extra care of the
> > mgmt_ethhdr. 
> > 
> 
> Also also... Should I use put_unalligned to fill the mgmt_ethhdr?

Documentation/core-api/unaligned-memory-access.rst section "Alignment vs. Networking"
says that the IP header is aligned to a 4 byte boundary.

Relative to the IP header, skb_mac_header(skb) is a pointer that's 14
bytes behind, right?

14 bytes behind something aligned to a 4 byte boundary is something
that's not aligned to a 4 byte boundary. That's why Andrew is suggesting
to use the unaligned helper for accesses (both put and get).

On-stack data structures don't need this, the compiler should take care
of aligning them and their fields appropriately. The trouble is with
pointers generated using manual arithmetics.

      reply	other threads:[~2022-10-12 13:31 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-10 11:14 [net PATCH 1/2] net: dsa: qca8k: fix inband mgmt for big-endian systems Christian Marangi
2022-10-10 11:14 ` [net PATCH 2/2] net: dsa: qca8k: fix ethtool autocast mib " Christian Marangi
2022-10-12 12:37   ` Andrew Lunn
2022-10-10 18:53 ` [net PATCH 1/2] net: dsa: qca8k: fix inband mgmt " Andrew Lunn
2022-10-10 12:44   ` Christian Marangi
2022-10-12  7:24     ` Vladimir Oltean
2022-10-12 12:24       ` Christian Marangi
2022-10-12 12:29     ` Andrew Lunn
2022-10-12 12:34       ` Christian Marangi
2022-10-12  7:27 ` Vladimir Oltean
2022-10-12 12:26   ` Christian Marangi
2022-10-12 12:31 ` Andrew Lunn
2022-10-12 12:42 ` Andrew Lunn
2022-10-12 12:54   ` Christian Marangi
2022-10-12 12:59     ` Christian Marangi
2022-10-12 13:31       ` Vladimir Oltean [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=20221012133148.6apqbip3kvnjuafu@skbuf \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=ansuelsmth@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kuba@kernel.org \
    --cc=lech.perczak@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=paweldembicki@gmail.com \
    --cc=rmk+kernel@armlinux.org.uk \
    --cc=vivien.didelot@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox