From: Maxim Mikityanskiy <maximmi@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>,
Michal Kubecek <mkubecek@suse.cz>, Andrew Lunn <andrew@lunn.ch>
Cc: Jakub Kicinski <kuba@kernel.org>,
Florian Fainelli <f.fainelli@gmail.com>,
netdev@vger.kernel.org, Maxim Mikityanskiy <maximmi@mellanox.com>
Subject: [PATCH net v2 3/3] ethtool: Don't omit the netlink reply if no features were changed
Date: Mon, 17 Aug 2020 16:34:07 +0300 [thread overview]
Message-ID: <20200817133407.22687-4-maximmi@mellanox.com> (raw)
In-Reply-To: <20200817133407.22687-1-maximmi@mellanox.com>
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: 0980bfcd6954 ("ethtool: set netdev features with FEATURES_SET request")
Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
---
net/ethtool/features.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/net/ethtool/features.c b/net/ethtool/features.c
index 6b288bfd7678..495635f152ba 100644
--- a/net/ethtool/features.c
+++ b/net/ethtool/features.c
@@ -268,14 +268,11 @@ int ethnl_set_features(struct sk_buff *skb, struct genl_info *info)
bitmap_and(req_wanted, req_wanted, req_mask, NETDEV_FEATURE_COUNT);
bitmap_andnot(new_wanted, old_wanted, req_mask, NETDEV_FEATURE_COUNT);
bitmap_or(req_wanted, new_wanted, req_wanted, NETDEV_FEATURE_COUNT);
- if (bitmap_equal(req_wanted, old_wanted, NETDEV_FEATURE_COUNT)) {
- ret = 0;
- goto out_rtnl;
+ if (!bitmap_equal(req_wanted, old_wanted, NETDEV_FEATURE_COUNT)) {
+ dev->wanted_features &= ~dev->hw_features;
+ dev->wanted_features |= ethnl_bitmap_to_features(req_wanted) & dev->hw_features;
+ __netdev_update_features(dev);
}
-
- dev->wanted_features &= ~dev->hw_features;
- dev->wanted_features |= ethnl_bitmap_to_features(req_wanted) & dev->hw_features;
- __netdev_update_features(dev);
ethnl_features_to_bitmap(new_active, dev->features);
mod = !bitmap_equal(old_active, new_active, NETDEV_FEATURE_COUNT);
--
2.25.1
next prev parent reply other threads:[~2020-08-17 13:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-17 13:34 [PATCH net v2 0/3] ethtool-netlink bug fixes Maxim Mikityanskiy
2020-08-17 13:34 ` [PATCH net v2 1/3] ethtool: Fix preserving of wanted feature bits in netlink interface Maxim Mikityanskiy
2020-08-18 22:15 ` Michal Kubecek
2020-08-17 13:34 ` [PATCH net v2 2/3] ethtool: Account for hw_features " Maxim Mikityanskiy
2020-08-18 22:25 ` Michal Kubecek
2020-08-17 13:34 ` Maxim Mikityanskiy [this message]
2020-08-18 22:46 ` [PATCH net v2 3/3] ethtool: Don't omit the netlink reply if no features were changed Michal Kubecek
2020-08-18 23:01 ` [PATCH net v2 0/3] ethtool-netlink bug fixes David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200817133407.22687-4-maximmi@mellanox.com \
--to=maximmi@mellanox.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).