Merge pull request #18227 from yuwata/network-dhcp6-pd-manage-temporary-address

network: introduce ManageTemporaryAddress= setting in [DHCPv6PrefixDelegation] section
This commit is contained in:
Lennart Poettering 2021-01-13 21:52:44 +01:00 committed by GitHub
commit ce0079d75e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 13 deletions

View File

@ -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>

View File

@ -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",

View File

@ -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)

View File

@ -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,

View File

@ -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;

View File

@ -143,6 +143,7 @@ RouteMetric=
SubnetId=
Announce=
Assign=
ManageTemporaryAddress=
Token=
[Route]
Destination=