Cannot set accept-ra to 2, it keeps reseting it to 0

Bug #1862481 reported by JS
22
This bug affects 4 people
Affects Status Importance Assigned to Milestone
Netplan
Triaged
Wishlist
Unassigned
netplan.io (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

As netplan is not supporting ipv6-pd now, we have to rely on other dhcpv6 client like dibbler-client or wide-dhcpv6-client. In order for those tools to work, /proc/sys/net/ipv6/conf/wan/accept_ra need to be 2. However, with setting like following:

network:
  version: 2
  renderer: networkd
  ethernets:
    wan:
      dhcp4: true
      dhcp-identifier: mac
      link-local: [ ]

/proc/sys/net/ipv6/conf/wan/accept_ra will always reset to 0.

The "accept-ra" option doesn't help as it only accept yes/no.

Revision history for this message
XSpielinbox (xspielinbox) wrote (last edit ):

I can reproduce this issue with the newest Version of Netplan in Ubuntu 22.04 as well as Ubuntu 22.10.

When 'accept-ra: true' is set the systemd-networkd config contains 'IPv6AcceptRA=yes'. (according to systemd documentation this should correspond to kernel option 2)
If 'accept-ra: false' is set the systemd-networkd config contains 'IPv6AcceptRA=no'. (according to systemd documentation this should correspond to kernel option 0)
If 'accept-ra' is unset, the systemd-networkd config does not contain any 'IPv6AcceptRA' statement. (according to systemd documentation this should correspond to the kernel default option 1)

However independent of the config in systmed-networkd/Netplan 'sysctl net.ipv6.conf.<iface>.accept_ra' always returns 0.

Moreover after trying to change the kernel setting manually and reapplying the Netplan config the kernel parameter get's reset to 0.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in netplan.io (Ubuntu):
status: New → Confirmed
Revision history for this message
XSpielinbox (xspielinbox) wrote :

Could it be that this is actually is an issue in systemd-networkd or Netplan putting the config option at the wrong spot?

Also this problem seems related, though distinct to LP#1807569.

summary: - Cannot set accept-ra to 2, and keep reseting it to 0
+ Cannot set accept-ra to 2, it keeps reseting it to 0
Lukas Märdian (slyon)
Changed in netplan:
importance: Undecided → Wishlist
status: New → Triaged
Revision history for this message
Yaobin Wen (yaobinwen) wrote (last edit ):

I ran into this today and after a lot of head-scratching, it just occurred to me that this is probably the expected behavior. systemd-network(5)'s IPv6AcceptRA section says (https://www.freedesktop.org/software/systemd/man/latest/systemd.network.html):

> Note that kernel's implementation of the IPv6 RA protocol is always disabled, regardless of this setting.

Then I read this comment: https://unix.stackexchange.com/questions/759771/ubuntu-accept-ra-is-not-effective-with-sysctl-and-prevents-dhcp6-when-in-netplan#comment1448644_759791, quoted below:

> It's for the in-kernel RA handler. Traditionally Linux has done IPv6 autoconfig (though not DHCPv6) without any userspace software at all, but its capabilities are limited. (Networkd actually sets it to 0 even if IPv6AcceptRA=true.)

What possibly confused the readers (including me) was, systemd-network(5) does say:

> Also see IP Sysctl in the kernel documentation regarding "accept_ra", but note that systemd's setting of 1 (i.e. true) corresponds to kernel's setting of 2.

At the beginning, this paragraph made me think systemd-networkd sets `accept_ra` to 2 when `IPv6AcceptRA=yes`. But, no. Now I realized systemd-network(5) was merely using the kernel document to explain that `IPv6AcceptRA=yes`'s behavior is the same as `accept_ra=2`'s behavior (i.e, accepting RA messages even if forwarding is enabled), but systemd-networkd always sets `accept_ra=0` duo the the explanation of "Note that kernel's implementation of the IPv6 RA protocol is always disabled".

Revision history for this message
Danilo Egea Gondolfo (danilogondolfo) wrote :

I was looking at this bug while working on another accept-ra related thing and found this:

As far as I can tell, networkd will always set the per-interface accept_ra parameter to 0:

https://github.com/systemd/systemd/blob/v255/src/network/networkd-sysctl.c#L146

The explanation for that is documented in an old version of this code (which was moved from networkd-link.c to networkd-sysctl.c):

https://github.com/systemd/systemd/blob/v241/src/network/networkd-link.c#L2609

It's also described in different words on systemd.network(5):

Note that kernel's implementation of the IPv6 RA protocol is always disabled, regardless of this setting. If this option is enabled, a userspace implementation of the IPv6 RA protocol is used, and the kernel's own implementation remains disabled...

The Netplan documentation need to be updated. It currently says "If unset use the host kernel default setting" but, at least when networkd is used, the "default" will always be disabled because networkd itself will force it.

Lukas Märdian (slyon)
tags: added: docs documentation
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.