Skip to content

Commit 1536b7b

Browse files
committed
network: introduce new UseAddress= setting in [DHCPv6] section
If it is disabled, then the addresses provided by the DHCPv6 server will be ignored. Closes systemd#18203.
1 parent e2645ca commit 1536b7b

File tree

6 files changed

+18
-2
lines changed

6 files changed

+18
-2
lines changed

man/systemd.network.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,6 +1866,14 @@ IPv6Token=prefixstable:2002:da8:1::</programlisting></para>
18661866
<varname>DHCP=</varname> setting described above, or invoked by the IPv6 Router Advertisement:</para>
18671867

18681868
<variablelist class='network-directives'>
1869+
<varlistentry>
1870+
<term><varname>UseAddress=</varname></term>
1871+
<listitem>
1872+
<para>When true (the default), the IP addresses provided by the DHCPv6 server will be
1873+
assigned.</para>
1874+
</listitem>
1875+
</varlistentry>
1876+
18691877
<varlistentry>
18701878
<term><varname>UseDNS=</varname></term>
18711879
<term><varname>UseNTP=</varname></term>

src/network/networkd-dhcp6.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,8 +1078,12 @@ static int dhcp6_address_acquired(Link *link) {
10781078
int r;
10791079

10801080
assert(link);
1081+
assert(link->network);
10811082
assert(link->dhcp6_lease);
10821083

1084+
if (!link->network->dhcp6_use_address)
1085+
return 0;
1086+
10831087
for (sd_dhcp6_lease_reset_address_iter(link->dhcp6_lease);;) {
10841088
uint32_t lifetime_preferred, lifetime_valid;
10851089
struct in6_addr ip6_addr;

src/network/networkd-network-gperf.gperf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ DHCPv4.SendOption, config_parse_dhcp_send_option,
221221
DHCPv4.SendVendorOption, config_parse_dhcp_send_option, 0, offsetof(Network, dhcp_client_send_vendor_options)
222222
DHCPv4.RouteMTUBytes, config_parse_mtu, AF_INET, offsetof(Network, dhcp_route_mtu)
223223
DHCPv4.FallbackLeaseLifetimeSec, config_parse_dhcp_fallback_lease_lifetime, 0, 0
224+
DHCPv6.UseAddress, config_parse_bool, 0, offsetof(Network, dhcp6_use_address)
224225
DHCPv6.UseDNS, config_parse_dhcp_use_dns, 0, 0
225226
DHCPv6.UseNTP, config_parse_dhcp_use_ntp, 0, 0
226227
DHCPv6.RapidCommit, config_parse_bool, 0, offsetof(Network, dhcp6_rapid_commit)

src/network/networkd-network.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,11 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
352352
.dhcp_use_timezone = false,
353353
.dhcp_ip_service_type = -1,
354354

355+
.dhcp6_use_address = true,
356+
.dhcp6_use_dns = true,
357+
.dhcp6_use_ntp = true,
355358
.dhcp6_rapid_commit = true,
356359
.dhcp6_route_metric = DHCP_ROUTE_METRIC,
357-
.dhcp6_use_ntp = true,
358-
.dhcp6_use_dns = true,
359360

360361
.dhcp6_pd = -1,
361362
.dhcp6_pd_announce = true,

src/network/networkd-network.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ struct Network {
146146
OrderedHashmap *dhcp_client_send_vendor_options;
147147

148148
/* DHCPv6 Client support*/
149+
bool dhcp6_use_address;
149150
bool dhcp6_use_dns;
150151
bool dhcp6_use_dns_set;
151152
bool dhcp6_use_ntp;

test/fuzz/fuzz-network-parser/directives.network

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ MUDURL=
125125
RouteMTUBytes=
126126
FallbackLeaseLifetimeSec=
127127
[DHCPv6]
128+
UseAddress=
128129
UseNTP=
129130
UseDNS=
130131
RapidCommit=

0 commit comments

Comments
 (0)