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
This commit is contained in:
Jon Ringle 2017-08-30 05:38:00 -04:00 committed by Lennart Poettering
parent 30495cb0a7
commit e4f05508ad
1 changed files with 24 additions and 9 deletions

View File

@ -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) {