From: Yu Watanabe Date: Wed, 9 Jun 2021 14:47:59 +0000 (+0900) Subject: sd-dhcp: refuse to set iaid if we cannot find the interface X-Git-Tag: v249-rc1~28^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=af7b405dff9c32bc76cbc673103194e4d5ac9918;p=thirdparty%2Fsystemd.git sd-dhcp: refuse to set iaid if we cannot find the interface --- diff --git a/src/libsystemd-network/dhcp-identifier.c b/src/libsystemd-network/dhcp-identifier.c index d1ea992d43c..3313e53f74c 100644 --- a/src/libsystemd-network/dhcp-identifier.c +++ b/src/libsystemd-network/dhcp-identifier.c @@ -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)