1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-27 07:22:31 +03:00

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,18 +163,22 @@ 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_new_from_ifindex(&device, ifindex);
if (r < 0)
return r;
r = sd_device_get_is_initialized(device);
if (r < 0)
return r;
@ -191,7 +195,6 @@ int dhcp_identifier_set_iaid(
name = net_get_name_persistent(device);
}
}
if (name)
id = siphash24(name, strlen(name), HASH_KEY.bytes);