149f89
From 47b95959941b3d7d2d35a128da5685799329aaf6 Mon Sep 17 00:00:00 2001
149f89
From: Michael Chan <mchan@broadcom.com>
149f89
Date: Tue, 22 Nov 2016 18:55:47 -0500
149f89
Subject: [PATCH 3/3] ethtool: Fix the "advertise" parameter logic.
149f89
149f89
The current code ignores the value of the advertise parameter.  For example,
149f89
149f89
ethtool -s ethx advertise 0x1000
149f89
149f89
The full_advertising_wanted parameter of 0x1000 is not passed to the kernel.
149f89
The reason is that advertising_wanted is NULL in this case, and ethtool
149f89
will think that the user has given no advertisement input and so it will
149f89
proceed to pass all supported advertisement speeds to the kernel.
149f89
149f89
The older legacy ethtool with similar logic worked because
149f89
advertising_wanted was an integer and could take on -1 and 0.  It would pass
149f89
the full_advertising_wanted value if advertising_wanted == -1.
149f89
149f89
This fix is to pass all supported advertisement speeds only when both
149f89
advertising_wanted == NULL && full_advertising_wanted == NULL.
149f89
149f89
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
149f89
Signed-off-by: John W. Linville <linville@tuxdriver.com>
149f89
---
149f89
 ethtool.c | 3 ++-
149f89
 1 file changed, 2 insertions(+), 1 deletion(-)
149f89
149f89
diff --git a/ethtool.c b/ethtool.c
149f89
index 0d3244e..ce48639 100644
149f89
--- a/ethtool.c
149f89
+++ b/ethtool.c
149f89
@@ -2972,7 +2972,8 @@ static int do_sset(struct cmd_context *ctx)
149f89
 				fprintf(stderr,	"\n");
149f89
 			}
149f89
 			if (autoneg_wanted == AUTONEG_ENABLE &&
149f89
-			    advertising_wanted == NULL) {
149f89
+			    advertising_wanted == NULL &&
149f89
+			    full_advertising_wanted == NULL) {
149f89
 				unsigned int i;
149f89
 
149f89
 				/* Auto negotiation enabled, but with
149f89
-- 
149f89
1.8.3.1
149f89