Skip to content

Commit

Permalink
ethtool: do not set some flags, if others failed
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Jeff Garzik authored and davem330 committed Feb 28, 2010
1 parent 6c74651 commit 9675478
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions net/core/ethtool.c
Original file line number Diff line number Diff line change
@@ -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;
}

0 comments on commit 9675478

Please sign in to comment.