chiark / gitweb /
networkd: tie links to rtnl rather than udev
[elogind.git] / src / udev / net / link-config.c
index 5bb6b02c1bb7b326e823651045cfb08b1aca8f2c..8215c40d5d2cd9730353f0c61cb50dcd2b05d231 100644 (file)
@@ -139,7 +139,7 @@ void link_config_ctx_free(link_config_ctx *ctx) {
 }
 
 static int load_link(link_config_ctx *ctx, const char *filename) {
-        link_config *link;
+        _cleanup_free_ link_config *link = NULL;
         _cleanup_fclose_ FILE *file;
         int r;
 
@@ -151,14 +151,12 @@ static int load_link(link_config_ctx *ctx, const char *filename) {
                 if (errno == ENOENT)
                         return 0;
                 else
-                        return errno;
+                        return -errno;
         }
 
         link = new0(link_config, 1);
-        if (!link) {
-                r = log_oom();
-                goto failure;
-        }
+        if (!link)
+                return log_oom();
 
         link->mac_policy = _MACPOLICY_INVALID;
         link->wol = _WOL_INVALID;
@@ -168,19 +166,16 @@ static int load_link(link_config_ctx *ctx, const char *filename) {
                          (void*) link_config_gperf_lookup, false, false, link);
         if (r < 0) {
                 log_warning("Could not parse config file %s: %s", filename, strerror(-r));
-                goto failure;
+                return r;
         } else
                 log_debug("Parsed configuration file %s", filename);
 
         link->filename = strdup(filename);
 
         LIST_PREPEND(links, ctx->links, link);
+        link = NULL;
 
         return 0;
-
-failure:
-        free(link);
-        return r;
 }
 
 static bool enable_name_policy(void) {
@@ -243,7 +238,7 @@ int link_config_get(link_config_ctx *ctx, struct udev_device *device, link_confi
                 if (net_match_config(link->match_mac, link->match_path, link->match_driver,
                                      link->match_type, NULL, link->match_host,
                                      link->match_virt, link->match_kernel, link->match_arch,
-                                     udev_device_get_sysattr_value(device, "address"),
+                                     ether_aton(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"),