Skip to content

Commit 0df55a0

Browse files
committed
Merge branch 'ethtool-netlink-bug-fixes'
Maxim Mikityanskiy says: ==================== ethtool-netlink bug fixes This series contains a few bug fixes for ethtool-netlink. These bugs are specific for the netlink interface, and the legacy ioctl interface is not affected. These patches aim to have the same behavior in ethtool-netlink as in the legacy ethtool. Please also see the sibling series for the userspace tool. v2 changes: Added Fixes tags. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 4ef1a7c + f01204e commit 0df55a0

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

net/ethtool/features.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ int ethnl_set_features(struct sk_buff *skb, struct genl_info *info)
224224
DECLARE_BITMAP(wanted_diff_mask, NETDEV_FEATURE_COUNT);
225225
DECLARE_BITMAP(active_diff_mask, NETDEV_FEATURE_COUNT);
226226
DECLARE_BITMAP(old_active, NETDEV_FEATURE_COUNT);
227+
DECLARE_BITMAP(old_wanted, NETDEV_FEATURE_COUNT);
227228
DECLARE_BITMAP(new_active, NETDEV_FEATURE_COUNT);
229+
DECLARE_BITMAP(new_wanted, NETDEV_FEATURE_COUNT);
228230
DECLARE_BITMAP(req_wanted, NETDEV_FEATURE_COUNT);
229231
DECLARE_BITMAP(req_mask, NETDEV_FEATURE_COUNT);
230232
struct nlattr *tb[ETHTOOL_A_FEATURES_MAX + 1];
@@ -250,6 +252,7 @@ int ethnl_set_features(struct sk_buff *skb, struct genl_info *info)
250252

251253
rtnl_lock();
252254
ethnl_features_to_bitmap(old_active, dev->features);
255+
ethnl_features_to_bitmap(old_wanted, dev->wanted_features);
253256
ret = ethnl_parse_bitset(req_wanted, req_mask, NETDEV_FEATURE_COUNT,
254257
tb[ETHTOOL_A_FEATURES_WANTED],
255258
netdev_features_strings, info->extack);
@@ -261,17 +264,15 @@ int ethnl_set_features(struct sk_buff *skb, struct genl_info *info)
261264
goto out_rtnl;
262265
}
263266

264-
/* set req_wanted bits not in req_mask from old_active */
267+
/* set req_wanted bits not in req_mask from old_wanted */
265268
bitmap_and(req_wanted, req_wanted, req_mask, NETDEV_FEATURE_COUNT);
266-
bitmap_andnot(new_active, old_active, req_mask, NETDEV_FEATURE_COUNT);
267-
bitmap_or(req_wanted, new_active, req_wanted, NETDEV_FEATURE_COUNT);
268-
if (bitmap_equal(req_wanted, old_active, NETDEV_FEATURE_COUNT)) {
269-
ret = 0;
270-
goto out_rtnl;
269+
bitmap_andnot(new_wanted, old_wanted, req_mask, NETDEV_FEATURE_COUNT);
270+
bitmap_or(req_wanted, new_wanted, req_wanted, NETDEV_FEATURE_COUNT);
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);
271275
}
272-
273-
dev->wanted_features = ethnl_bitmap_to_features(req_wanted);
274-
__netdev_update_features(dev);
275276
ethnl_features_to_bitmap(new_active, dev->features);
276277
mod = !bitmap_equal(old_active, new_active, NETDEV_FEATURE_COUNT);
277278

0 commit comments

Comments
 (0)