[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1401750420-6668-1-git-send-email-stannous@cumulusnetworks.com>
Date: Mon, 2 Jun 2014 19:07:00 -0400
From: stannous@...ulusnetworks.com
To: netdev@...r.kernel.org
Cc: shm@...ulusnetworks.com, sfeldma@...ulusnetworks.com,
stannous@...ulusnetworks.com
Subject: [PATCH] Force speed and duplex mode setting if link down
From: Sam Tannous <stannous@...ulusnetworks.com>
This patch forces the user to set both the speed and the duplex
mode if the user only specifies the speed while the interface is down.
If the interface is down, we'll get an ecmd speed
and duplex mode of 0. This has the ill effect of
setting the duplex to HALF and this often results in an
error since many higher speed will not support HALF duplex.
Signed-off-by: Sam Tannous <stannous@...ulusnetworks.com>
---
ethtool.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/ethtool.c b/ethtool.c
index 8e968a8..9cd3103 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -2461,6 +2461,22 @@ static int do_sset(struct cmd_context *ctx)
if (err < 0) {
perror("Cannot get current device settings");
} else {
+ /* If the interface is down, we'll get an ecmd speed and
+ duplex of 0. This has the effect of defaulting
+ the duplex mode to HALF. This results in an
+ error since many of our speeds will not support HALF
+ any more. To prevent this, we need to insist that
+ the user provide us with specific duplex mode if
+ they haven't already (likely FULL) if both the speed
+ and duplex are 0 here.
+ */
+ if (speed_wanted != -1 && duplex_wanted == -1
+ && !(ecmd.speed || ecmd.duplex)) {
+ fprintf(stderr, "Setting the speed while the link "
+ "is down requires both the speed and the "
+ "duplex mode to be set");
+ exit_bad_args();
+ }
/* Change everything the user specified. */
if (speed_wanted != -1)
ethtool_cmd_speed_set(&ecmd, speed_wanted);
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists