mirror of
https://github.com/systemd/systemd.git
synced 2025-01-25 10:04:04 +03:00
Merge pull request #32276 from yuwata/network-global-use-domains-setting
network: introduce protocol-independent UseDomains= setting
This commit is contained in:
commit
af46138f39
@ -159,6 +159,43 @@
|
||||
<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>
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -24,16 +24,20 @@
|
||||
#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
|
||||
|
@ -6909,9 +6909,11 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
|
||||
check(self, False, False)
|
||||
|
||||
def test_dhcp_client_default_use_domains(self):
|
||||
def check(self, ipv4, ipv6):
|
||||
def check(self, common, ipv4, ipv6):
|
||||
mkdir_p(networkd_conf_dropin_dir)
|
||||
with open(os.path.join(networkd_conf_dropin_dir, 'default_use_domains.conf'), mode='w', encoding='utf-8') as f:
|
||||
f.write('[Network]\nUseDomains=')
|
||||
f.write('yes\n' if common else 'no\n')
|
||||
f.write('[DHCPv4]\nUseDomains=')
|
||||
f.write('yes\n' if ipv4 else 'no\n')
|
||||
f.write('[DHCPv6]\nUseDomains=')
|
||||
@ -6932,7 +6934,7 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
|
||||
|
||||
for _ in range(20):
|
||||
output = resolvectl('domain', 'veth99')
|
||||
if ipv4 or ipv6:
|
||||
if common or ipv4 or ipv6:
|
||||
if 'example.com' in output:
|
||||
break
|
||||
else:
|
||||
@ -6941,16 +6943,18 @@ class NetworkdDHCPClientTests(unittest.TestCase, Utilities):
|
||||
time.sleep(0.5)
|
||||
else:
|
||||
print(output)
|
||||
print(read_link_state_file('veth99'))
|
||||
self.fail('unexpected domain setting in resolved...')
|
||||
|
||||
stop_dnsmasq()
|
||||
remove_networkd_conf_dropin('default_use_domains.conf')
|
||||
|
||||
copy_network_unit('25-veth.netdev', '25-dhcp-server-veth-peer.network', '25-dhcp-client.network', copy_dropins=False)
|
||||
check(self, True, True)
|
||||
check(self, True, False)
|
||||
check(self, False, True)
|
||||
check(self, False, False)
|
||||
check(self, True, False, False)
|
||||
check(self, False, True, True)
|
||||
check(self, False, True, False)
|
||||
check(self, False, False, True)
|
||||
check(self, False, False, False)
|
||||
|
||||
def test_dhcp_client_use_captive_portal(self):
|
||||
def check(self, ipv4, ipv6):
|
||||
|
Loading…
x
Reference in New Issue
Block a user