chiark / gitweb /
silence warnings
[elogind.git] / src / udev / net / link-config.c
index 0c563b2db5432ff241eb6bf2203f87094bb1365d..8234598e4518e5ae8a0e857e8cd075ba6b928d67 100644 (file)
@@ -140,12 +140,17 @@ void link_config_ctx_free(link_config_ctx *ctx) {
 
 static int load_link(link_config_ctx *ctx, const char *filename) {
         _cleanup_free_ link_config *link = NULL;
-        _cleanup_fclose_ FILE *file;
+        _cleanup_fclose_ FILE *file = NULL;
         int r;
 
         assert(ctx);
         assert(filename);
 
+        if (null_or_empty_path(filename)) {
+                log_debug("skipping empty file: %s", filename);
+                return 0;
+        }
+
         file = fopen(filename, "re");
         if (!file) {
                 if (errno == ENOENT)
@@ -238,7 +243,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"),
@@ -273,22 +278,6 @@ static bool mac_is_random(struct udev_device *device) {
         return type == 1;
 }
 
-static bool mac_is_permanent(struct udev_device *device) {
-        const char *s;
-        unsigned type;
-        int r;
-
-        s = udev_device_get_sysattr_value(device, "addr_assign_type");
-        if (!s)
-                return true; /* if we don't know, assume it is permanent */
-        r = safe_atou(s, &type);
-        if (r < 0)
-                return true;
-
-        /* check for NET_ADDR_PERM */
-        return type == 0;
-}
-
 static int get_mac(struct udev_device *device, bool want_random, struct ether_addr *mac) {
         int r;
 
@@ -384,7 +373,7 @@ int link_config_apply(link_config_ctx *ctx, link_config *config, struct udev_dev
 
         switch (config->mac_policy) {
                 case MACPOLICY_PERSISTENT:
-                        if (!mac_is_permanent(device)) {
+                        if (mac_is_random(device)) {
                                 r = get_mac(device, false, &generated_mac);
                                 if (r < 0)
                                         return r;