Skip to content
This repository has been archived by the owner on Dec 14, 2022. It is now read-only.

Commit

Permalink
net: core: 'ethtool' issue with querying phy settings
Browse files Browse the repository at this point in the history
When trying to configure the settings for PHY1, using commands
like 'ethtool -s eth0 phyad 1 speed 100', the 'ethtool' seems to
modify other settings apart from the speed of the PHY1, in the
above case.

The ethtool seems to query the settings for PHY0, and use this
as the base to apply the new settings to the PHY1. This is
causing the other settings of the PHY 1 to be wrongly
configured.

The issue is caused by the '_ethtool_get_settings()' API, which
gets called because of the 'ETHTOOL_GSET' command, is clearing
the 'cmd' pointer (of type 'struct ethtool_cmd') by calling
memset. This clears all the parameters (if any) passed for the
'ETHTOOL_GSET' cmd. So the driver's callback is always invoked
with 'cmd->phy_address' as '0'.

The '_ethtool_get_settings()' is called from other files in the
'net/core'. So the fix is applied to the 'ethtool_get_settings()'
which is only called in the context of the 'ethtool'.

Signed-off-by: Arun Parameswaran <[email protected]>
Reviewed-by: Ray Jui <[email protected]>
Reviewed-by: Scott Branden <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Arun Parameswaran authored and davem330 committed May 22, 2015
1 parent 47cc84c commit f96dee1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion net/core/ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,15 @@ static int ethtool_get_settings(struct net_device *dev, void __user *useraddr)
int err;
struct ethtool_cmd cmd;

err = __ethtool_get_settings(dev, &cmd);
if (!dev->ethtool_ops->get_settings)
return -EOPNOTSUPP;

if (copy_from_user(&cmd, useraddr, sizeof(cmd)))
return -EFAULT;

cmd.cmd = ETHTOOL_GSET;

err = dev->ethtool_ops->get_settings(dev, &cmd);
if (err < 0)
return err;

Expand Down

0 comments on commit f96dee1

Please sign in to comment.