* [PATCH net-next] net: fix net device address assign type
@ 2023-06-21 13:21 Piotr Gardocki
2023-06-22 6:37 ` Simon Horman
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Piotr Gardocki @ 2023-06-21 13:21 UTC (permalink / raw)
To: netdev
Cc: piotrx.gardocki, intel-wired-lan, przemyslaw.kitszel,
michal.swiatkowski, pmenzel, kuba, maciej.fijalkowski,
anthony.l.nguyen, simon.horman, aleksander.lobakin, gal
Commit ad72c4a06acc introduced optimization to return from function
quickly if the MAC address is not changing at all. It was reported
that such change causes dev->addr_assign_type to not change
to NET_ADDR_SET from _PERM or _RANDOM.
Restore the old behavior and skip only call to ndo_set_mac_address.
Fixes: ad72c4a06acc ("net: add check for current MAC address in dev_set_mac_address")
Reported-by: Gal Pressman <gal@nvidia.com>
Signed-off-by: Piotr Gardocki <piotrx.gardocki@intel.com>
---
net/core/dev.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index e4ff0adf5523..69a3e544676c 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -8781,14 +8781,14 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa,
return -EINVAL;
if (!netif_device_present(dev))
return -ENODEV;
- if (!memcmp(dev->dev_addr, sa->sa_data, dev->addr_len))
- return 0;
err = dev_pre_changeaddr_notify(dev, sa->sa_data, extack);
if (err)
return err;
- err = ops->ndo_set_mac_address(dev, sa);
- if (err)
- return err;
+ if (memcmp(dev->dev_addr, sa->sa_data, dev->addr_len)) {
+ err = ops->ndo_set_mac_address(dev, sa);
+ if (err)
+ return err;
+ }
dev->addr_assign_type = NET_ADDR_SET;
call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
add_device_randomness(dev->dev_addr, dev->addr_len);
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] net: fix net device address assign type
2023-06-21 13:21 [PATCH net-next] net: fix net device address assign type Piotr Gardocki
@ 2023-06-22 6:37 ` Simon Horman
2023-06-22 8:22 ` Jiri Pirko
2023-06-23 3:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 6+ messages in thread
From: Simon Horman @ 2023-06-22 6:37 UTC (permalink / raw)
To: Piotr Gardocki
Cc: netdev, intel-wired-lan, przemyslaw.kitszel, michal.swiatkowski,
pmenzel, kuba, maciej.fijalkowski, anthony.l.nguyen,
aleksander.lobakin, gal
On Wed, Jun 21, 2023 at 03:21:06PM +0200, Piotr Gardocki wrote:
> Commit ad72c4a06acc introduced optimization to return from function
> quickly if the MAC address is not changing at all. It was reported
> that such change causes dev->addr_assign_type to not change
> to NET_ADDR_SET from _PERM or _RANDOM.
> Restore the old behavior and skip only call to ndo_set_mac_address.
>
> Fixes: ad72c4a06acc ("net: add check for current MAC address in dev_set_mac_address")
> Reported-by: Gal Pressman <gal@nvidia.com>
> Signed-off-by: Piotr Gardocki <piotrx.gardocki@intel.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] net: fix net device address assign type
2023-06-21 13:21 [PATCH net-next] net: fix net device address assign type Piotr Gardocki
2023-06-22 6:37 ` Simon Horman
@ 2023-06-22 8:22 ` Jiri Pirko
2023-06-22 12:42 ` Piotr Gardocki
2023-06-23 3:00 ` patchwork-bot+netdevbpf
2 siblings, 1 reply; 6+ messages in thread
From: Jiri Pirko @ 2023-06-22 8:22 UTC (permalink / raw)
To: Piotr Gardocki
Cc: netdev, intel-wired-lan, przemyslaw.kitszel, michal.swiatkowski,
pmenzel, kuba, maciej.fijalkowski, anthony.l.nguyen, simon.horman,
aleksander.lobakin, gal
Wed, Jun 21, 2023 at 03:21:06PM CEST, piotrx.gardocki@intel.com wrote:
>Commit ad72c4a06acc introduced optimization to return from function
Out of curiosity, what impact does this optimization have? Is it worth
it to have such optimization at all? Wouldn't simple revert of the fixes
commit do the trick? If not, see below.
>quickly if the MAC address is not changing at all. It was reported
>that such change causes dev->addr_assign_type to not change
>to NET_ADDR_SET from _PERM or _RANDOM.
>Restore the old behavior and skip only call to ndo_set_mac_address.
>
>Fixes: ad72c4a06acc ("net: add check for current MAC address in dev_set_mac_address")
>Reported-by: Gal Pressman <gal@nvidia.com>
>Signed-off-by: Piotr Gardocki <piotrx.gardocki@intel.com>
>---
> net/core/dev.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
>diff --git a/net/core/dev.c b/net/core/dev.c
>index e4ff0adf5523..69a3e544676c 100644
>--- a/net/core/dev.c
>+++ b/net/core/dev.c
>@@ -8781,14 +8781,14 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa,
> return -EINVAL;
> if (!netif_device_present(dev))
> return -ENODEV;
>- if (!memcmp(dev->dev_addr, sa->sa_data, dev->addr_len))
>- return 0;
> err = dev_pre_changeaddr_notify(dev, sa->sa_data, extack);
> if (err)
> return err;
>- err = ops->ndo_set_mac_address(dev, sa);
>- if (err)
>- return err;
>+ if (memcmp(dev->dev_addr, sa->sa_data, dev->addr_len)) {
>+ err = ops->ndo_set_mac_address(dev, sa);
>+ if (err)
>+ return err;
>+ }
> dev->addr_assign_type = NET_ADDR_SET;
> call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
Although I don't think the notifiers here and
dev_pre_changeaddr_notify() above have to be called in case the address
didn't actually change, it restores the old behaviour, even with the
netlink notification, which is probably good.
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
> add_device_randomness(dev->dev_addr, dev->addr_len);
>--
>2.34.1
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] net: fix net device address assign type
2023-06-22 8:22 ` Jiri Pirko
@ 2023-06-22 12:42 ` Piotr Gardocki
2023-06-22 13:37 ` Jiri Pirko
0 siblings, 1 reply; 6+ messages in thread
From: Piotr Gardocki @ 2023-06-22 12:42 UTC (permalink / raw)
To: Jiri Pirko
Cc: netdev, intel-wired-lan, przemyslaw.kitszel, michal.swiatkowski,
pmenzel, kuba, maciej.fijalkowski, anthony.l.nguyen, simon.horman,
aleksander.lobakin, gal
On 22.06.2023 10:22, Jiri Pirko wrote:
> Wed, Jun 21, 2023 at 03:21:06PM CEST, piotrx.gardocki@intel.com wrote:
>> Commit ad72c4a06acc introduced optimization to return from function
>
> Out of curiosity, what impact does this optimization have? Is it worth
> it to have such optimization at all? Wouldn't simple revert of the fixes
> commit do the trick? If not, see below.
Thanks for review. My main goal originally was to skip call to ndo_set_mac_address.
The benefit of this depends on how given driver handles such request. Some drivers
notify their hardware about the "change", iavf for example sends a request to PF
driver (and awaits for response). i40e and ice already had this check (I removed
them in previous patch set) and we wanted to also introduce it in iavf. But it
was suggested to move this check to core to have benefit for all drivers.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] net: fix net device address assign type
2023-06-22 12:42 ` Piotr Gardocki
@ 2023-06-22 13:37 ` Jiri Pirko
0 siblings, 0 replies; 6+ messages in thread
From: Jiri Pirko @ 2023-06-22 13:37 UTC (permalink / raw)
To: Piotr Gardocki
Cc: netdev, intel-wired-lan, przemyslaw.kitszel, michal.swiatkowski,
pmenzel, kuba, maciej.fijalkowski, anthony.l.nguyen, simon.horman,
aleksander.lobakin, gal
Thu, Jun 22, 2023 at 02:42:53PM CEST, piotrx.gardocki@intel.com wrote:
>On 22.06.2023 10:22, Jiri Pirko wrote:
>> Wed, Jun 21, 2023 at 03:21:06PM CEST, piotrx.gardocki@intel.com wrote:
>>> Commit ad72c4a06acc introduced optimization to return from function
>>
>> Out of curiosity, what impact does this optimization have? Is it worth
>> it to have such optimization at all? Wouldn't simple revert of the fixes
>> commit do the trick? If not, see below.
>
>Thanks for review. My main goal originally was to skip call to ndo_set_mac_address.
>The benefit of this depends on how given driver handles such request. Some drivers
>notify their hardware about the "change", iavf for example sends a request to PF
>driver (and awaits for response). i40e and ice already had this check (I removed
>them in previous patch set) and we wanted to also introduce it in iavf. But it
>was suggested to move this check to core to have benefit for all drivers.
Okay. Makes sense.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] net: fix net device address assign type
2023-06-21 13:21 [PATCH net-next] net: fix net device address assign type Piotr Gardocki
2023-06-22 6:37 ` Simon Horman
2023-06-22 8:22 ` Jiri Pirko
@ 2023-06-23 3:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-06-23 3:00 UTC (permalink / raw)
To: Piotr Gardocki
Cc: netdev, intel-wired-lan, przemyslaw.kitszel, michal.swiatkowski,
pmenzel, kuba, maciej.fijalkowski, anthony.l.nguyen, simon.horman,
aleksander.lobakin, gal
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 21 Jun 2023 15:21:06 +0200 you wrote:
> Commit ad72c4a06acc introduced optimization to return from function
> quickly if the MAC address is not changing at all. It was reported
> that such change causes dev->addr_assign_type to not change
> to NET_ADDR_SET from _PERM or _RANDOM.
> Restore the old behavior and skip only call to ndo_set_mac_address.
>
> Fixes: ad72c4a06acc ("net: add check for current MAC address in dev_set_mac_address")
> Reported-by: Gal Pressman <gal@nvidia.com>
> Signed-off-by: Piotr Gardocki <piotrx.gardocki@intel.com>
>
> [...]
Here is the summary with links:
- [net-next] net: fix net device address assign type
https://git.kernel.org/netdev/net-next/c/0ec92a8f56ff
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-06-23 3:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-21 13:21 [PATCH net-next] net: fix net device address assign type Piotr Gardocki
2023-06-22 6:37 ` Simon Horman
2023-06-22 8:22 ` Jiri Pirko
2023-06-22 12:42 ` Piotr Gardocki
2023-06-22 13:37 ` Jiri Pirko
2023-06-23 3:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).