From: Jon Ringle Date: Wed, 30 Aug 2017 09:38:00 +0000 (-0400) Subject: networkd: Honor configured DHCP ClientIdentifier on link_update (#6622) X-Git-Tag: v235~213 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e4f05508add524cbde0a8d63752d3620c954edcb;p=thirdparty%2Fsystemd.git networkd: Honor configured DHCP ClientIdentifier on link_update (#6622) We have an embedded board with a couple of ethernet ports. From the kernel log, I can see that the ethernet drivers are obtaining their correct MAC address, but for some reason, at first systemd-networkd doesn't see the mac address for the ethernet port at the time that it looks at dhcp_client_identifier configuration (it has 00:00:00:00:00:00 for mac). Later on, systemd-networkd gets a link_update() call, and at this time, it has the correct mac address for the ethernet port. However, in link_update() the dhcp_client_identifier configuration is not being considered, and a call to sd_dhcp_client_set_iaid_duid() is being done always --- diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 03b8f8c3c40..cba08738713 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -3186,8 +3186,6 @@ int link_update(Link *link, sd_netlink_message *m) { } if (link->dhcp_client) { - const DUID *duid = link_duid(link); - r = sd_dhcp_client_set_mac(link->dhcp_client, (const uint8_t *) &link->mac, sizeof (link->mac), @@ -3195,13 +3193,30 @@ int link_update(Link *link, sd_netlink_message *m) { if (r < 0) return log_link_warning_errno(link, r, "Could not update MAC address in DHCP client: %m"); - r = sd_dhcp_client_set_iaid_duid(link->dhcp_client, - link->network->iaid, - duid->type, - duid->raw_data_len > 0 ? duid->raw_data : NULL, - duid->raw_data_len); - if (r < 0) - return log_link_warning_errno(link, r, "Could not update DUID/IAID in DHCP client: %m"); + switch (link->network->dhcp_client_identifier) { + case DHCP_CLIENT_ID_DUID: { + const DUID *duid = link_duid(link); + + r = sd_dhcp_client_set_iaid_duid(link->dhcp_client, + link->network->iaid, + duid->type, + duid->raw_data_len > 0 ? duid->raw_data : NULL, + duid->raw_data_len); + if (r < 0) + return log_link_warning_errno(link, r, "Could not update DUID/IAID in DHCP client: %m"); + break; + } + case DHCP_CLIENT_ID_MAC: + r = sd_dhcp_client_set_client_id(link->dhcp_client, + ARPHRD_ETHER, + (const uint8_t *)&link->mac, + sizeof(link->mac)); + if(r < 0) + return log_link_warning_errno(link, r, "Could not update MAC client id in DHCP client: %m"); + break; + default: + assert_not_reached("Unknown client identifier type."); + } } if (link->dhcp6_client) {