Skip to content

Commit

Permalink
net: fix ETHTOOL_SFEATURES compatibility with old ethtool_ops.set_flags
Browse files Browse the repository at this point in the history
Current code squashes flags to bool - this makes set_flags fail whenever
some ETH_FLAG_* equivalent features are set. Fix this.

Signed-off-by: Michał Mirosław <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
osctobe authored and davem330 committed May 26, 2011
1 parent 94265cf commit fd0daf9
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion net/core/ethtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,29 @@ static int ethtool_set_feature_compat(struct net_device *dev,
return 1;
}

static int ethtool_set_flags_compat(struct net_device *dev,
int (*legacy_set)(struct net_device *, u32),
struct ethtool_set_features_block *features, u32 mask)
{
u32 value;

if (!legacy_set)
return 0;

if (!(features[0].valid & mask))
return 0;

value = dev->features & ~features[0].valid;
value |= features[0].requested;

features[0].valid &= ~mask;

if (legacy_set(dev, value & mask) < 0)
netdev_info(dev, "Legacy flags change failed\n");

return 1;
}

static int ethtool_set_features_compat(struct net_device *dev,
struct ethtool_set_features_block *features)
{
Expand All @@ -249,7 +272,7 @@ static int ethtool_set_features_compat(struct net_device *dev,
features, NETIF_F_ALL_TSO);
compat |= ethtool_set_feature_compat(dev, dev->ethtool_ops->set_rx_csum,
features, NETIF_F_RXCSUM);
compat |= ethtool_set_feature_compat(dev, dev->ethtool_ops->set_flags,
compat |= ethtool_set_flags_compat(dev, dev->ethtool_ops->set_flags,
features, flags_dup_features);

return compat;
Expand Down

0 comments on commit fd0daf9

Please sign in to comment.