Thread (5 messages) flat view 5 messages, 3 authors, 2021-10-05

Re: [PATCH net-next 1/2] ethernet: use eth_hw_addr_set() for dev->addr_len cases

From: Jakub Kicinski <kuba@kernel.org>
Date: 2021-10-04 22:56:45

On Tue, 5 Oct 2021 00:18:45 +0200 Andrew Lunn wrote:
On Mon, Oct 04, 2021 at 09:05:21AM -0700, Jakub Kicinski wrote:
quoted
Convert all Ethernet drivers from memcpy(... dev->addr_len)
to eth_hw_addr_set():

  @@
  expression dev, np;
  @@
  - memcpy(dev->dev_addr, np, dev->addr_len)
  + eth_hw_addr_set(dev, np)  
eth_hw_addr_set() uses ether_addr_copy(), which says:

Please note: dst & src must both be aligned to u16.

memcpy() does not have this restriction. If the source is something
funky, like an EEPROM, it could be oddly aligned.

If you are going to do this, i think the assumption needs removing, a
test added for unaligned addresses and fall back to memcpy().
Thanks for pointing that out, I'll queue up a fix.

At the end of the conversion eth_hw_addr_set() calls dev_addr_set()
which is a memcpy() but I created the former first hence the wrong
ordering.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help