]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: introduce network- and protocol-independent default for UseDomains=
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 15 Apr 2024 05:55:18 +0000 (14:55 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 20 Apr 2024 03:01:53 +0000 (12:01 +0900)
Follow-up for fb573007430ab0dbe45517b58837d2fa5cfa1a48.

Prompted by #32273.

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

index 8820fcc507da1d02d0d708056a0d09b5ec700ab2..843636fd4fdeccba6a0b795c4dbcba1f6f4667de 100644 (file)
         <xi:include href="version-info.xml" xpointer="v254"/>
         </listitem>
       </varlistentry>
+
+      <varlistentry>
+        <term><varname>UseDomains=</varname></term>
+        <listitem>
+          <para>Specifies the network- and protocol-independent default value for the same settins in
+          [IPv6AcceptRA], [DHCPv4], and [DHCPv6] sections below. Takes a boolean, or the special value
+          <option>route</option>. See the same setting in
+          <citerefentry><refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
+          Defaults to <literal>no</literal>.</para>
+
+          <xi:include href="version-info.xml" xpointer="v256"/>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+
+  <refsect1>
+    <title>[IPv6AcceptRA] Section Options</title>
+
+    <para>This section configures the default setting of the Neighbor Discovery. The following options are
+    available in the [IPv6AcceptRA] section:</para>
+
+    <variablelist class='network-directives'>
+      <varlistentry>
+        <term><varname>UseDomains=</varname></term>
+        <listitem>
+          <para>Specifies the network-independent default value for the same setting in the [IPv6AcceptRA]
+          section in
+          <citerefentry><refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
+          Takes a boolean, or the special value <option>route</option>. When unspecified, the value specified
+          in the [Network] section in
+          <citerefentry><refentrytitle>networkd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
+          which defaults to <literal>no</literal>, will be used.</para>
+
+          <xi:include href="version-info.xml" xpointer="v256"/>
+        </listitem>
+      </varlistentry>
     </variablelist>
   </refsect1>
 
@@ -260,11 +297,9 @@ DUIDRawData=00:00:ab:11:f9:2a:c2:77:29:f9:5c:00</programlisting>
 
       <varlistentry>
         <term><varname>UseDomains=</varname></term>
-          <listitem><para>Specifies the default value for per-network <varname>UseDomains=</varname>.
-          Takes a boolean. See for details in
-          <citerefentry><refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
-          Defaults to <literal>no</literal>.</para>
-          
+        <listitem>
+          <para>Same as the one in the [IPv6AcceptRA] section, but applied for DHCPv4 protocol.</para>
+
           <xi:include href="version-info.xml" xpointer="v256"/>
         </listitem>
       </varlistentry>
@@ -310,12 +345,9 @@ DUIDRawData=00:00:ab:11:f9:2a:c2:77:29:f9:5c:00</programlisting>
 
     <variablelist class='network-directives'>
       <varlistentry>
-        <term><varname>PersistLeases=</varname></term>
+        <term><varname>UseDomains=</varname></term>
         <listitem>
-          <para>Specifies the default value for per-network <varname>PersistLeases=</varname>.
-          Takes a boolean. See for details in
-          <citerefentry><refentrytitle>systemd.network</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
-          Defaults to <literal>yes</literal>.</para>
+          <para>Same as the one in the [IPv6AcceptRA] section, but applied for DHCPv4 protocol.</para>
 
           <xi:include href="version-info.xml" xpointer="v256"/>
         </listitem>
index 5e8361f69af1be42d8157b63841db2ef173d1170..916eb5bffe7233fc55c0352615facb73e6c28ee6 100644 (file)
@@ -747,6 +747,17 @@ Table=1234</programlisting></para>
         </listitem>
       </varlistentry>
 
+      <varlistentry>
+        <term><varname>UseDomains=</varname></term>
+        <listitem>
+          <para>Specifies the protocol-independent default value for the same settins in
+          [IPv6AcceptRA], [DHCPv4], and [DHCPv6] sections below. Takes a boolean, or the special value
+          <option>route</option>. See also the same setting in [DHCPv4] below. Defaults to unset.</para>
+
+          <xi:include href="version-info.xml" xpointer="v256"/>
+        </listitem>
+      </varlistentry>
+
       <varlistentry>
         <term><varname>Domains=</varname></term>
         <listitem>
@@ -2571,9 +2582,15 @@ NFTSet=prefix:netdev:filter:eth_ipv4_prefix</programlisting>
           effect of the <option>Domains=</option> setting. If set to <option>route</option>, the domain name
           received from the DHCP server will be used for routing DNS queries only, but not for searching,
           similarly to the effect of the <option>Domains=</option> setting when the argument is prefixed with
-          <literal>~</literal>. When unspecified, the value specified in the same setting in
-          <citerefentry><refentrytitle>networkd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
-          which defaults to <literal>no</literal>, will be used.</para>
+          <literal>~</literal>.</para>
+
+          <para>When unspecified, the value specified in the same setting in the [Network] section will be
+          used. When it is unspecified, the value specified in the same setting in the [DHCPv4] section in
+          <citerefentry><refentrytitle>networkd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+          will be used. When it is unspecified, the value specified in the same setting in the [Network]
+          section in
+          <citerefentry><refentrytitle>networkd.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+          will be used. When none of them are specified, defaults to <literal>no</literal>.</para>
 
           <para>It is recommended to enable this option only on trusted networks, as setting this
           affects resolution of all hostnames, in particular of single-label names. It is generally
index 150ce624821f007c4cdd29b41d976d8cc7f7cba3..7078419d3750765095319d030a21b4fcb67f5974 100644 (file)
@@ -31,7 +31,7 @@ UseDomains link_get_use_domains(Link *link, NetworkConfigSource proto) {
         case NETWORK_CONFIG_SOURCE_NDISC:
                 n = link->network->ndisc_use_domains;
                 c = _USE_DOMAINS_INVALID;
-                m = _USE_DOMAINS_INVALID;
+                m = link->manager->ndisc_use_domains;
                 break;
         default:
                 assert_not_reached();
@@ -45,12 +45,16 @@ UseDomains link_get_use_domains(Link *link, NetworkConfigSource proto) {
         if (c >= 0)
                 return c;
 
+        /* If per-network but protocol-independent setting is specified, use it. */
+        if (link->network->use_domains >= 0)
+                return link->network->use_domains;
+
         /* If global per-protocol setting is specified, use it. */
         if (m >= 0)
                 return m;
 
-        /* Otherwise, defaults to no. */
-        return USE_DOMAINS_NO;
+        /* If none of them are specified, use the global protocol-independent value. */
+        return link->manager->use_domains;
 }
 
 bool link_get_use_dns(Link *link, NetworkConfigSource proto) {
index b2d116e98ded182fc932241d2d693998005c0af6..f02dfd7a05f9a87deb876cd2d720a89c88587824 100644 (file)
@@ -31,6 +31,8 @@ Network.RouteTable,                      config_parse_route_table_names,
 Network.IPv4Forwarding,                  config_parse_tristate,                  0,          offsetof(Manager, ip_forwarding[0])
 Network.IPv6Forwarding,                  config_parse_tristate,                  0,          offsetof(Manager, ip_forwarding[1])
 Network.IPv6PrivacyExtensions,           config_parse_ipv6_privacy_extensions,   0,          offsetof(Manager, ipv6_privacy_extensions)
+Network.UseDomains,                      config_parse_use_domains,               0,          offsetof(Manager, use_domains)
+IPv6AcceptRA.UseDomains,                 config_parse_use_domains,               0,          offsetof(Manager, ndisc_use_domains)
 DHCPv4.UseDomains,                       config_parse_use_domains,               0,          offsetof(Manager, dhcp_use_domains)
 DHCPv4.DUIDType,                         config_parse_duid_type,                 0,          offsetof(Manager, dhcp_duid)
 DHCPv4.DUIDRawData,                      config_parse_duid_rawdata,              0,          offsetof(Manager, dhcp_duid)
index 2d21c2bca574f02544f9f25b26c2b4d655cf4c1c..4ec4550caf3cb1f035f101f15dcbdeb96cfb96f8 100644 (file)
@@ -601,6 +601,7 @@ int manager_new(Manager **ret, bool test_mode) {
                 .persistent_storage_fd = persistent_storage_open(),
                 .dhcp_use_domains = _USE_DOMAINS_INVALID,
                 .dhcp6_use_domains = _USE_DOMAINS_INVALID,
+                .ndisc_use_domains = _USE_DOMAINS_INVALID,
                 .dhcp_duid.type = DUID_TYPE_EN,
                 .dhcp6_duid.type = DUID_TYPE_EN,
                 .duid_product_uuid.type = DUID_TYPE_UUID,
index 31ddbdf6174f10fd020725e21913f070014d36bf..c14a98fb9753e13e10d3bf199b76da166404e973 100644 (file)
@@ -64,8 +64,10 @@ struct Manager {
         OrderedSet *address_pools;
         Set *dhcp_pd_subnet_ids;
 
+        UseDomains use_domains; /* default for all protocols */
         UseDomains dhcp_use_domains;
         UseDomains dhcp6_use_domains;
+        UseDomains ndisc_use_domains;
 
         DUID dhcp_duid;
         DUID dhcp6_duid;
index 7084f82f9ff70edc14cc77101fbd5bac7a247f12..62f11c5c5c91823dec1f2c900e3bf37e8bed3e4a 100644 (file)
@@ -118,6 +118,7 @@ Network.EmitLLDP,                            config_parse_lldp_multicast_mode,
 Network.Address,                             config_parse_address,                                     0,                             0
 Network.Gateway,                             config_parse_gateway,                                     0,                             0
 Network.Domains,                             config_parse_domains,                                     0,                             0
+Network.UseDomains,                          config_parse_use_domains,                                 0,                             offsetof(Network, use_domains)
 Network.DNS,                                 config_parse_dns,                                         0,                             0
 Network.DNSDefaultRoute,                     config_parse_tristate,                                    0,                             offsetof(Network, dns_default_route)
 Network.LLMNR,                               config_parse_resolve_support,                             0,                             offsetof(Network, llmnr)
index 15d5721866a373f26f47fefbedd66d1dfc540969..c64091c15aecccae8bf93103d48898d4de07244a 100644 (file)
@@ -377,6 +377,8 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
 
                 .keep_configuration = manager->keep_configuration,
 
+                .use_domains = _USE_DOMAINS_INVALID,
+
                 .compat_dhcp_use_domains = _USE_DOMAINS_INVALID,
                 .compat_dhcp_use_dns = -1,
                 .compat_dhcp_use_ntp = -1,
@@ -489,6 +491,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
                 .ndisc_use_hop_limit = true,
                 .ndisc_use_reachable_time = true,
                 .ndisc_use_retransmission_time = true,
+                .ndisc_use_domains = _USE_DOMAINS_INVALID,
                 .ndisc_route_table = RT_TABLE_MAIN,
                 .ndisc_route_metric_high = IPV6RA_ROUTE_METRIC_HIGH,
                 .ndisc_route_metric_medium = IPV6RA_ROUTE_METRIC_MEDIUM,
index dd938e525aa830663f4659816efe7b779538f0eb..c8573e097342d75fac3db7dc6013bf3db6ea1bc0 100644 (file)
@@ -113,6 +113,9 @@ struct Network {
         bool default_route_on_device;
         AddressFamily ip_masquerade;
 
+        /* Protocol independent settings */
+        UseDomains use_domains;
+
         /* For backward compatibility, only applied to DHCPv4 and DHCPv6. */
         UseDomains compat_dhcp_use_domains;
         int compat_dhcp_use_dns;
index 828dbb96388a6230daf564e62da3ab64d6c0d07a..06d436245e7bbe66612d90b24593001fc150b546 100644 (file)
 #ManageForeignNextHops=yes
 #RouteTable=
 #IPv6PrivacyExtensions=no
+#UseDomains=no
+
+[IPv6AcceptRA]
+#UseDomains=
 
 [DHCPv4]
 #DUIDType=vendor
 #DUIDRawData=
-#UseDomains=no
+#UseDomains=
 
 [DHCPv6]
 #DUIDType=vendor
 #DUIDRawData=
-#UseDomains=no
+#UseDomains=
 
 [DHCPServer]
 #PersistLeases=yes