From: Yu Watanabe Date: Sat, 15 Jul 2023 05:35:28 +0000 (+0900) Subject: network,dhcp: drop support of ClientIdentifier=duid-only X-Git-Tag: v255-rc1~901^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d8f19e03c09f3df3e30767ae32b9318107c554ff;p=thirdparty%2Fsystemd.git network,dhcp: drop support of ClientIdentifier=duid-only 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. --- diff --git a/man/systemd.network.xml b/man/systemd.network.xml index 56c02e18dbb..95b41b28c09 100644 --- a/man/systemd.network.xml +++ b/man/systemd.network.xml @@ -1789,12 +1789,12 @@ allow my_server_t localnet_peer_t:peer recv; ClientIdentifier= - The DHCPv4 client identifier to use. Takes one of , - or . If set to , the - MAC address of the link is used. If set to , an RFC4361-compliant Client - ID, which is the combination of IAID and DUID (see below), is used. If set to - , only DUID is used, this may not be RFC compliant, but some setups - may require to use this. Defaults to . + The DHCPv4 client identifier to use. Takes one of or + . If set to , the MAC address of the link is used. If set + to , an RFC4361-compliant Client ID, which is the combination of IAID and + DUID, is used. IAID can be configured by IAID=. DUID can be configured by + DUIDType= and DUIDRawData=. Defaults to + . diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c index e5a1fdcd54a..aaca8b792e8 100644 --- a/src/libsystemd-network/sd-dhcp-client.c +++ b/src/libsystemd-network/sd-dhcp-client.c @@ -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) { diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c index e2fe836f2c7..4f89cdd8579 100644 --- a/src/network/networkd-dhcp4.c +++ b/src/network/networkd-dhcp4.c @@ -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); diff --git a/src/network/networkd-dhcp4.h b/src/network/networkd-dhcp4.h index 0f14e079433..7446f0a1311 100644 --- a/src/network/networkd-dhcp4.h +++ b/src/network/networkd-dhcp4.h @@ -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; diff --git a/src/systemd/sd-dhcp-client.h b/src/systemd/sd-dhcp-client.h index 2b8fddcf046..7339bb68724 100644 --- a/src/systemd/sd-dhcp-client.h +++ b/src/systemd/sd-dhcp-client.h @@ -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,