hn = hostname;
}
- return sd_dhcp_client_set_hostname(link->dhcp_client, hn);
+ r = sd_dhcp_client_set_hostname(link->dhcp_client, hn);
+ if (r == -EINVAL && hostname)
+ /* Ignore error when the machine's hostname is not suitable to send in DHCP packet. */
+ log_link_warning_errno(link, r, "DHCP4 CLIENT: Failed to set hostname from kernel hostname, ignoring: %m");
+ else if (r < 0)
+ return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to set hostname: %m");
+
+ return 0;
}
static bool promote_secondaries_enabled(const char *ifname) {
r = dhcp4_set_hostname(link);
if (r < 0)
- return log_link_error_errno(link, r, "DHCP4 CLIENT: Failed to set hostname: %m");
+ return r;
if (link->network->dhcp_vendor_class_identifier) {
r = sd_dhcp_client_set_vendor_class_identifier(link->dhcp_client,
hn = hostname;
}
- return sd_dhcp6_client_set_fqdn(client, hn);
+ r = sd_dhcp6_client_set_fqdn(client, hn);
+ if (r == -EINVAL && hostname)
+ /* Ignore error when the machine's hostname is not suitable to send in DHCP packet. */
+ log_link_warning_errno(link, r, "DHCP6 CLIENT: Failed to set hostname from kernel hostname, ignoring: %m");
+ else if (r < 0)
+ return log_link_error_errno(link, r, "DHCP6 CLIENT: Failed to set hostname: %m");
+
+ return 0;
}
int dhcp6_configure(Link *link) {
r = dhcp6_set_hostname(client, link);
if (r < 0)
- return log_link_error_errno(link, r, "DHCP6 CLIENT: Failed to set hostname: %m");
+ return r;
r = sd_dhcp6_client_set_ifindex(client, link->ifindex);
if (r < 0)