Commit a4c3ebed authored by Thomas Haller's avatar Thomas Haller

dhcp: abort DHCP on devices without MAC address early

Internal DHCPv4 client requires a valid MAC address for functioning.
Just always require a MAC address to start DHCP, both v4 and v6.

We have no MAC address for example on Layer3 devices like tun or wireguard.

Also, before "0a797bdc systemd/dhcp: fix assertion starting DHCP
client without MAC address", if we tired to start sd_dhcp_client without
setting a MAC address, an assertion was triggered.

(cherry picked from commit e8fa75ce)
parent 0a797bdc
......@@ -178,6 +178,7 @@ client_start (NMDhcpManager *self,
NMDhcpManagerPrivate *priv;
NMDhcpClient *client;
gboolean success = FALSE;
gsize hwaddr_len;
g_return_val_if_fail (NM_IS_DHCP_MANAGER (self), NULL);
g_return_val_if_fail (ifindex > 0, NULL);
......@@ -185,6 +186,22 @@ client_start (NMDhcpManager *self,
g_return_val_if_fail (!dhcp_client_id || g_bytes_get_size (dhcp_client_id) >= 2, NULL);
g_return_val_if_fail (!error || !*error, NULL);
if (!hwaddr) {
nm_utils_error_set (error,
"missing MAC address");
return NULL;
hwaddr_len = g_bytes_get_size (hwaddr);
if ( hwaddr_len == 0
|| hwaddr_len > NM_UTILS_HWADDR_LEN_MAX) {
nm_utils_error_set (error,
"invalid MAC address");
g_return_val_if_reached (NULL) ;
nm_assert (priv->client_factory);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment