Skip to content

Commit f01204e

Browse files
Maxim Mikityanskiydavem330
authored andcommitted
ethtool: Don't omit the netlink reply if no features were changed
The legacy ethtool userspace tool shows an error when no features could be changed. It's useful to have a netlink reply to be able to show this error when __netdev_update_features wasn't called, for example: 1. ethtool -k eth0 large-receive-offload: off 2. ethtool -K eth0 rx-fcs on 3. ethtool -K eth0 lro on Could not change any device features rx-lro: off [requested on] 4. ethtool -K eth0 lro on # The output should be the same, but without this patch the kernel # doesn't send the reply, and ethtool is unable to detect the error. This commit makes ethtool-netlink always return a reply when requested, and it still avoids unnecessary calls to __netdev_update_features if the wanted features haven't changed. Fixes: 0980bfc ("ethtool: set netdev features with FEATURES_SET request") Signed-off-by: Maxim Mikityanskiy <[email protected]> Reviewed-by: Michal Kubecek <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2847bfe commit f01204e

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

net/ethtool/features.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -268,14 +268,11 @@ int ethnl_set_features(struct sk_buff *skb, struct genl_info *info)
268268
bitmap_and(req_wanted, req_wanted, req_mask, NETDEV_FEATURE_COUNT);
269269
bitmap_andnot(new_wanted, old_wanted, req_mask, NETDEV_FEATURE_COUNT);
270270
bitmap_or(req_wanted, new_wanted, req_wanted, NETDEV_FEATURE_COUNT);
271-
if (bitmap_equal(req_wanted, old_wanted, NETDEV_FEATURE_COUNT)) {
272-
ret = 0;
273-
goto out_rtnl;
271+
if (!bitmap_equal(req_wanted, old_wanted, NETDEV_FEATURE_COUNT)) {
272+
dev->wanted_features &= ~dev->hw_features;
273+
dev->wanted_features |= ethnl_bitmap_to_features(req_wanted) & dev->hw_features;
274+
__netdev_update_features(dev);
274275
}
275-
276-
dev->wanted_features &= ~dev->hw_features;
277-
dev->wanted_features |= ethnl_bitmap_to_features(req_wanted) & dev->hw_features;
278-
__netdev_update_features(dev);
279276
ethnl_features_to_bitmap(new_active, dev->features);
280277
mod = !bitmap_equal(old_active, new_active, NETDEV_FEATURE_COUNT);
281278

0 commit comments

Comments
 (0)