[PATCH] net: avoid assigning ethaddr to wrong devices

Sascha Hauer sha at pengutronix.de
Mon Jun 25 05:34:33 PDT 2018

Hi Nikita,

On Fri, Jun 22, 2018 at 07:30:12PM +0300, Nikita Yushchenko wrote:
> It can happen that device tree contains ethernetN alias pointing to
> valid device, but that device is not supported by [running instance of]
> barebox. Then ethN remains unassigned, and can be later captured by
> dynamically registered device such as usbnet.
> For such "stranger" device, ethaddr preconfigured for ethN should not be
> assigned. Also, ethaddr of such device should not be written to
> ethernetN node of device tree passed to kernel being booted.

There's only one usecase for matching edev->dev.id against the ethernetx
alias which has been introduced with:

| commit a78431c7fc42193be252417bf06f7cc61765a51e
| Author: Renaud Barbier <renaud.barbier at ge.com>
| Date:   Wed Sep 4 08:37:03 2013 +0200
|     net, of: fixup MAC address by alias
|     If a network device has not been registered from the devicetree, we may
|     still find it by its alias in the devicetree. This way also platform based
|     network devices can obtain a valid MAC address in the devicetree.
|     Signed-off-by: Renaud Barbier <renaud.barbier at ge.com>
|     Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>

Your eth_is_stranger() returns true for the devices that Renaud wanted
to support, so instead of applying your patch we could equally well
revert that from Renaud.

I don't have a good idea right now how to fix this. Maybe we have to
make sure that ethernet devices from dynamic buses never get an id
asigned that is also present in the aliases node.


Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

More information about the barebox mailing list