]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev/net: drop fallback logic to set speed
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 20 May 2021 21:22:37 +0000 (06:22 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 23 May 2021 02:40:15 +0000 (11:40 +0900)
ethtool_set_glinksettings() already fallback to use ETHTOOL_GSET/ETHTOOL_SSET
commands when ETHTOOL_GLINKSETTINGS/ETHTOOL_SLINKSETTINGS are not
supported.

src/udev/net/link-config.c

index 3685c9d2280813e8cf60896cf2ef5bd1c6b18398..dc6d437718a6e30791aa0a8e1b62000a0a4c728e 100644 (file)
@@ -308,28 +308,30 @@ static int link_config_apply_ethtool_settings(int *ethtool_fd, const link_config
                                       config->autonegotiation, config->advertise,
                                       config->speed, config->duplex, config->port);
         if (r < 0) {
-                if (config->port != _NET_DEV_PORT_INVALID)
-                        log_device_warning_errno(device, r, "Could not set port '%s', ignoring: %m", port_to_string(config->port));
+                if (config->autonegotiation >= 0)
+                        log_device_warning_errno(device, r, "Could not %s auto negotiation, ignoring: %m",
+                                                 enable_disable(config->autonegotiation));
 
                 if (!eqzero(config->advertise))
-                        log_device_warning_errno(device, r, "Could not set advertise mode, ignoring: %m"); /* TODO: include modes in the log message. */
+                        log_device_warning_errno(device, r, "Could not set advertise mode, ignoring: %m");
 
-                if (config->speed) {
-                        unsigned speed = DIV_ROUND_UP(config->speed, 1000000);
-                        if (r == -EOPNOTSUPP) {
-                                r = ethtool_set_speed(ethtool_fd, name, speed, config->duplex);
-                                if (r < 0)
-                                        log_device_warning_errno(device, r, "Could not set speed to %uMbps, ignoring: %m", speed);
-                        }
-                }
+                if (config->speed > 0)
+                        log_device_warning_errno(device, r, "Could not set speed to %"PRIu64"Mbps, ignoring: %m",
+                                                 DIV_ROUND_UP(config->speed, 1000000));
+
+                if (config->duplex >= 0)
+                        log_device_warning_errno(device, r, "Could not set duplex to %s, ignoring: %m",
+                                                 duplex_to_string(config->duplex));
 
-                if (config->duplex != _DUP_INVALID)
-                        log_device_warning_errno(device, r, "Could not set duplex to %s, ignoring: %m", duplex_to_string(config->duplex));
+                if (config->port >= 0)
+                        log_device_warning_errno(device, r, "Could not set port to '%s', ignoring: %m",
+                                                 port_to_string(config->port));
         }
 
         r = ethtool_set_wol(ethtool_fd, name, config->wol);
         if (r < 0)
-                log_device_warning_errno(device, r, "Could not set WakeOnLan to %s, ignoring: %m", wol_to_string(config->wol));
+                log_device_warning_errno(device, r, "Could not set WakeOnLan to %s, ignoring: %m",
+                                         wol_to_string(config->wol));
 
         r = ethtool_set_features(ethtool_fd, name, config->features);
         if (r < 0)