sd-dhcp: refuse to set iaid if we cannot find the interface

This commit is contained in:
Yu Watanabe 2021-06-09 23:47:59 +09:00
parent 8d71f2b3a6
commit af7b405dff

View 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 = sd_device_new_from_ifindex(&device, ifindex);
if (r < 0)
return r;
r = device_is_renaming(device);
if (r < 0)
return r;
if (r > 0)
/* device is under renaming */
return -EBUSY;
r = sd_device_get_is_initialized(device);
if (r < 0)
return r;
if (r == 0)
/* not yet ready */
return -EBUSY;
name = net_get_name_persistent(device);
}
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)