Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9675478b authored by Jeff Garzik's avatar Jeff Garzik Committed by David S. Miller
Browse files

ethtool: do not set some flags, if others failed



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: default avatarJeff Garzik <jgarzik@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6c74651c
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -135,21 +135,23 @@ u32 ethtool_op_get_flags(struct net_device *dev)
int ethtool_op_set_flags(struct net_device *dev, u32 data)
int ethtool_op_set_flags(struct net_device *dev, u32 data)
{
{
	const struct ethtool_ops *ops = dev->ethtool_ops;
	const struct ethtool_ops *ops = dev->ethtool_ops;
	unsigned long features = dev->features;


	if (data & ETH_FLAG_LRO)
	if (data & ETH_FLAG_LRO)
		dev->features |= NETIF_F_LRO;
		features |= NETIF_F_LRO;
	else
	else
		dev->features &= ~NETIF_F_LRO;
		features &= ~NETIF_F_LRO;


	if (data & ETH_FLAG_NTUPLE) {
	if (data & ETH_FLAG_NTUPLE) {
		if (!ops->set_rx_ntuple)
		if (!ops->set_rx_ntuple)
			return -EOPNOTSUPP;
			return -EOPNOTSUPP;
		dev->features |= NETIF_F_NTUPLE;
		features |= NETIF_F_NTUPLE;
	} else {
	} else {
		/* safe to clear regardless */
		/* safe to clear regardless */
		dev->features &= ~NETIF_F_NTUPLE;
		features &= ~NETIF_F_NTUPLE;
	}
	}


	dev->features = features;
	return 0;
	return 0;
}
}