]> git.baikalelectronics.ru Git - kernel.git/commit
ethtool: Fix preserving of wanted feature bits in netlink interface
authorMaxim Mikityanskiy <maximmi@mellanox.com>
Mon, 17 Aug 2020 13:34:05 +0000 (16:34 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 18 Aug 2020 23:00:24 +0000 (16:00 -0700)
commit0196087cb8ee641760e705ab8540452c12424103
treebc982c301db02b4a1d8c53c0013d73a4218ec4e1
parent4a84f9fe093e5e9d7585b4895c75f4a633c3f8d2
ethtool: Fix preserving of wanted feature bits in netlink interface

Currently, ethtool-netlink calculates new wanted bits as:
(req_wanted & req_mask) | (old_active & ~req_mask)

It completely discards the old wanted bits, so they are forgotten with
the next ethtool command. Sample steps to reproduce:

1. ethtool -k eth0
   tx-tcp-segmentation: on # TSO is on from the beginning
2. ethtool -K eth0 tx off
   tx-tcp-segmentation: off [not requested]
3. ethtool -k eth0
   tx-tcp-segmentation: off [requested on]
4. ethtool -K eth0 rx off # Some change unrelated to TSO
5. ethtool -k eth0
   tx-tcp-segmentation: off # "Wanted on" is forgotten

This commit fixes it by changing the formula to:
(req_wanted & req_mask) | (old_wanted & ~req_mask),
where old_active was replaced by old_wanted to account for the wanted
bits.

The shortcut condition for the case where nothing was changed now
compares wanted bitmasks, instead of wanted to active.

Fixes: 3fc4e8ed4ffd ("ethtool: set netdev features with FEATURES_SET request")
Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
Reviewed-by: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ethtool/features.c