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

Commit 1437ce39 authored by Ben Hutchings's avatar Ben Hutchings Committed by David S. Miller
Browse files

ethtool: Change ethtool_op_set_flags to validate flags



ethtool_op_set_flags() does not check for unsupported flags, and has
no way of doing so.  This means it is not suitable for use as a
default implementation of ethtool_ops::set_flags.

Add a 'supported' parameter specifying the flags that the driver and
hardware support, validate the requested flags against this, and
change all current callers to pass this parameter.

Change some other trivial implementations of ethtool_ops::set_flags to
call ethtool_op_set_flags().

Signed-off-by: default avatarBen Hutchings <bhutchings@solarflare.com>
Reviewed-by: default avatarStanislaw Gruszka <sgruszka@redhat.com>
Acked-by: default avatarJeff Garzik <jgarzik@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b3003be3
Loading
Loading
Loading
Loading
+1 −8
Original line number Diff line number Diff line
@@ -1799,14 +1799,7 @@ static int set_tso(struct net_device *dev, u32 value)

static int set_flags(struct net_device *dev, u32 flags)
{
	if (flags & ~ETH_FLAG_RXHASH)
		return -EOPNOTSUPP;

	if (flags & ETH_FLAG_RXHASH)
		dev->features |= NETIF_F_RXHASH;
	else
		dev->features &= ~NETIF_F_RXHASH;
	return 0;
	return ethtool_op_set_flags(dev, flags, ETH_FLAG_RXHASH);
}

static struct ethtool_ops cxgb_ethtool_ops = {
+0 −1
Original line number Diff line number Diff line
@@ -365,7 +365,6 @@ static const struct ethtool_ops enic_ethtool_ops = {
	.get_coalesce = enic_get_coalesce,
	.set_coalesce = enic_set_coalesce,
	.get_flags = ethtool_op_get_flags,
	.set_flags = ethtool_op_set_flags,
};

static void enic_free_wq_buf(struct vnic_wq *wq, struct vnic_wq_buf *buf)
+4 −1
Original line number Diff line number Diff line
@@ -2205,8 +2205,11 @@ static int ixgbe_set_flags(struct net_device *netdev, u32 data)
{
	struct ixgbe_adapter *adapter = netdev_priv(netdev);
	bool need_reset = false;
	int rc;

	ethtool_op_set_flags(netdev, data);
	rc = ethtool_op_set_flags(netdev, data, ETH_FLAG_LRO | ETH_FLAG_NTUPLE);
	if (rc)
		return rc;

	/* if state changes we need to update adapter->flags and reset */
	if (adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE) {
+6 −1
Original line number Diff line number Diff line
@@ -1636,6 +1636,11 @@ static void mv643xx_eth_get_ethtool_stats(struct net_device *dev,
	}
}

static int mv643xx_eth_set_flags(struct net_device *dev, u32 data)
{
	return ethtool_op_set_flags(dev, data, ETH_FLAG_LRO);
}

static int mv643xx_eth_get_sset_count(struct net_device *dev, int sset)
{
	if (sset == ETH_SS_STATS)
@@ -1661,7 +1666,7 @@ static const struct ethtool_ops mv643xx_eth_ethtool_ops = {
	.get_strings		= mv643xx_eth_get_strings,
	.get_ethtool_stats	= mv643xx_eth_get_ethtool_stats,
	.get_flags		= ethtool_op_get_flags,
	.set_flags		= ethtool_op_set_flags,
	.set_flags		= mv643xx_eth_set_flags,
	.get_sset_count		= mv643xx_eth_get_sset_count,
};

+7 −3
Original line number Diff line number Diff line
@@ -1730,8 +1730,7 @@ static int myri10ge_set_rx_csum(struct net_device *netdev, u32 csum_enabled)
	if (csum_enabled)
		mgp->csum_flag = MXGEFW_FLAGS_CKSUM;
	else {
		u32 flags = ethtool_op_get_flags(netdev);
		err = ethtool_op_set_flags(netdev, (flags & ~ETH_FLAG_LRO));
		netdev->features &= ~NETIF_F_LRO;
		mgp->csum_flag = 0;

	}
@@ -1900,6 +1899,11 @@ static u32 myri10ge_get_msglevel(struct net_device *netdev)
	return mgp->msg_enable;
}

static int myri10ge_set_flags(struct net_device *netdev, u32 value)
{
	return ethtool_op_set_flags(netdev, value, ETH_FLAG_LRO);
}

static const struct ethtool_ops myri10ge_ethtool_ops = {
	.get_settings = myri10ge_get_settings,
	.get_drvinfo = myri10ge_get_drvinfo,
@@ -1920,7 +1924,7 @@ static const struct ethtool_ops myri10ge_ethtool_ops = {
	.set_msglevel = myri10ge_set_msglevel,
	.get_msglevel = myri10ge_get_msglevel,
	.get_flags = ethtool_op_get_flags,
	.set_flags = ethtool_op_set_flags
	.set_flags = myri10ge_set_flags
};

static int myri10ge_allocate_rings(struct myri10ge_slice_state *ss)
Loading