lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 6 Oct 2021 05:59:25 -0700
From:   Jakub Kicinski <kuba@...nel.org>
To:     Heikki Krogerus <heikki.krogerus@...ux.intel.com>
Cc:     davem@...emloft.net, netdev@...r.kernel.org,
        gregkh@...uxfoundation.org, rafael@...nel.org, andrew@...n.ch,
        hkallweit1@...il.com, linux@...linux.org.uk, robh+dt@...nel.org,
        frowand.list@...il.com, devicetree@...r.kernel.org
Subject: Re: [PATCH net-next 3/4] device property: add a helper for loading
 netdev->dev_addr

On Wed, 6 Oct 2021 10:43:13 +0300 Heikki Krogerus wrote:
> On Tue, Oct 05, 2021 at 08:53:20AM -0700, Jakub Kicinski wrote:
> > Commit 406f42fa0d3c ("net-next: When a bond have a massive amount
> > of VLANs...") introduced a rbtree for faster Ethernet address look
> > up. To maintain netdev->dev_addr in this tree we need to make all
> > the writes to it got through appropriate helpers.
> > 
> > There is a handful of drivers which pass netdev->dev_addr as
> > the destination buffer to device_get_mac_address(). Add a helper
> > which takes a dev pointer instead, so it can call an appropriate
> > helper.
> > 
> > Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> > ---
> >  drivers/base/property.c  | 20 ++++++++++++++++++++
> >  include/linux/property.h |  2 ++
> >  2 files changed, 22 insertions(+)
> > 
> > diff --git a/drivers/base/property.c b/drivers/base/property.c
> > index 453918eb7390..1c8d4676addc 100644
> > --- a/drivers/base/property.c
> > +++ b/drivers/base/property.c
> > @@ -997,6 +997,26 @@ void *device_get_mac_address(struct device *dev, char *addr, int alen)
> >  }
> >  EXPORT_SYMBOL(device_get_mac_address);
> >  
> > +/**
> > + * device_get_ethdev_addr - Set netdev's MAC address from a given device
> > + * @dev:	Pointer to the device
> > + * @netdev:	Pointer to netdev to write the address to
> > + *
> > + * Wrapper around device_get_mac_address() which writes the address
> > + * directly to netdev->dev_addr.
> > + */
> > +void *device_get_ethdev_addr(struct device *dev, struct net_device *netdev)
> > +{
> > +	u8 addr[ETH_ALEN];
> > +	void *ret;
> > +
> > +	ret = device_get_mac_address(dev, addr, ETH_ALEN);
> > +	if (ret)
> > +		eth_hw_addr_set(netdev, addr);
> > +	return ret;
> > +}
> > +EXPORT_SYMBOL(device_get_ethdev_addr);  
> 
> Is there some reason why can't this be in net/ethernet/eth.c?
> 
> I would really prefer that we don't add any more subsystem specific
> functions into this file (drivers/base/property.c).

Sure.

> Shouldn't actually fwnode_get_mac_addr() and fwnode_get_mac_address()
> be moved to net/ethernet/eth.c as well?

Fine by me, there's already a handful of such helpers there. 

I'll add the refactoring I posted as a RFC to the series as well:

https://lore.kernel.org/all/20211006022444.3155482-1-kuba@kernel.org/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ