netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: Michal Kubecek <mkubecek@suse.cz>, Kevin Easton <kevin@guarana.org>
Cc: davem@davemloft.net, Todd Fujinaka <todd.fujinaka@intel.com>,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com
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	[thread overview]
Message-ID: <13765e905d175d0339a75835b996c82dff806968.camel@intel.com> (raw)
In-Reply-To: <20181108064250.GB24800@unicorn.suse.cz>

[-- Attachment #1: Type: text/plain, Size: 4488 bytes --]

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 <todd.fujinaka@intel.com>
> > > 
> > > 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.
> > > 
> > > Signed-off-by: Todd Fujinaka <todd.fujinaka@intel.com>
> > > Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
> > > Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
> > > ---
> > >  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(-)
> > > 
> > > 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;
> > >  
> > >  	/* only magic packet is supported */
> > > -	if (wol->wolopts && (wol->wolopts != WAKE_MAGIC))
> > > +	if (wol->wolopts && (wol->wolopts != WAKE_MAGIC)
> > > +			  | (wol->wolopts != WAKE_FILTER))
> > >  		return -EOPNOTSUPP;
> > 
> > This doesn't look right.  WAKE_MAGIC and WAKE_FILTER are distinct, so
> > 
> > (wol->wolopts != WAKE_MAGIC) | (wol->wolopts != WAKE_FILTER)
> > 
> > will always be 1.
> 
> 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.
> 
> 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.

> 
> > 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.
> 
> Another way to write the check would be
> 
> 	if (wol->wolopts & ~WAKE_MAGIC)
> 
> > > 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 = netdev_priv(netdev);
> > >  
> > > -	if (wol->wolopts & (WAKE_ARP | WAKE_MAGICSECURE))
> > > +	if (wol->wolopts & (WAKE_ARP | WAKE_MAGICSECURE | WAKE_FILTER))
> > >  		return -EOPNOTSUPP;
> > >  
> > >  	if (!(adapter->flags & IGB_FLAG_WOL_SUPPORTED))
> 
> 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):
> 
> #define SUPPORTED_WOL_MODES \
> 	(WAKE_PHY | WAKE_UCAST | WAKE_MCAST | WAKE_BCAST | WAKE_MAGIC)
> ...
> 	if (wol->wolopts & ~SUPPORTED_WOL_MODES)
> 		return -EOPNOTSUPP;
> 
> 
> > > 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 = netdev_priv(netdev);
> > >  
> > > -	if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE))
> > > +	if (wol->wolopts & (WAKE_PHY | WAKE_ARP | WAKE_MAGICSECURE |
> > > +			    WAKE_FILTER))
> > >  		return -EOPNOTSUPP;
> > >  
> > >  	if (ixgbe_wol_exclusion(adapter, wol))
> 
> ...and here.
> 
> Michal Kubecek


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2018-11-09  7:31 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-07 22:48 [net-next 00/12][pull request] Intel Wired LAN Driver Updates 2018-11-07 Jeff Kirsher
2018-11-07 22:48 ` [net-next 01/12] igbvf: Replace spin_is_locked() with lockdep Jeff Kirsher
2018-11-07 22:48 ` [net-next 02/12] ixgbe: don't clear_bit on xdp_ring->state if xdp_ring is null Jeff Kirsher
2018-11-07 22:48 ` [net-next 03/12] ixgbe: allow IPsec Tx offload in VEPA mode Jeff Kirsher
2018-11-07 22:48 ` [net-next 04/12] ixgbevf: add support for software timestamps Jeff Kirsher
2018-11-07 22:48 ` [net-next 05/12] intel-ethernet: software timestamp skbs as late as possible Jeff Kirsher
2018-11-07 22:48 ` [net-next 06/12] i40e/ixgbe/igb: fail on new WoL flag setting WAKE_MAGICSECURE Jeff Kirsher
2018-11-08  6:05   ` Kevin Easton
2018-11-08  6:42     ` Michal Kubecek
2018-11-08 21:53       ` Jeff Kirsher [this message]
2018-11-07 22:48 ` [net-next 07/12] igc: Remove set but not used variables 'ctrl_ext, link_mode' Jeff Kirsher
2018-11-07 22:48 ` [net-next 08/12] igc: Remove set but not used variable 'pci_using_dac' Jeff Kirsher
2018-11-07 22:48 ` [net-next 09/12] igc: fix error return handling from call to netif_set_real_num_tx_queues Jeff Kirsher
2018-11-07 22:48 ` [net-next 10/12] igc: Tidy up some white space Jeff Kirsher
2018-11-07 22:48 ` [net-next 11/12] e1000e: allow non-monotonic SYSTIM readings Jeff Kirsher
2018-11-07 22:48 ` [net-next 12/12] igc: Clean up code Jeff Kirsher
2018-11-08 11:00   ` Joe Perches
2018-11-08 12:09     ` Neftin, Sasha
2018-11-08  7:07 ` [net-next 00/12][pull request] Intel Wired LAN Driver Updates 2018-11-07 David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=13765e905d175d0339a75835b996c82dff806968.camel@intel.com \
    --to=jeffrey.t.kirsher@intel.com \
    --cc=davem@davemloft.net \
    --cc=kevin@guarana.org \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@redhat.com \
    --cc=sassmann@redhat.com \
    --cc=todd.fujinaka@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).