|
|
83ef35 |
From ad9e296622adf2cd775c93a94c4ba2756d07e0d5 Mon Sep 17 00:00:00 2001
|
|
|
83ef35 |
From: Maxim Mikityanskiy <maximmi@mellanox.com>
|
|
|
83ef35 |
Date: Tue, 25 Aug 2020 11:11:38 +0300
|
|
|
83ef35 |
Subject: [PATCH 02/17] netlink: Print and return an error when features
|
|
|
83ef35 |
weren't changed
|
|
|
83ef35 |
|
|
|
83ef35 |
The legacy ethtool prints an error message and returns 1 if no features
|
|
|
83ef35 |
were changed as requested. Port this behavior to ethtool-netlink.
|
|
|
83ef35 |
req_mask is compared to wanted_mask to detect if any feature was
|
|
|
83ef35 |
changed. If these masks are equal, it means that the kernel hasn't
|
|
|
83ef35 |
changed anything, and all bits got to wanted.
|
|
|
83ef35 |
|
|
|
83ef35 |
Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
|
|
|
83ef35 |
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
|
|
|
83ef35 |
(cherry picked from commit e06cf83352d5161399da49eae7296126cd5e4ea1)
|
|
|
83ef35 |
---
|
|
|
83ef35 |
netlink/features.c | 11 ++++++++++-
|
|
|
83ef35 |
1 file changed, 10 insertions(+), 1 deletion(-)
|
|
|
83ef35 |
|
|
|
83ef35 |
diff --git a/netlink/features.c b/netlink/features.c
|
|
|
83ef35 |
index 133529da2b9f..762259405acc 100644
|
|
|
83ef35 |
--- a/netlink/features.c
|
|
|
83ef35 |
+++ b/netlink/features.c
|
|
|
83ef35 |
@@ -243,6 +243,7 @@ int nl_gfeatures(struct cmd_context *ctx)
|
|
|
83ef35 |
/* FEATURES_SET */
|
|
|
83ef35 |
|
|
|
83ef35 |
struct sfeatures_context {
|
|
|
83ef35 |
+ bool nothing_changed;
|
|
|
83ef35 |
uint32_t req_mask[0];
|
|
|
83ef35 |
};
|
|
|
83ef35 |
|
|
|
83ef35 |
@@ -411,10 +412,14 @@ static void show_feature_changes(struct nl_context *nlctx,
|
|
|
83ef35 |
if (!wanted_val || !wanted_mask || !active_val || !active_mask)
|
|
|
83ef35 |
goto err;
|
|
|
83ef35 |
|
|
|
83ef35 |
+ sfctx->nothing_changed = true;
|
|
|
83ef35 |
diff = false;
|
|
|
83ef35 |
- for (i = 0; i < words; i++)
|
|
|
83ef35 |
+ for (i = 0; i < words; i++) {
|
|
|
83ef35 |
+ if (wanted_mask[i] != sfctx->req_mask[i])
|
|
|
83ef35 |
+ sfctx->nothing_changed = false;
|
|
|
83ef35 |
if (wanted_mask[i] || (active_mask[i] & ~sfctx->req_mask[i]))
|
|
|
83ef35 |
diff = true;
|
|
|
83ef35 |
+ }
|
|
|
83ef35 |
if (!diff)
|
|
|
83ef35 |
return;
|
|
|
83ef35 |
|
|
|
83ef35 |
@@ -520,6 +525,10 @@ int nl_sfeatures(struct cmd_context *ctx)
|
|
|
83ef35 |
if (ret < 0)
|
|
|
83ef35 |
return 92;
|
|
|
83ef35 |
ret = nlsock_process_reply(nlsk, sfeatures_reply_cb, nlctx);
|
|
|
83ef35 |
+ if (sfctx->nothing_changed) {
|
|
|
83ef35 |
+ fprintf(stderr, "Could not change any device features\n");
|
|
|
83ef35 |
+ return nlctx->exit_code ?: 1;
|
|
|
83ef35 |
+ }
|
|
|
83ef35 |
if (ret == 0)
|
|
|
83ef35 |
return 0;
|
|
|
83ef35 |
return nlctx->exit_code ?: 92;
|
|
|
83ef35 |
--
|
|
|
83ef35 |
2.26.2
|
|
|
83ef35 |
|