Blame SOURCES/0002-netlink-Print-and-return-an-error-when-features-were.patch

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