]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dhcp: refuse to set iaid if we cannot find the interface 19866/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 9 Jun 2021 14:47:59 +0000 (23:47 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 11 Jun 2021 18:19:08 +0000 (03:19 +0900)
src/libsystemd-network/dhcp-identifier.c

index d1ea992d43c593a71abfd0b8d830ca191014e77f..3313e53f74ce47838dc1fd68508f9dac1b28d93f 100644 (file)
@@ -163,34 +163,37 @@ int dhcp_identifier_set_iaid(
                 bool legacy_unstable_byteorder,
                 bool use_mac,
                 void *_id) {
+
         /* name is a pointer to memory in the sd_device struct, so must
          * have the same scope */
         _cleanup_(sd_device_unrefp) sd_device *device = NULL;
         const char *name = NULL;
-        uint64_t id;
         uint32_t id32;
+        uint64_t id;
         int r;
 
         if (path_is_read_only_fs("/sys") <= 0 && !use_mac) {
                 /* udev should be around */
 
-                if (sd_device_new_from_ifindex(&device, ifindex) >= 0) {
-                        r = sd_device_get_is_initialized(device);
-                        if (r < 0)
-                                return r;
-                        if (r == 0)
-                                /* not yet ready */
-                                return -EBUSY;
-
-                        r = device_is_renaming(device);
-                        if (r < 0)
-                                return r;
-                        if (r > 0)
-                                /* device is under renaming */
-                                return -EBUSY;
-
-                        name = net_get_name_persistent(device);
-                }
+                r = sd_device_new_from_ifindex(&device, ifindex);
+                if (r < 0)
+                        return r;
+
+                r = sd_device_get_is_initialized(device);
+                if (r < 0)
+                        return r;
+                if (r == 0)
+                        /* not yet ready */
+                        return -EBUSY;
+
+                r = device_is_renaming(device);
+                if (r < 0)
+                        return r;
+                if (r > 0)
+                        /* device is under renaming */
+                        return -EBUSY;
+
+                name = net_get_name_persistent(device);
         }
 
         if (name)