Re: [RFC PATCH net-next 05/10] net: hibmcge: Implement some .ndo functions
From: Andrew Lunn
Date: Thu Aug 01 2024 - 08:19:01 EST
On Thu, Aug 01, 2024 at 05:13:33PM +0800, Jijie Shao wrote:
>
> on 2024/8/1 8:51, Andrew Lunn wrote:
> > > +static int hbg_net_set_mac_address(struct net_device *dev, void *addr)
> > > +{
> > > + struct hbg_priv *priv = netdev_priv(dev);
> > > + u8 *mac_addr;
> > > +
> > > + mac_addr = ((struct sockaddr *)addr)->sa_data;
> > > + if (ether_addr_equal(dev->dev_addr, mac_addr))
> > > + return 0;
> > > +
> > > + if (!is_valid_ether_addr(mac_addr))
> > > + return -EADDRNOTAVAIL;
> > How does the core pass you an invalid MAC address?
>
> According to my test,
> in the 6.4 rc4 kernel version, invalid mac address is allowed to be configured.
> An error is reported only when ifconfig ethx up.
Ah, interesting.
I see a test in __dev_open(), which is what you are saying here. But i
would also expect a test in rtnetlink, or maybe dev_set_mac_address().
We don't want every driver having to repeat this test in their
.ndo_set_mac_address, when it could be done once in the core.
Andrew