All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ethtool: do not set some flags, if others failed
@ 2010-02-27  7:43 Jeff Garzik
  2010-02-28  9:40 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Jeff Garzik @ 2010-02-27  7:43 UTC (permalink / raw)
  To: netdev


NETIF_F_NTUPLE flag setting introduced a bug:  non-ntuple flags
like LRO may be successfully set, before ioctl(2) returns failure
to userspace.

The set-flags operation should be all-or-none, rather than leaving
things in an inconsistent state prior to reporting failure to
userspace.

Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
---
 net/core/ethtool.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 31b1edd..0f2f821 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -135,21 +135,23 @@ u32 ethtool_op_get_flags(struct net_device *dev)
 int ethtool_op_set_flags(struct net_device *dev, u32 data)
 {
 	const struct ethtool_ops *ops = dev->ethtool_ops;
+	unsigned long features = dev->features;
 
 	if (data & ETH_FLAG_LRO)
-		dev->features |= NETIF_F_LRO;
+		features |= NETIF_F_LRO;
 	else
-		dev->features &= ~NETIF_F_LRO;
+		features &= ~NETIF_F_LRO;
 
 	if (data & ETH_FLAG_NTUPLE) {
 		if (!ops->set_rx_ntuple)
 			return -EOPNOTSUPP;
-		dev->features |= NETIF_F_NTUPLE;
+		features |= NETIF_F_NTUPLE;
 	} else {
 		/* safe to clear regardless */
-		dev->features &= ~NETIF_F_NTUPLE;
+		features &= ~NETIF_F_NTUPLE;
 	}
 
+	dev->features = features;
 	return 0;
 }
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ethtool: do not set some flags, if others failed
  2010-02-27  7:43 [PATCH] ethtool: do not set some flags, if others failed Jeff Garzik
@ 2010-02-28  9:40 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2010-02-28  9:40 UTC (permalink / raw)
  To: jeff; +Cc: netdev

From: Jeff Garzik <jeff@garzik.org>
Date: Sat, 27 Feb 2010 02:43:38 -0500

> 
> NETIF_F_NTUPLE flag setting introduced a bug:  non-ntuple flags
> like LRO may be successfully set, before ioctl(2) returns failure
> to userspace.
> 
> The set-flags operation should be all-or-none, rather than leaving
> things in an inconsistent state prior to reporting failure to
> userspace.
> 
> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>

Applied, thanks Jeff.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-28  9:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-27  7:43 [PATCH] ethtool: do not set some flags, if others failed Jeff Garzik
2010-02-28  9:40 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.