network: attach device to DHCP clients

The attached sd_device object will be used later.
This commit is contained in:
Yu Watanabe
2022-10-26 08:08:35 +09:00
parent 793178b987
commit 3b1dbdf0c2
3 changed files with 20 additions and 0 deletions
+4
View File
@@ -1357,6 +1357,10 @@ static int dhcp4_configure(Link *link) {
if (r < 0)
return log_link_debug_errno(link, r, "DHCPv4 CLIENT: Failed to attach event to DHCPv4 client: %m");
r = sd_dhcp_client_attach_device(link->dhcp_client, link->dev);
if (r < 0)
return log_link_debug_errno(link, r, "DHCPv4 CLIENT: Failed to attach device: %m");
r = sd_dhcp_client_set_mac(link->dhcp_client,
link->hw_addr.bytes,
link->bcast_addr.length > 0 ? link->bcast_addr.bytes : NULL,
+4
View File
@@ -594,6 +594,10 @@ static int dhcp6_configure(Link *link) {
if (r < 0)
return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to attach event: %m");
r = sd_dhcp6_client_attach_device(client, link->dev);
if (r < 0)
return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to attach device: %m");
r = dhcp6_set_identifier(link, client);
if (r < 0)
return log_link_debug_errno(link, r, "DHCPv6 CLIENT: Failed to set identifier: %m");
+12
View File
@@ -1410,6 +1410,18 @@ static int link_initialized(Link *link, sd_device *device) {
* or sysattrs) may be outdated. */
device_unref_and_replace(link->dev, device);
if (link->dhcp_client) {
r = sd_dhcp_client_attach_device(link->dhcp_client, link->dev);
if (r < 0)
log_link_warning_errno(link, r, "Failed to attach device to DHCPv4 client, ignoring: %m");
}
if (link->dhcp6_client) {
r = sd_dhcp6_client_attach_device(link->dhcp6_client, link->dev);
if (r < 0)
log_link_warning_errno(link, r, "Failed to attach device to DHCPv6 client, ignoring: %m");
}
r = link_set_sr_iov_ifindices(link);
if (r < 0)
log_link_warning_errno(link, r, "Failed to manage SR-IOV PF and VF ports, ignoring: %m");