chiark / gitweb /
util: replace close_nointr_nofail() by a more useful safe_close()
[elogind.git] / src / udev / net / link-config.c
index 40b1d7f7bc84ceb4316f24c193df8ab0033c314c..62439c0c71a680f858fbf48dc740da0345604a4f 100644 (file)
@@ -127,8 +127,7 @@ void link_config_ctx_free(link_config_ctx *ctx) {
         if (!ctx)
                 return;
 
-        if (ctx->ethtool_fd >= 0)
-                close_nointr_nofail(ctx->ethtool_fd);
+        safe_close(ctx->ethtool_fd);
 
         sd_rtnl_unref(ctx->rtnl);
 
@@ -247,6 +246,7 @@ int link_config_get(link_config_ctx *ctx, struct udev_device *device, link_confi
                                      udev_device_get_sysattr_value(device, "address"),
                                      udev_device_get_property_value(device, "ID_PATH"),
                                      udev_device_get_driver(udev_device_get_parent(device)),
+                                     udev_device_get_property_value(device, "ID_NET_DRIVER"),
                                      udev_device_get_devtype(device),
                                      NULL)) {
                         log_debug("Config file %s applies to device %s",
@@ -364,10 +364,11 @@ int link_config_apply(link_config_ctx *ctx, link_config *config, struct udev_dev
         if (!old_name)
                 return -EINVAL;
 
-        r = ethtool_set_speed(ctx->ethtool_fd, old_name, config->speed, config->duplex);
+        r = ethtool_set_speed(ctx->ethtool_fd, old_name, config->speed / 1024, config->duplex);
         if (r < 0)
-                log_warning("Could not set speed or duplex of %s to %u Mbytes (%s): %s",
-                             old_name, config->speed, duplex_to_string(config->duplex), strerror(-r));
+                log_warning("Could not set speed or duplex of %s to %u Mbps (%s): %s",
+                            old_name, config->speed / 1024, duplex_to_string(config->duplex),
+                            strerror(-r));
 
         r = ethtool_set_wol(ctx->ethtool_fd, old_name, config->wol);
         if (r < 0)
@@ -464,7 +465,7 @@ int link_get_driver(link_config_ctx *ctx, struct udev_device *device, char **ret
         return 0;
 }
 
-static const char* const mac_policy_table[] = {
+static const char* const mac_policy_table[_MACPOLICY_MAX] = {
         [MACPOLICY_PERSISTENT] = "persistent",
         [MACPOLICY_RANDOM] = "random"
 };
@@ -472,7 +473,7 @@ static const char* const mac_policy_table[] = {
 DEFINE_STRING_TABLE_LOOKUP(mac_policy, MACPolicy);
 DEFINE_CONFIG_PARSE_ENUM(config_parse_mac_policy, mac_policy, MACPolicy, "Failed to parse MAC address policy");
 
-static const char* const name_policy_table[] = {
+static const char* const name_policy_table[_NAMEPOLICY_MAX] = {
         [NAMEPOLICY_DATABASE] = "database",
         [NAMEPOLICY_ONBOARD] = "onboard",
         [NAMEPOLICY_SLOT] = "slot",