diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2016-11-10 17:09:44 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-10 17:09:44 -0500 |
commit | 4553df9fd7efdca00ce54ec195b61a019b67a6e7 (patch) | |
tree | 10d891b4c09428ed93db2f51fcb05950fe285200 /src/udev/net/link-config.c | |
parent | a649c9576eedd00635345524430d771cbda521f6 (diff) | |
parent | a39f92d391ac1ce06b3618874ff4211ecb11f549 (diff) |
Merge pull request #4104 from ssahani/ethtool_xlink_settings
Link: port to new ethtool ETHTOOL_xLINKSETTINGS
Diffstat (limited to 'src/udev/net/link-config.c')
-rw-r--r-- | src/udev/net/link-config.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c index ece9248c2a..4578d0d9b2 100644 --- a/src/udev/net/link-config.c +++ b/src/udev/net/link-config.c @@ -167,6 +167,7 @@ static int load_link(link_config_ctx *ctx, const char *filename) { link->mac_policy = _MACPOLICY_INVALID; link->wol = _WOL_INVALID; link->duplex = _DUP_INVALID; + link->autonegotiation = -1; memset(&link->features, -1, _NET_DEV_FEAT_MAX); @@ -202,9 +203,9 @@ static bool enable_name_policy(void) { } int link_config_load(link_config_ctx *ctx) { - int r; _cleanup_strv_free_ char **files; char **f; + int r; link_configs_free(ctx); @@ -364,11 +365,12 @@ static int get_mac(struct udev_device *device, bool want_random, int link_config_apply(link_config_ctx *ctx, link_config *config, struct udev_device *device, const char **name) { - const char *old_name; - const char *new_name = NULL; + bool respect_predictable = false; struct ether_addr generated_mac; struct ether_addr *mac = NULL; - bool respect_predictable = false; + const char *new_name = NULL; + const char *old_name; + unsigned speed; int r, ifindex; assert(ctx); @@ -380,11 +382,19 @@ int link_config_apply(link_config_ctx *ctx, link_config *config, if (!old_name) return -EINVAL; - r = ethtool_set_speed(&ctx->ethtool_fd, old_name, config->speed / 1024, config->duplex); - if (r < 0) - log_warning_errno(r, "Could not set speed or duplex of %s to %zu Mbps (%s): %m", - old_name, config->speed / 1024, - duplex_to_string(config->duplex)); + + speed = DIV_ROUND_UP(config->speed, 1000000); + + r = ethtool_set_glinksettings(&ctx->ethtool_fd, old_name, speed, config->duplex, config->autonegotiation); + if (r < 0) { + + 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 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); if (r < 0) |