]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: introduce system wide default setting for DHCPv4 client ID
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 30 Dec 2024 01:16:37 +0000 (10:16 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 30 Dec 2024 01:27:39 +0000 (10:27 +0900)
Typically, the same client identifier setting is used for all
interfaces. Hence, better to provide the system-wide setting to specify
the client identifier.

man/networkd.conf.xml
man/systemd.network.xml
src/network/networkd-dhcp4.c
src/network/networkd-gperf.gperf
src/network/networkd-manager.c
src/network/networkd-manager.h
src/network/networkd.conf

index e843e3d9b1e328eee7e10f6fb48f9a2b2a6d0385..1d5edfd45f28dbe8bb230daefcac439d1ecc67e6 100644 (file)
     <para>The following options are understood:</para>
 
     <variablelist class='network-directives'>
+      <varlistentry>
+        <term><varname>ClientIdentifier=</varname></term>
+        <listitem>
+          <para>Specifies the default DHCPv4 client identifier to be used. Takes one of <option>mac</option>
+          or <option>duid</option>. If set to <option>mac</option>, the MAC address of each link will be 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> in each matching
+          <filename>.network</filename> file. DUID can be configured by <varname>DUIDType=</varname> and
+          <varname>DUIDRawData=</varname>. Defaults to <option>duid</option>.</para>
+
+        <xi:include href="version-info.xml" xpointer="v258"/>
+        </listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><varname>DUIDType=</varname></term>
         <listitem><para>Specifies how the DUID should be generated. See
index 6ed4dde4df43e94934d6b3a2cf3baba3d7ad9f9e..1c26609917e24082e90a1add788f587ef653282c 100644 (file)
@@ -2371,8 +2371,11 @@ NFTSet=prefix:netdev:filter:eth_ipv4_prefix</programlisting>
           <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>
+          <varname>DUIDType=</varname> and <varname>DUIDRawData=</varname>. When
+          <varname>Anonymize=</varname> is enabled, <option>mac</option> is unconditionally used and the
+          specified value will be ignored. When unspecified, the value specified in the same setting in
+          <citerefentry><refentrytitle>networkd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+          will be used.</para>
 
         <xi:include href="version-info.xml" xpointer="v220"/>
         </listitem>
index d94ac1a213afbb60b862d77684a8763b3c60532b..30abef49a23a46a12a157f5d0a2b5c809357d01e 100644 (file)
@@ -52,7 +52,7 @@ void network_adjust_dhcp4(Network *network) {
         }
 
         if (network->dhcp_client_identifier < 0)
-                network->dhcp_client_identifier = network->dhcp_anonymize ? DHCP_CLIENT_ID_MAC : DHCP_CLIENT_ID_DUID;
+                network->dhcp_client_identifier = network->dhcp_anonymize ? DHCP_CLIENT_ID_MAC : network->manager->dhcp_client_identifier;
 
         /* By default, RapidCommit= is enabled when Anonymize=no and neither AllowList= nor DenyList= is specified. */
         if (network->dhcp_use_rapid_commit < 0)
index b69ef5fd31333edfb34600daf8abe0af1a0c5fbd..21e8d12690b14f864e49edbcf4c3f1036f73c169 100644 (file)
@@ -37,6 +37,7 @@ IPv6AcceptRA.UseDomains,                 config_parse_use_domains,
 IPv6AddressLabel.Prefix,                 config_parse_ipv6_address_label_section, IPV6_ADDRESS_LABEL_BY_MANAGER | IPV6_ADDRESS_LABEL_PREFIX, 0
 IPv6AddressLabel.Label,                  config_parse_ipv6_address_label_section, IPV6_ADDRESS_LABEL_BY_MANAGER | IPV6_ADDRESS_LABEL,        0
 DHCPv4.UseDomains,                       config_parse_use_domains,                0,                                                         offsetof(Manager, dhcp_use_domains)
+DHCPv4.ClientIdentifier,                 config_parse_dhcp_client_identifier,     0,                                                         offsetof(Manager, dhcp_client_identifier)
 DHCPv4.DUIDType,                         config_parse_duid_type,                  0,                                                         offsetof(Manager, dhcp_duid)
 DHCPv4.DUIDRawData,                      config_parse_duid_rawdata,               0,                                                         offsetof(Manager, dhcp_duid)
 DHCPv6.UseDomains,                       config_parse_use_domains,                0,                                                         offsetof(Manager, dhcp6_use_domains)
index 829937958b4c23b14bc7e025aa0678a73ac6c5f5..8061976d7b9cd7cc5b260223bb3890bd65b0064b 100644 (file)
@@ -647,6 +647,7 @@ int manager_new(Manager **ret, bool test_mode) {
                 .dhcp_use_domains = _USE_DOMAINS_INVALID,
                 .dhcp6_use_domains = _USE_DOMAINS_INVALID,
                 .ndisc_use_domains = _USE_DOMAINS_INVALID,
+                .dhcp_client_identifier = DHCP_CLIENT_ID_DUID,
                 .dhcp_duid.type = DUID_TYPE_EN,
                 .dhcp6_duid.type = DUID_TYPE_EN,
                 .duid_product_uuid.type = DUID_TYPE_UUID,
index faa335715169db1793a0eb73a2b577f36fc27e11..9891b8c1fc0f44cb54899f53d3dcd701693ac2ee 100644 (file)
@@ -78,6 +78,7 @@ struct Manager {
         UseDomains dhcp6_use_domains;
         UseDomains ndisc_use_domains;
 
+        DHCPClientIdentifier dhcp_client_identifier;
         DUID dhcp_duid;
         DUID dhcp6_duid;
         DUID duid_product_uuid;
index 857df0899f32b1d481fb1e41fcf2690b579ce671..a5a9418bbb1942b6533eb8f7256f21d693623582 100644 (file)
@@ -36,6 +36,7 @@
 #UseDomains=
 
 [DHCPv4]
+#ClientIdentifier=duid
 #DUIDType=vendor
 #DUIDRawData=
 #UseDomains=