summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2020-11-16 16:25:43 +0900
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-12-16 14:34:54 +0100
commite39f0fa5c3da64181981ee9dc373b400e6453b19 (patch)
tree4ae1c9979c365148767d019748eb0b6afa0a05a2
parent83c47527396842302154203fbb5ada66747d0175 (diff)
downloadsystemd-e39f0fa5c3da64181981ee9dc373b400e6453b19.tar.gz
network: honor M or O flag in RA even if IPv6AcceptRA.DHCPv6Cleint=alwaysv246.8
Follow-up for ac24e418d9bc988ecf114c464701b35934948178. The original motivation of the commit and RFE #15339 is to start dhcpv6 client in managed mode when neither M nor O flag is set in the RA. But, previously, if the setting is set to "always", then the DHCPv6 client is always started in managed mode even if O flag is set in the RA. Such the behavior breaks RFC 7084. (cherry picked from commit 0e686feaff71465e3220f234871f66a39f0f57ad)
-rw-r--r--man/systemd.network.xml8
-rw-r--r--src/network/networkd-ndisc.c12
2 files changed, 13 insertions, 7 deletions
diff --git a/man/systemd.network.xml b/man/systemd.network.xml
index 9d28de7ac7..b1880699ab 100644
--- a/man/systemd.network.xml
+++ b/man/systemd.network.xml
@@ -2052,9 +2052,11 @@
<varlistentry>
<term><varname>DHCPv6Client=</varname></term>
<listitem>
- <para>Takes a boolean, or the special value <literal>always</literal>. When true (the default), the DHCPv6 client will be started when the
- RA has the managed or other information flag. If set to <literal>always</literal>, the DHCPv6 client will be started even if there is no
- managed or other information flag in the RA.</para>
+ <para>Takes a boolean, or the special value <literal>always</literal>. When true or
+ <literal>always</literal>, the DHCPv6 client will be started when the RA has the managed or
+ other information flag. If set to <literal>always</literal>, the DHCPv6 client will also be
+ started in managed mode when neither managed nor other information flag is set in the RA.
+ Defaults to true.</para>
</listitem>
</varlistentry>
</variablelist>
diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c
index bcea91c696..fed6aaba22 100644
--- a/src/network/networkd-ndisc.c
+++ b/src/network/networkd-ndisc.c
@@ -1116,13 +1116,17 @@ static int ndisc_router_handler(Link *link, sd_ndisc_router *rt) {
if (r < 0)
return log_link_error_errno(link, r, "Failed to get RA flags: %m");
- if ((flags & (ND_RA_FLAG_MANAGED | ND_RA_FLAG_OTHER) && link->network->ipv6_accept_ra_start_dhcp6_client)) {
+ if ((flags & (ND_RA_FLAG_MANAGED | ND_RA_FLAG_OTHER) &&
+ link->network->ipv6_accept_ra_start_dhcp6_client != IPV6_ACCEPT_RA_START_DHCP6_CLIENT_NO) ||
+ link->network->ipv6_accept_ra_start_dhcp6_client == IPV6_ACCEPT_RA_START_DHCP6_CLIENT_ALWAYS) {
- if (link->network->ipv6_accept_ra_start_dhcp6_client == IPV6_ACCEPT_RA_START_DHCP6_CLIENT_ALWAYS)
- r = dhcp6_request_address(link, false);
- else
+ if (flags & (ND_RA_FLAG_MANAGED | ND_RA_FLAG_OTHER))
/* (re)start DHCPv6 client in stateful or stateless mode according to RA flags */
r = dhcp6_request_address(link, !(flags & ND_RA_FLAG_MANAGED));
+ else
+ /* When IPv6AcceptRA.DHCPv6Client=always, start dhcp6 client in managed mode
+ * even if router does not have M or O flag. */
+ r = dhcp6_request_address(link, false);
if (r < 0 && r != -EBUSY)
return log_link_error_errno(link, r, "Could not acquire DHCPv6 lease on NDisc request: %m");
else