summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-10-14 12:35:30 +0200
committerThomas Haller <thaller@redhat.com>2019-10-14 12:46:26 +0200
commite236b686bddbad43ce7095a55c1ef9fe00d27101 (patch)
tree24f321bc813d25987eff5787dba93fe3328749a3
parent7fed51fa7b13b9ff2647128fda027f496e40e3c6 (diff)
downloadNetworkManager-th/n-dhcp4-max-client-id-len.tar.gz
dhcp: truncate client-id for n-dhcp4 client at arbitrary limitth/n-dhcp4-max-client-id-len
RFC does not define how long the client ID can be. However, n-dhcp4 enforces that the server replies with a client ID that matches the request. Also, the client ID gets encoded as a DHCP option, hence it cannot be longer than 255 bytes. While n-dhcp4 doesn't enforce a certain length, a too long client ID is not going to work. Hence, truncate it at 133 bytes. This is the same limit that also systemd's DHCP client has. It's chosen to fit an RFC4361-complient client ID with a DUID of length MAX_DUID_LEN (which is 128 bytes according to RFC 3315 section 9.1). Fixes-test: @ipv4_set_very_long_dhcp_client_id
-rw-r--r--src/dhcp/nm-dhcp-nettools.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/dhcp/nm-dhcp-nettools.c b/src/dhcp/nm-dhcp-nettools.c
index 35ed7d0b84..49743eb148 100644
--- a/src/dhcp/nm-dhcp-nettools.c
+++ b/src/dhcp/nm-dhcp-nettools.c
@@ -1096,7 +1096,9 @@ nettools_create (NMDhcpNettools *self,
n_dhcp4_client_config_set_transport (config, transport);
n_dhcp4_client_config_set_mac (config, hwaddr_arr, hwaddr_len);
n_dhcp4_client_config_set_broadcast_mac (config, bcast_hwaddr_arr, bcast_hwaddr_len);
- r = n_dhcp4_client_config_set_client_id (config, client_id_arr, client_id_len);
+ r = n_dhcp4_client_config_set_client_id (config,
+ client_id_arr,
+ NM_MIN (client_id_len, 1 + _NM_SD_MAX_CLIENT_ID_LEN));
if (r) {
nm_utils_error_set_errno (error, r, "failed to set client-id: %s");
return FALSE;