From 9c5e1172396136bb307459551f407fc614182392 Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Mon, 26 Jun 2017 18:37:38 +0530 Subject: [PATCH 1/2] ethtool: Fix speed in 593022fa377d40d9a645919759b04c53cf4eace8 We should use the DIV_ROUND_UP --- src/udev/net/ethtool-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/udev/net/ethtool-util.c b/src/udev/net/ethtool-util.c index 19f5f049e4..201fc23437 100644 --- a/src/udev/net/ethtool-util.c +++ b/src/udev/net/ethtool-util.c @@ -527,7 +527,7 @@ int ethtool_set_glinksettings(int *fd, const char *ifname, struct link_config *l } if (link->speed) - u->base.speed = link->speed; + u->base.speed = DIV_ROUND_UP(link->speed, 1000000); if (link->duplex != _DUP_INVALID) u->base.duplex = link->duplex; From bb79318e2150385ab91513cf151f01729762fb1d Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Mon, 26 Jun 2017 21:05:52 +0530 Subject: [PATCH 2/2] ethtool: warn when ethtool_set_glinksettings not supported This is useful when port is not set and should be notified to user. --- src/udev/net/link-config.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index e65a8794dc..05a186357c 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -378,18 +378,19 @@ int link_config_apply(link_config_ctx *ctx, link_config *config, if (!old_name) return -EINVAL; - - speed = DIV_ROUND_UP(config->speed, 1000000); - r = ethtool_set_glinksettings(&ctx->ethtool_fd, old_name, config); if (r < 0) { + if (config->port != _NET_DEV_PORT_INVALID) + log_warning_errno(r, "Could not set port (%s) of %s: %m", port_to_string(config->port), old_name); + + speed = DIV_ROUND_UP(config->speed, 1000000); if (r == -EOPNOTSUPP) r = ethtool_set_speed(&ctx->ethtool_fd, old_name, speed, config->duplex); if (r < 0) - log_warning_errno(r, "Could not set speed, duplex or port (%s) of %s to %u Mbps (%s): %m", - port_to_string(config->port), old_name, speed, duplex_to_string(config->duplex)); + log_warning_errno(r, "Could not set speed or duplex of %s to %u Mbps (%s): %m", + old_name, speed, duplex_to_string(config->duplex)); } r = ethtool_set_wol(&ctx->ethtool_fd, old_name, config->wol);