From f90635f14fb6ff67905ffa16cc4683dbdeda8212 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 14 Apr 2021 13:14:30 +0900 Subject: [PATCH] network: dhcp4: warn when Anonymize=yes and ClientIdentifier= is not mac --- src/network/networkd-dhcp4.c | 17 ++++++++++++----- src/network/networkd-network.c | 3 +-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c index 067247f497..33f501b593 100644 --- a/src/network/networkd-dhcp4.c +++ b/src/network/networkd-dhcp4.c @@ -35,13 +35,20 @@ void network_adjust_dhcp4(Network *network) { if (network->dhcp_use_gateway < 0) network->dhcp_use_gateway = network->dhcp_use_routes; - if (network->dhcp_anonymize) { - /* RFC7844 section 3.: MAY contain the Client Identifier option - * Section 3.5: clients MUST use client identifiers based solely on the link-layer address - * NOTE: Using MAC, as it does not reveal extra information, and some servers might not - * answer if this option is not sent */ + /* RFC7844 section 3.: MAY contain the Client Identifier option + * Section 3.5: clients MUST use client identifiers based solely on the link-layer address + * NOTE: Using MAC, as it does not reveal extra information, and some servers might not answer + * if this option is not sent */ + if (network->dhcp_anonymize && + network->dhcp_client_identifier >= 0 && + network->dhcp_client_identifier != DHCP_CLIENT_ID_MAC) { + log_warning("%s: ClientIdentifier= is set, although Anonymize=yes. Using ClientIdentifier=mac.", + network->filename); network->dhcp_client_identifier = DHCP_CLIENT_ID_MAC; } + + if (network->dhcp_client_identifier < 0) + network->dhcp_client_identifier = network->dhcp_anonymize ? DHCP_CLIENT_ID_MAC : DHCP_CLIENT_ID_DUID; } static int dhcp4_release_old_lease(Link *link) { diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index ca3582cc8e..03eaf6f5dd 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -312,8 +312,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi .dhcp_send_hostname = true, .dhcp_send_release = true, .dhcp_route_metric = DHCP_ROUTE_METRIC, - /* NOTE: this var might be overwritten by network_adjust_dhcp4() */ - .dhcp_client_identifier = DHCP_CLIENT_ID_DUID, + .dhcp_client_identifier = _DHCP_CLIENT_ID_INVALID, .dhcp_route_table = RT_TABLE_MAIN, .dhcp_ip_service_type = -1, -- 2.25.1