summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2021-01-13 21:52:44 +0100
committerGitHub <noreply@github.com>2021-01-13 21:52:44 +0100
commitce0079d75e792a30ee3363bdd6330ecff02677c7 (patch)
tree4350a15c2b245fc11ecbe86781dbd581d2044369
parent984aaaa3c646d0f83782b5bc7d475b32e0f1c325 (diff)
parentfec1b650adca8a92ca3d3aa9c8ef32c72bb43310 (diff)
downloadsystemd-ce0079d75e792a30ee3363bdd6330ecff02677c7.tar.gz
Merge pull request #18227 from yuwata/network-dhcp6-pd-manage-temporary-address
network: introduce ManageTemporaryAddress= setting in [DHCPv6PrefixDelegation] section
-rw-r--r--man/systemd.network.xml11
-rw-r--r--src/network/networkd-dhcp6.c28
-rw-r--r--src/network/networkd-network-gperf.gperf1
-rw-r--r--src/network/networkd-network.c1
-rw-r--r--src/network/networkd-network.h1
-rw-r--r--test/fuzz/fuzz-network-parser/directives.network1
6 files changed, 30 insertions, 13 deletions
diff --git a/man/systemd.network.xml b/man/systemd.network.xml
index 5ad9a846f0..fa80bdc51b 100644
--- a/man/systemd.network.xml
+++ b/man/systemd.network.xml
@@ -1081,11 +1081,11 @@ IPv6Token=prefixstable:2002:da8:1::</programlisting></para>
<listitem>
<para>Takes a boolean. If true the kernel manage temporary addresses created
from this one as template on behalf of Privacy Extensions
- <ulink url="https://tools.ietf.org/html/rfc3041">RFC 3041</ulink>. For this to become
+ <ulink url="https://tools.ietf.org/html/rfc3041">RFC 3041</ulink>. For this to become
active, the use_tempaddr sysctl setting has to be set to a value greater than zero.
The given address needs to have a prefix length of 64. This flag allows using privacy
extensions in a manually configured network, just like if stateless auto-configuration
- was active. Defaults to false. </para>
+ was active. Defaults to false.</para>
</listitem>
</varlistentry>
<varlistentry>
@@ -2056,6 +2056,13 @@ IPv6Token=prefixstable:2002:da8:1::</programlisting></para>
addresses. Defaults to unset.</para>
</listitem>
</varlistentry>
+
+ <varlistentry>
+ <term><varname>ManageTemporaryAddress=</varname></term>
+ <listitem>
+ <para>As in the [Address] section, but defaults to true.</para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect1>
diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c
index 89b22c35e3..9571221da2 100644
--- a/src/network/networkd-dhcp6.c
+++ b/src/network/networkd-dhcp6.c
@@ -365,11 +365,11 @@ static int dhcp6_pd_address_handler(sd_netlink *rtnl, sd_netlink_message *m, Lin
return 1;
}
-static int dhcp6_set_pd_address(Link *link,
- const union in_addr_union *prefix,
- uint8_t prefix_len,
- uint32_t lifetime_preferred,
- uint32_t lifetime_valid) {
+static int dhcp6_set_pd_address(
+ Link *link,
+ const union in_addr_union *prefix,
+ uint32_t lifetime_preferred,
+ uint32_t lifetime_valid) {
_cleanup_(address_freep) Address *address = NULL;
Address *ret;
@@ -396,10 +396,11 @@ static int dhcp6_set_pd_address(Link *link,
return log_link_warning_errno(link, r, "Failed to generate EUI64 address for acquired DHCPv6 delegated prefix: %m");
}
- address->prefixlen = prefix_len;
+ address->prefixlen = 64;
address->family = AF_INET6;
address->cinfo.ifa_prefered = lifetime_preferred;
address->cinfo.ifa_valid = lifetime_valid;
+ SET_FLAG(address->flags, IFA_F_MANAGETEMPADDR, link->network->dhcp6_pd_manage_temporary_address);
r = address_configure(address, link, dhcp6_pd_address_handler, true, &ret);
if (r < 0)
@@ -416,8 +417,13 @@ static int dhcp6_set_pd_address(Link *link,
return 0;
}
-static int dhcp6_pd_assign_prefix(Link *link, const union in_addr_union *prefix, const union in_addr_union *pd_prefix,
- uint8_t prefix_len, uint32_t lifetime_preferred, uint32_t lifetime_valid) {
+static int dhcp6_pd_assign_prefix(
+ Link *link,
+ const union in_addr_union *prefix,
+ const union in_addr_union *pd_prefix,
+ uint32_t lifetime_preferred,
+ uint32_t lifetime_valid) {
+
int r;
assert(link);
@@ -425,7 +431,7 @@ static int dhcp6_pd_assign_prefix(Link *link, const union in_addr_union *prefix,
assert(prefix);
if (link->network->dhcp6_pd_announce) {
- r = radv_add_prefix(link, &prefix->in6, prefix_len, lifetime_preferred, lifetime_valid);
+ r = radv_add_prefix(link, &prefix->in6, 64, lifetime_preferred, lifetime_valid);
if (r < 0)
return r;
}
@@ -434,7 +440,7 @@ static int dhcp6_pd_assign_prefix(Link *link, const union in_addr_union *prefix,
if (r < 0)
return r;
- r = dhcp6_set_pd_address(link, prefix, prefix_len, lifetime_preferred, lifetime_valid);
+ r = dhcp6_set_pd_address(link, prefix, lifetime_preferred, lifetime_valid);
if (r < 0)
return r;
@@ -559,7 +565,7 @@ static void dhcp6_pd_prefix_distribute(Link *dhcp6_link,
}
(void) in_addr_to_string(AF_INET6, &assigned_prefix, &assigned_buf);
- r = dhcp6_pd_assign_prefix(link, &assigned_prefix, masked_pd_prefix, 64,
+ r = dhcp6_pd_assign_prefix(link, &assigned_prefix, masked_pd_prefix,
lifetime_preferred, lifetime_valid);
if (r < 0) {
log_link_error_errno(link, r, "Unable to assign/update prefix %s/64: %m",
diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf
index 00ba043b23..896a884063 100644
--- a/src/network/networkd-network-gperf.gperf
+++ b/src/network/networkd-network-gperf.gperf
@@ -295,6 +295,7 @@ BridgeVLAN.EgressUntagged, config_parse_brvlan_untagged,
DHCPv6PrefixDelegation.SubnetId, config_parse_dhcp6_pd_subnet_id, 0, offsetof(Network, dhcp6_pd_subnet_id)
DHCPv6PrefixDelegation.Announce, config_parse_bool, 0, offsetof(Network, dhcp6_pd_announce)
DHCPv6PrefixDelegation.Assign, config_parse_bool, 0, offsetof(Network, dhcp6_pd_assign)
+DHCPv6PrefixDelegation.ManageTemporaryAddress, config_parse_bool, 0, offsetof(Network, dhcp6_pd_manage_temporary_address)
DHCPv6PrefixDelegation.Token, config_parse_dhcp6_pd_token, 0, offsetof(Network, dhcp6_pd_token)
IPv6SendRA.RouterLifetimeSec, config_parse_sec, 0, offsetof(Network, router_lifetime_usec)
IPv6SendRA.Managed, config_parse_bool, 0, offsetof(Network, router_managed)
diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c
index a8d6c58ac4..a74a1e946e 100644
--- a/src/network/networkd-network.c
+++ b/src/network/networkd-network.c
@@ -361,6 +361,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
.dhcp6_pd = -1,
.dhcp6_pd_announce = true,
.dhcp6_pd_assign = true,
+ .dhcp6_pd_manage_temporary_address = true,
.dhcp6_pd_subnet_id = -1,
.dhcp_server_emit[SD_DHCP_LEASE_DNS].emit = true,
diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h
index 656bf6c366..bd419f6ef4 100644
--- a/src/network/networkd-network.h
+++ b/src/network/networkd-network.h
@@ -200,6 +200,7 @@ struct Network {
int dhcp6_pd;
bool dhcp6_pd_announce;
bool dhcp6_pd_assign;
+ bool dhcp6_pd_manage_temporary_address;
int64_t dhcp6_pd_subnet_id;
union in_addr_union dhcp6_pd_token;
diff --git a/test/fuzz/fuzz-network-parser/directives.network b/test/fuzz/fuzz-network-parser/directives.network
index 3024c65713..cc91437c16 100644
--- a/test/fuzz/fuzz-network-parser/directives.network
+++ b/test/fuzz/fuzz-network-parser/directives.network
@@ -143,6 +143,7 @@ RouteMetric=
SubnetId=
Announce=
Assign=
+ManageTemporaryAddress=
Token=
[Route]
Destination=