]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: dhcp4: warn when Anonymize=yes and ClientIdentifier= is not mac
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 14 Apr 2021 04:14:30 +0000 (13:14 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 14 Apr 2021 05:15:11 +0000 (14:15 +0900)
src/network/networkd-dhcp4.c
src/network/networkd-network.c

index 067247f4973cdf76ef8197fdc80631cec893df66..33f501b59388ccf36fb9ae5ff14cd33558122a18 100644 (file)
@@ -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) {
index ca3582cc8ea9765c1fb5e5bf9f480c0b25ed6fb1..03eaf6f5dd40cd91db8708f76547423f3066aee1 100644 (file)
@@ -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,