]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network,dhcp: drop support of ClientIdentifier=duid-only
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 15 Jul 2023 05:35:28 +0000 (14:35 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 29 Jul 2023 09:51:09 +0000 (18:51 +0900)
The setting has not been never worked, not tested, and should not been
used. As the option is RFC incompliant. Let's drop it.

Closes #25562.

man/systemd.network.xml
src/libsystemd-network/sd-dhcp-client.c
src/network/networkd-dhcp4.c
src/network/networkd-dhcp4.h
src/systemd/sd-dhcp-client.h

index 56c02e18dbb397a4c5c5c18676fa55467c484e64..95b41b28c098cff405b9e180a0aff46d6e8f51de 100644 (file)
@@ -1789,12 +1789,12 @@ allow my_server_t localnet_peer_t:peer recv;</programlisting>
       <varlistentry>
         <term><varname>ClientIdentifier=</varname></term>
         <listitem>
-          <para>The DHCPv4 client identifier to use. Takes one of <option>mac</option>,
-          <option>duid</option> or <option>duid-only</option>. If set to <option>mac</option>, the
-          MAC address of the link is used. If set to <option>duid</option>, an RFC4361-compliant Client
-          ID, which is the combination of IAID and DUID (see below), is used. If set to
-          <option>duid-only</option>, only DUID is used, this may not be RFC compliant, but some setups
-          may require to use this. Defaults to <option>duid</option>.</para>
+          <para>The DHCPv4 client identifier to use. Takes one of <option>mac</option> or
+          <option>duid</option>. If set to <option>mac</option>, the MAC address of the link is used. If set
+          to <option>duid</option>, an RFC4361-compliant Client ID, which is the combination of IAID and
+          DUID, is used. IAID can be configured by <varname>IAID=</varname>. DUID can be configured by
+          <varname>DUIDType=</varname> and <varname>DUIDRawData=</varname>. Defaults to
+          <option>duid</option>.</para>
         </listitem>
       </varlistentry>
 
index e5a1fdcd54a3a8002e31e874bab72fa2337ded06..aaca8b792e86c5ac5fcfbf69aea07568d840abaa 100644 (file)
@@ -404,7 +404,6 @@ int sd_dhcp_client_set_client_id(
  */
 static int dhcp_client_set_iaid_duid_internal(
                 sd_dhcp_client *client,
-                bool iaid_append,
                 bool iaid_set,
                 uint32_t iaid,
                 DUIDType duid_type,
@@ -428,16 +427,14 @@ static int dhcp_client_set_iaid_duid_internal(
         zero(client->client_id);
         client->client_id.type = 255;
 
-        if (iaid_append) {
-                if (iaid_set)
-                        client->client_id.ns.iaid = htobe32(iaid);
-                else {
-                        r = dhcp_identifier_set_iaid(client->dev, &client->hw_addr,
-                                                     /* legacy_unstable_byteorder = */ true,
-                                                     &client->client_id.ns.iaid);
-                        if (r < 0)
-                                return log_dhcp_client_errno(client, r, "Failed to set IAID: %m");
-                }
+        if (iaid_set)
+                client->client_id.ns.iaid = htobe32(iaid);
+        else {
+                r = dhcp_identifier_set_iaid(client->dev, &client->hw_addr,
+                                             /* legacy_unstable_byteorder = */ true,
+                                             &client->client_id.ns.iaid);
+                if (r < 0)
+                        return log_dhcp_client_errno(client, r, "Failed to set IAID: %m");
         }
 
         if (duid) {
@@ -459,8 +456,7 @@ static int dhcp_client_set_iaid_duid_internal(
                                                      duid_type_to_string(duid_type));
         }
 
-        client->client_id_len = sizeof(client->client_id.type) + len +
-                                (iaid_append ? sizeof(client->client_id.ns.iaid) : 0);
+        client->client_id_len = sizeof(client->client_id.type) + sizeof(client->client_id.ns.iaid) + len;
 
         return 0;
 }
@@ -472,7 +468,7 @@ int sd_dhcp_client_set_iaid_duid(
                 uint16_t duid_type,
                 const void *duid,
                 size_t duid_len) {
-        return dhcp_client_set_iaid_duid_internal(client, true, iaid_set, iaid, duid_type, duid, duid_len, 0);
+        return dhcp_client_set_iaid_duid_internal(client, iaid_set, iaid, duid_type, duid, duid_len, 0);
 }
 
 int sd_dhcp_client_set_iaid_duid_llt(
@@ -480,21 +476,7 @@ int sd_dhcp_client_set_iaid_duid_llt(
                 bool iaid_set,
                 uint32_t iaid,
                 usec_t llt_time) {
-        return dhcp_client_set_iaid_duid_internal(client, true, iaid_set, iaid, DUID_TYPE_LLT, NULL, 0, llt_time);
-}
-
-int sd_dhcp_client_set_duid(
-                sd_dhcp_client *client,
-                uint16_t duid_type,
-                const void *duid,
-                size_t duid_len) {
-        return dhcp_client_set_iaid_duid_internal(client, false, false, 0, duid_type, duid, duid_len, 0);
-}
-
-int sd_dhcp_client_set_duid_llt(
-                sd_dhcp_client *client,
-                usec_t llt_time) {
-        return dhcp_client_set_iaid_duid_internal(client, false, false, 0, DUID_TYPE_LLT, NULL, 0, llt_time);
+        return dhcp_client_set_iaid_duid_internal(client, iaid_set, iaid, DUID_TYPE_LLT, NULL, 0, llt_time);
 }
 
 void dhcp_client_set_test_mode(sd_dhcp_client *client, bool test_mode) {
index e2fe836f2c7f19ce9aa9924399fddf5bc19865b7..4f89cdd8579c5cdd3b15051497f94289050c1209 100644 (file)
@@ -1260,22 +1260,6 @@ static int dhcp4_set_client_identifier(Link *link) {
                         return log_link_debug_errno(link, r, "DHCPv4 CLIENT: Failed to set IAID+DUID: %m");
                 break;
         }
-        case DHCP_CLIENT_ID_DUID_ONLY: {
-                /* If configured, apply user specified DUID */
-                const DUID *duid = link_get_dhcp4_duid(link);
-
-                if (duid->type == DUID_TYPE_LLT && duid->raw_data_len == 0)
-                        r = sd_dhcp_client_set_duid_llt(link->dhcp_client,
-                                                        duid->llt_time);
-                else
-                        r = sd_dhcp_client_set_duid(link->dhcp_client,
-                                                    duid->type,
-                                                    duid->raw_data_len > 0 ? duid->raw_data : NULL,
-                                                    duid->raw_data_len);
-                if (r < 0)
-                        return log_link_debug_errno(link, r, "DHCPv4 CLIENT: Failed to set DUID: %m");
-                break;
-        }
         case DHCP_CLIENT_ID_MAC: {
                 const uint8_t *hw_addr = link->hw_addr.bytes;
                 size_t hw_addr_len = link->hw_addr.length;
@@ -1595,8 +1579,9 @@ int dhcp4_start(Link *link) {
 
 static int dhcp4_configure_duid(Link *link) {
         assert(link);
+        assert(link->network);
 
-        if (!IN_SET(link->network->dhcp_client_identifier, DHCP_CLIENT_ID_DUID, DHCP_CLIENT_ID_DUID_ONLY))
+        if (link->network->dhcp_client_identifier != DHCP_CLIENT_ID_DUID)
                 return 1;
 
         return dhcp_configure_duid(link, link_get_dhcp4_duid(link));
@@ -1832,9 +1817,8 @@ int config_parse_dhcp_label(
 }
 
 static const char* const dhcp_client_identifier_table[_DHCP_CLIENT_ID_MAX] = {
-        [DHCP_CLIENT_ID_MAC] = "mac",
+        [DHCP_CLIENT_ID_MAC]  = "mac",
         [DHCP_CLIENT_ID_DUID] = "duid",
-        [DHCP_CLIENT_ID_DUID_ONLY] = "duid-only",
 };
 
 DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING(dhcp_client_identifier, DHCPClientIdentifier);
index 0f14e0794333c28bd69225d5278312512b071010..7446f0a1311441d28e69356f701503caddb2863f 100644 (file)
@@ -9,11 +9,6 @@ typedef struct Network Network;
 typedef enum DHCPClientIdentifier {
         DHCP_CLIENT_ID_MAC,
         DHCP_CLIENT_ID_DUID,
-        /* The following option may not be good for RFC regarding DHCP (3315 and 4361).
-         * But some setups require this. E.g., Sky Broadband, the second largest provider in the UK
-         * requires the client id to be set to a custom string, reported at
-         * https://github.com/systemd/systemd/issues/7828 */
-        DHCP_CLIENT_ID_DUID_ONLY,
         _DHCP_CLIENT_ID_MAX,
         _DHCP_CLIENT_ID_INVALID = -EINVAL,
 } DHCPClientIdentifier;
index 2b8fddcf046df912460edd9f9446638bea36ba8b..7339bb687248c07b80e22fb3fa9337f96ea6a778 100644 (file)
@@ -269,14 +269,6 @@ __extension__ int sd_dhcp_client_set_iaid_duid_llt(
                 bool iaid_set,
                 uint32_t iaid,
                 uint64_t llt_time);
-int sd_dhcp_client_set_duid(
-                sd_dhcp_client *client,
-                uint16_t duid_type,
-                const void *duid,
-                size_t duid_len);
-int sd_dhcp_client_set_duid_llt(
-                sd_dhcp_client *client,
-                uint64_t llt_time);
 int sd_dhcp_client_get_client_id(
                 sd_dhcp_client *client,
                 uint8_t *ret_type,