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

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