Re: [PATCH V9 net-next 11/11] net: add ndo_validate_addr check in dev_set_mac_address

From: Andrew Lunn
Date: Wed Sep 11 2024 - 10:42:54 EST


> This patch may not work as expected.
>
> ndo_validate_addr() has only one parameter.
> The sa parameter of the MAC address is not transferred to the function.
> So ndo_validate_addr() checks the old MAC address, not the new MAC address.

Yes, i agree. The current API does not lend itself to validation
before change.

> I haven't found a better way to fix it yet.

Maybe in dev_set_mac_address(), make a copy of dev->dev_addr. Call
ops->ndo_set_mac_address(). If there is no error call
ndo_validate_addr(). If that returns an error, call
ops->ndo_set_mac_address() again with the old MAC address, and then
return the error from ndo_validate_addr().

It is not great, but it is the best i can think of.

Since this is not as simple i was expecting, feel free to drop it from
your patchset, and submit it as a standalone patch.

Andrew