net: usb: Check for Wake-on-LAN modes
Subsystems (7)
cover net: usb: Check for Wake-on-LAN modes
Hi all,
Most of our USB Ethernet drivers don't seem to be checking properly whether the user is supplying a correct Wake-on-LAN mode to enter, so the experience as an user could be confusing, since it would generally lead to either no wake-up, or the device not being marked for wake-up.
Please review!
Florian Fainelli (7):
asix: Check for supported Wake-on-LAN modes
ax88179_178a: Check for supported Wake-on-LAN modes
lan78xx: Check for supported Wake-on-LAN modes
sr9800: Check for supported Wake-on-LAN modes
r8152: Check for supported Wake-on-LAN Modes
smsc75xx: Check for Wake-on-LAN modes
smsc95xx: Check for Wake-on-LAN modes
drivers/net/usb/asix_common.c | 3 +++ drivers/net/usb/ax88179_178a.c | 3 +++ drivers/net/usb/lan78xx.c | 3 +++ drivers/net/usb/r8152.c | 3 +++ drivers/net/usb/smsc75xx.c | 3 +++ drivers/net/usb/smsc95xx.c | 3 +++ drivers/net/usb/sr9800.c | 3 +++ 7 files changed, 21 insertions(+)
Signature · 1 line
2.17.1
PATCH 1/7 asix: Check for supported Wake-on-LAN modes
The driver currently silently accepts unsupported Wake-on-LAN modes (other than WAKE_PHY or WAKE_MAGIC) without reporting that to the user, which is confusing.
--- drivers/net/usb/asix_common.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/usb/asix_common.c +3 -0
@@ -607,6 +607,9 @@ int asix_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)struct usbnet *dev =netdev_priv (net);u8 opt =0 ; +if (wolinfo->wolopts & ~(WAKE_PHY |WAKE_MAGIC )) +return -EINVAL ; +if (wolinfo->wolopts &WAKE_PHY ) opt |=AX_MONITOR_LINK ;if (wolinfo->wolopts &WAKE_MAGIC )
PATCH 2/7 ax88179_178a: Check for supported Wake-on-LAN modes
In reply to Florian FainelliThe driver currently silently accepts unsupported Wake-on-LAN modes (other than WAKE_PHY or WAKE_MAGIC) without reporting that to the user, which is confusing.
--- drivers/net/usb/ax88179_178a.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/usb/ax88179_178a.c +3 -0
@@ -566,6 +566,9 @@ ax88179_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)struct usbnet *dev =netdev_priv (net);u8 opt =0 ; +if (wolinfo->wolopts & ~(WAKE_PHY |WAKE_MAGIC )) +return -EINVAL ; +if (wolinfo->wolopts &WAKE_PHY ) opt |=AX_MONITOR_MODE_RWLC ;if (wolinfo->wolopts &WAKE_MAGIC )
PATCH 3/7 lan78xx: Check for supported Wake-on-LAN modes
In reply to Florian FainelliThe driver supports a fair amount of Wake-on-LAN modes, but is not checking that the user specified one that is supported.
--- drivers/net/usb/lan78xx.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/usb/lan78xx.c +3 -0
@@ -1415,6 +1415,9 @@ static int lan78xx_set_wol(struct net_device *netdev,if (wol->wolopts &WAKE_ARP ) pdata->wol |=WAKE_ARP ; +if (pdata->wol ==0 ) +return -EINVAL ; +device_set_wakeup_enable (&dev->udev->dev, (bool )wol->wolopts);phy_ethtool_set_wol (netdev->phydev, wol);
PATCH 4/7 sr9800: Check for supported Wake-on-LAN modes
In reply to Florian FainelliThe driver currently silently accepts unsupported Wake-on-LAN modes (other than WAKE_PHY or WAKE_MAGIC) without reporting that to the user, which is confusing.
--- drivers/net/usb/sr9800.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/usb/sr9800.c +3 -0
@@ -421,6 +421,9 @@ sr_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)struct usbnet *dev =netdev_priv (net);u8 opt =0 ; +if (wolinfo->wolopts & ~(WAKE_PHY |WAKE_MAGIC )) +return -EINVAL ; +if (wolinfo->wolopts &WAKE_PHY ) opt |=SR_MONITOR_LINK ;if (wolinfo->wolopts &WAKE_MAGIC )
PATCH 5/7 r8152: Check for supported Wake-on-LAN Modes
In reply to Florian FainelliThe driver does not check for Wake-on-LAN modes specified by an user, but will conditionally set the device as wake-up enabled or not based on that, which could be a very confusing user experience.
--- drivers/net/usb/r8152.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/usb/r8152.c +3 -0
@@ -4506,6 +4506,9 @@ static int rtl8152_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)if (!rtl_can_wakeup (tp))return -EOPNOTSUPP ; +if (wol->wolopts & ~WAKE_ANY ) +return -EINVAL ; + ret =usb_autopm_get_interface (tp->intf);if (ret <0 ) goto out_set_wol;
PATCH 6/7 smsc75xx: Check for Wake-on-LAN modes
In reply to Florian FainelliThe driver does not check for Wake-on-LAN modes specified by an user, but will conditionally set the device as wake-up enabled or not based on that, which could be a very confusing user experience.
--- drivers/net/usb/smsc75xx.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/usb/smsc75xx.c +3 -0
@@ -731,6 +731,9 @@ static int smsc75xx_ethtool_set_wol(struct net_device *net,struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0 ]);int ret; +if (wolinfo->wolopts & ~SUPPORTED_WAKE ) +return -EINVAL ; + pdata->wolopts = wolinfo->wolopts &SUPPORTED_WAKE ; ret =device_set_wakeup_enable (&dev->udev->dev, pdata->wolopts);
PATCH 7/7 smsc95xx: Check for Wake-on-LAN modes
In reply to Florian FainelliThe driver does not check for Wake-on-LAN modes specified by an user, but will conditionally set the device as wake-up enabled or not based on that, which could be a very confusing user experience.
--- drivers/net/usb/smsc95xx.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/usb/smsc95xx.c +3 -0
@@ -774,6 +774,9 @@ static int smsc95xx_ethtool_set_wol(struct net_device *net,struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0 ]);int ret; +if (wolinfo->wolopts & ~SUPPORTED_WAKE ) +return -EINVAL ; + pdata->wolopts = wolinfo->wolopts &SUPPORTED_WAKE ; ret =device_set_wakeup_enable (&dev->udev->dev, pdata->wolopts);
RE: [PATCH net 3/7] lan78xx: Check for supported Wake-on-LAN modes
In reply to Florian FainelliHi Florian,
drivers/net/usb/lan78xx.c static int lan78xx_set_wol(struct net_device *netdev, · line 1420
Quoted 7 lines
drivers/net/usb/lan78xx.c +3
-0@@ -1415,6 +1415,9 @@ static int lan78xx_set_wol(struct net_device *netdev,if (wol->wolopts &WAKE_ARP ) pdata->wol |=WAKE_ARP ; +if (pdata->wol ==0 ) +return -EINVAL ; +
It will make function return when disabling WOL.
Is there other place handling this scenario?
drivers/net/usb/lan78xx.c static int lan78xx_set_wol(struct net_device *netdev, · line 1423
Quoted 3 lines
drivers/net/usb/lan78xx.c +0
-0device_set_wakeup_enable (&dev->udev->dev, (bool )wol->wolopts);phy_ethtool_set_wol (netdev->phydev, wol);
Thanks.
Woojung
Re: [PATCH net 3/7] lan78xx: Check for supported Wake-on-LAN modes
Quoted 10 lines · On 09/25/2018 10:19 AM, [email protected] wrote:
Hi Florian,
drivers/net/usb/lan78xx.c static int lan78xx_set_wol(struct net_device *netdev, · line 1420
Quoted 7 lines
drivers/net/usb/lan78xx.c +3
-0@@ -1415,6 +1415,9 @@ static int lan78xx_set_wol(struct net_device *netdev,if (wol->wolopts &WAKE_ARP ) pdata->wol |=WAKE_ARP ; +if (pdata->wol ==0 ) +return -EINVAL ; +It will make function return when disabling WOL.
Huh, yes, good point.
Quoted 1 line
Is there other place handling this scenario?
How do you mean?
Quoted 9 lines
drivers/net/usb/lan78xx.c static int lan78xx_set_wol(struct net_device *netdev, · line 1423
Quoted 4 lines
drivers/net/usb/lan78xx.c +0
-0device_set_wakeup_enable (&dev->udev->dev, (bool )wol->wolopts);phy_ethtool_set_wol (netdev->phydev, wol);Thanks.
Woojung
RE: [PATCH net 3/7] lan78xx: Check for supported Wake-on-LAN modes
Hi Florian,
Quoted 11 lines
Quoted 4 lines
drivers/net/usb/lan78xx.c static int lan78xx_set_wol(struct net_device *netdev, · line 1420
Quoted 3 lines
drivers/net/usb/lan78xx.c +3
-0+if (pdata->wol ==0 ) +return -EINVAL ; +It will make function return when disabling WOL.
Huh, yes, good point.
Quoted 1 line
Is there other place handling this scenario?
How do you mean?
I meant there is another path I might miss when disabling WOL than this xxx_set_wol().
Thanks
Woojung
Re: [PATCH net 3/7] lan78xx: Check for supported Wake-on-LAN modes
Quoted 7 lines · On 09/25/2018 10:32 AM, [email protected] wrote:
Hi Florian,
Quoted 5 lines
Quoted 4 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+ if (pdata->wol == 0) + return -EINVAL; +It will make function return when disabling WOL.
Quoted 8 lines
Quoted 6 lines
Huh, yes, good point.
Quoted 1 line
Is there other place handling this scenario?
How do you mean?
I meant there is another path I might miss when disabling WOL than this
xxx_set_wol().
I don't think so, at least not from the ethtool perspective, this should fix the issue before, and simplifying the code, since all we are doing it taking a bitmask, checking each bit we support, and again, make it the same bitmask in pdata->wol, can you test that? If you have a new enough version of ethtool, try using: ethtool -s <iface> wol f, which was added recently and which this driver does not support:
drivers/net/usb/lan78xx.c +0 -0
@@ -1401,19 +1401,10 @@ static int lan78xx_set_wol(struct net_device
*netdev,
if (ret < 0)
return ret;- pdata->wol = 0;
- if (wol->wolopts & WAKE_UCAST)
- pdata->wol |= WAKE_UCAST;
- if (wol->wolopts & WAKE_MCAST)
- pdata->wol |= WAKE_MCAST;
- if (wol->wolopts & WAKE_BCAST)
- pdata->wol |= WAKE_BCAST;
- if (wol->wolopts & WAKE_MAGIC)
- pdata->wol |= WAKE_MAGIC;
- if (wol->wolopts & WAKE_PHY)
- pdata->wol |= WAKE_PHY;
- if (wol->wolopts & WAKE_ARP)
- pdata->wol |= WAKE_ARP;
+ if (pdata->wol & ~WAKE_ALL)
+ return -EINVAL;
+
+ pdata->wol = wol->wolopts;
device_set_wakeup_enable(&dev->udev->dev, (bool)wol->wolopts);
RE: [PATCH net 3/7] lan78xx: Check for supported Wake-on-LAN modes
Hi Florian,
Quoted 1 line
(quoted diff) +0
-0@@ -1401,19 +1401,10 @@ static int lan78xx_set_wol(struct net_device
...
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (pdata->wol & ~WAKE_ALL) + return -EINVAL;
If I understand correctly, it needs to check againt "wol->wolopts" than pdata->wol.
Review
Quoted 2 lines
(quoted diff) +2
-0+ + pdata->wol = wol->wolopts;
Thanks.
Woojung
David Miller
maintainerFrom: Florian Fainelli <[email protected]>
Date: Mon, 24 Sep 2018 13:54:13 -0700
Quoted 6 lines
Most of our USB Ethernet drivers don't seem to be checking properly whether the user is supplying a correct Wake-on-LAN mode to enter, so the experience as an user could be confusing, since it would generally lead to either no wake-up, or the device not being marked for wake-up.
Please review!
I saw some discussion on patch #3, is there going to be a new version of this series or should I apply this one?
Thanks.
Quoted 8 lines · David Miller
From: Florian Fainelli <[email protected]>
Date: Mon, 24 Sep 2018 13:54:13 -0700Quoted 5 lines
Most of our USB Ethernet drivers don't seem to be checking properly whether the user is supplying a correct Wake-on-LAN mode to enter, so the experience as an user could be confusing, since it would generally lead to either no wake-up, or the device not being marked for wake-up.
Quoted 4 lines
Quoted 1 line
Please review!
I saw some discussion on patch #3, is there going to be a new version of this series or should I apply this one?
I will be sending a v2, please discard this one, thanks!
Signature · 1 line
Florian