Skip to contentSkip to conversation

ethtool: Fix the "advertise" parameter logic.

PATCH In review Michael Chan 2 participants 2 messages Nov 22, 2016 – Nov 23, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ethtool: Fix the "advertise" parameter logic.

From: Michael Chan <[email protected]>

The current code ignores the value of the advertise parameter. For example,

ethtool -s ethx advertise 0x1000

The full_advertising_wanted parameter of 0x1000 is not passed to the kernel. The reason is that advertising_wanted is NULL in this case, and ethtool will think that the user has given no advertisement input and so it will proceed to pass all supported advertisement speeds to the kernel.

The older legacy ethtool with similar logic worked because advertising_wanted was an integer and could take on -1 and 0. It would pass the full_advertising_wanted value if advertising_wanted == -1.

This fix is to pass all supported advertisement speeds only when both advertising_wanted == NULL && full_advertising_wanted == NULL.

---
 ethtool.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
ethtool.c +2 -1
index 49ac94e..7715823 100644
@@ -2971,7 +2971,8 @@ static int do_sset(struct cmd_context *ctx)
 				fprintf(stderr,	"\n");
 			}
 			if (autoneg_wanted == AUTONEG_ENABLE &&
-			    advertising_wanted == NULL) {
+			    advertising_wanted == NULL &&
+			    full_advertising_wanted == NULL) {
 				unsigned int i;
 
 				/* Auto negotiation enabled, but with
Signature · 1 line
1.8.4.5
#1 lore raw
Quoted 11 lines · Michael Chan

From: Michael Chan <[email protected]>

The current code ignores the value of the advertise parameter. For example,

ethtool -s ethx advertise 0x1000

The full_advertising_wanted parameter of 0x1000 is not passed to the kernel. The reason is that advertising_wanted is NULL in this case, and ethtool will think that the user has given no advertisement input and so it will proceed to pass all supported advertisement speeds to the kernel.

Quoted 8 lines

The older legacy ethtool with similar logic worked because advertising_wanted was an integer and could take on -1 and 0. It would pass the full_advertising_wanted value if advertising_wanted == -1.

This fix is to pass all supported advertisement speeds only when both advertising_wanted == NULL && full_advertising_wanted == NULL.

Thanks, Michael -- merging...

John

Signature · 2 lines
John W. Linville		Someday the world will need a hero, and you
[email protected]			might be all we have.  Be ready.