From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeff Kirsher Subject: Re: [net-next 06/12] i40e/ixgbe/igb: fail on new WoL flag setting WAKE_MAGICSECURE Date: Thu, 08 Nov 2018 13:53:59 -0800 Message-ID: <13765e905d175d0339a75835b996c82dff806968.camel@intel.com> References: <20181107224830.9737-1-jeffrey.t.kirsher@intel.com> <20181107224830.9737-7-jeffrey.t.kirsher@intel.com> <20181108060526.GA11230@ip-172-31-15-78> <20181108064250.GB24800@unicorn.suse.cz> Mime-Version: 1.0 Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-77UiHiBF02rcqtFrabMC" Cc: davem@davemloft.net, Todd Fujinaka , netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com To: Michal Kubecek , Kevin Easton Return-path: Received: from mga06.intel.com ([134.134.136.31]:18758 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726875AbeKIHb0 (ORCPT ); Fri, 9 Nov 2018 02:31:26 -0500 In-Reply-To: <20181108064250.GB24800@unicorn.suse.cz> Sender: netdev-owner@vger.kernel.org List-ID: --=-77UiHiBF02rcqtFrabMC Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, 2018-11-08 at 07:42 +0100, Michal Kubecek wrote: > On Thu, Nov 08, 2018 at 06:05:26AM +0000, Kevin Easton wrote: > > On Wed, Nov 07, 2018 at 02:48:24PM -0800, Jeff Kirsher wrote: > > > From: Todd Fujinaka > > >=20 > > > There's a new flag for setting WoL filters that is only > > > enabled on one manufacturer's NICs, and it's not ours. Fail > > > with EOPNOTSUPP. > > >=20 > > > Signed-off-by: Todd Fujinaka > > > Tested-by: Andrew Bowers > > > Signed-off-by: Jeff Kirsher > > > --- > > > drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 3 ++- > > > drivers/net/ethernet/intel/igb/igb_ethtool.c | 2 +- > > > drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 3 ++- > > > 3 files changed, 5 insertions(+), 3 deletions(-) > > >=20 > > > diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c > > > b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c > > > index 9f8464f80783..9c1211ad2c6b 100644 > > > --- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c > > > +++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c > > > @@ -2377,7 +2377,8 @@ static int i40e_set_wol(struct net_device > > > *netdev, struct ethtool_wolinfo *wol) > > > return -EOPNOTSUPP; > > > =20 > > > /* only magic packet is supported */ > > > - if (wol->wolopts && (wol->wolopts !=3D WAKE_MAGIC)) > > > + if (wol->wolopts && (wol->wolopts !=3D WAKE_MAGIC) > > > + | (wol->wolopts !=3D WAKE_FILTER)) > > > return -EOPNOTSUPP; > >=20 > > This doesn't look right. WAKE_MAGIC and WAKE_FILTER are distinct, so > >=20 > > (wol->wolopts !=3D WAKE_MAGIC) | (wol->wolopts !=3D WAKE_FILTER) > >=20 > > will always be 1. >=20 > Right. Also, using "|" with logical values is rather confusing. While > the result works as expected, its priority is higher than priority of > && (which would not be true for ||), making the code counterintuitive. >=20 > BtW, the patch subject is also wrong, the newly added flag it is dealing > with is WAKE_FILTER, not WAKE_MAGICSECURE. After looking into this this more, this does appear to be incorrect. The author of this change is currently out on vacation, so once he gets back, I will address both Kevin's and your concerns. >=20 > > It looks like the existing test in this driver was fine - it *only* > > accepted wol->wolopts of either 0 or WAKE_MAGIC, it was already > > rejecting everything else including WAKE_FILTER. >=20 > Another way to write the check would be >=20 > if (wol->wolopts & ~WAKE_MAGIC) >=20 > > > diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c > > > b/drivers/net/ethernet/intel/igb/igb_ethtool.c > > > index 5acf3b743876..c57671068245 100644 > > > --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c > > > +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c > > > @@ -2113,7 +2113,7 @@ static int igb_set_wol(struct net_device > > > *netdev, struct ethtool_wolinfo *wol) > > > { > > > struct igb_adapter *adapter =3D netdev_priv(netdev); > > > =20 > > > - if (wol->wolopts & (WAKE_ARP | WAKE_MAGICSECURE)) > > > + if (wol->wolopts & (WAKE_ARP | WAKE_MAGICSECURE | WAKE_FILTER)) > > > return -EOPNOTSUPP; > > > =20 > > > if (!(adapter->flags & IGB_FLAG_WOL_SUPPORTED)) >=20 > I would also suggest taking the opposite approach here, i.e. listing the > flags which _are_ supported so that we don't have to update the code if > another wol flag is added (or userspace sends an invalid one): >=20 > #define SUPPORTED_WOL_MODES \ > (WAKE_PHY | WAKE_UCAST | WAKE_MCAST | WAKE_BCAST | WAKE_MAGIC) > ... > if (wol->wolopts & ~SUPPORTED_WOL_MODES) > return -EOPNOTSUPP; >=20 >=20 > > > diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c > > > b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c > > > index 732b1e6ecc43..acba067cc15a 100644 > > > --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c > > > +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c > > > @@ -2206,7 +2206,8 @@ static int ixgbe_set_wol(struct net_device > > > *netdev, struct ethtool_wolinfo *wol) > > > { > > > struct ixgbe_adapter *adapter =3D netdev_priv(netdev); > > > =20 > > > - if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE)) > > > + if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE | > > > + WAKE_FILTER)) > > > return -EOPNOTSUPP; > > > =20 > > > if (ixgbe_wol_exclusion(adapter, wol)) >=20 > ...and here. >=20 > Michal Kubecek --=-77UiHiBF02rcqtFrabMC Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEiTyZWz+nnTrOJ1LZ5W/vlVpL7c4FAlvksHcACgkQ5W/vlVpL 7c6WyhAAkQCRzMu26HncTplw2Qw96wcbkRmq6ljBOiDR+6fqvLfj9l+suH5z9VLr P2iOyKkTynSDMQ21348uZ4YwmG5ruGu+4TclOXAdlfiZ/Y0/qV0lmk+FLYr3SWB+ Ey5FU7kuGvSB+MoxBhuanyFmIhmbJAue4sIBtMaZSGED3A8bfSLHPOLb/z2hG9/z WMCBS5WXgpnCytouPw855zwqsP7sxh3q02GvPXr9bOvFBQF2s9ZEz/Tw98BL34Ql vrY4kybqkcYkqk5sevm7oYFGnpM6L/3LRexbMlWHLMgTlrOEx3RD4M9QDqUHanUX 9YMq01Hv2t3jZXLcTIX/oC8BxyvBL2ElHfSJl2zZqFxMIS47qer/TbKkPDgXuC8k Hh+BnCn3zPaRzAAvpJ+3LIJUZ7OzmzIW8tBCTFIWlf2e8mf0VxpuzPK9yBp8mAo5 hHxbHXMSdtiQomrywQ8LO+lEB3ntF0P5r/N1DDsciB4Ipsg/5GCnwxhjpKBaI9BA 7ojElhNOdymUmYZtAbK/FjCFO+zavOab7az7su+kNvAsLDEQ+++HY04OGYyzbv7J 6Wk/6NirjlG1w95b40r5guRp3s1AdcMhVXcgVkcrRuTlIqBfifsleWH+hB1X30IB 0T2361lvJUGi3w/xOpwS1qdekk/97pUwrlz4uO0s1rkmPLUqBhg= =W1Jg -----END PGP SIGNATURE----- --=-77UiHiBF02rcqtFrabMC--