network: introduce new UseAddress= setting in [DHCPv6] section

If it is disabled, then the addresses provided by the DHCPv6 server will
be ignored.

Closes #18203.
This commit is contained in:
Yu Watanabe 2021-01-12 00:02:09 +09:00
parent e2645ca619
commit 1536b7b2d0
6 changed files with 18 additions and 2 deletions

View file

@ -1866,6 +1866,14 @@ IPv6Token=prefixstable:2002:da8:1::</programlisting></para>
<varname>DHCP=</varname> setting described above, or invoked by the IPv6 Router Advertisement:</para>
<variablelist class='network-directives'>
<varlistentry>
<term><varname>UseAddress=</varname></term>
<listitem>
<para>When true (the default), the IP addresses provided by the DHCPv6 server will be
assigned.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>UseDNS=</varname></term>
<term><varname>UseNTP=</varname></term>

View file

@ -1078,8 +1078,12 @@ static int dhcp6_address_acquired(Link *link) {
int r;
assert(link);
assert(link->network);
assert(link->dhcp6_lease);
if (!link->network->dhcp6_use_address)
return 0;
for (sd_dhcp6_lease_reset_address_iter(link->dhcp6_lease);;) {
uint32_t lifetime_preferred, lifetime_valid;
struct in6_addr ip6_addr;

View file

@ -221,6 +221,7 @@ DHCPv4.SendOption, config_parse_dhcp_send_option,
DHCPv4.SendVendorOption, config_parse_dhcp_send_option, 0, offsetof(Network, dhcp_client_send_vendor_options)
DHCPv4.RouteMTUBytes, config_parse_mtu, AF_INET, offsetof(Network, dhcp_route_mtu)
DHCPv4.FallbackLeaseLifetimeSec, config_parse_dhcp_fallback_lease_lifetime, 0, 0
DHCPv6.UseAddress, config_parse_bool, 0, offsetof(Network, dhcp6_use_address)
DHCPv6.UseDNS, config_parse_dhcp_use_dns, 0, 0
DHCPv6.UseNTP, config_parse_dhcp_use_ntp, 0, 0
DHCPv6.RapidCommit, config_parse_bool, 0, offsetof(Network, dhcp6_rapid_commit)

View file

@ -352,10 +352,11 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
.dhcp_use_timezone = false,
.dhcp_ip_service_type = -1,
.dhcp6_use_address = true,
.dhcp6_use_dns = true,
.dhcp6_use_ntp = true,
.dhcp6_rapid_commit = true,
.dhcp6_route_metric = DHCP_ROUTE_METRIC,
.dhcp6_use_ntp = true,
.dhcp6_use_dns = true,
.dhcp6_pd = -1,
.dhcp6_pd_announce = true,

View file

@ -146,6 +146,7 @@ struct Network {
OrderedHashmap *dhcp_client_send_vendor_options;
/* DHCPv6 Client support*/
bool dhcp6_use_address;
bool dhcp6_use_dns;
bool dhcp6_use_dns_set;
bool dhcp6_use_ntp;

View file

@ -125,6 +125,7 @@ MUDURL=
RouteMTUBytes=
FallbackLeaseLifetimeSec=
[DHCPv6]
UseAddress=
UseNTP=
UseDNS=
RapidCommit=