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-23 14:58:13 +0200
commit7efc3c479f8abd46d601105c1f618d529352a86a (patch)
tree2831a84d700339afd37e55eef1e080bd88ba6dec
parent907bd2820330a5d1ebbcd356e44fde61a61e703d (diff)
downloadNetworkManager-7efc3c479f8abd46d601105c1f618d529352a86a.tar.gz
dhcp: truncate client-id for n-dhcp4 client at arbitrary limit
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 See-also: https://github.com/nettools/n-dhcp4/pull/6 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/307
-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;