diff mbox series

[RESEND,net-next] ipv6: provide Kconfig switch to disable accept_ra by default

Message ID b39b1b4304524c43dfd83280aea4cfb4e8ac97f5.1523959377.git.mschiffer@universe-factory.net
State Changes Requested, archived
Delegated to: David Miller
Headers show
Series [RESEND,net-next] ipv6: provide Kconfig switch to disable accept_ra by default | expand

Commit Message

Matthias Schiffer April 17, 2018, 10:04 a.m. UTC
Many distributions and users prefer to handle router advertisements in
userspace; one example is OpenWrt, which includes a combined RA and DHCPv6
client. For such configurations, accept_ra should not be enabled by
default.

As setting net.ipv6.conf.default.accept_ra via sysctl.conf or similar
facilities may be too late to catch all interfaces and common sysctl.conf
tools do not allow setting an option for all existing interfaces, this
patch provides a Kconfig option to control the default value of
default.accept_ra.

Using default.accept_ra is preferable to all.accept_ra for our usecase,
as disabling all.accept_ra would preclude users from explicitly enabling
accept_ra on individual interfaces.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
---
 net/ipv6/Kconfig    | 12 ++++++++++++
 net/ipv6/addrconf.c |  2 +-
 2 files changed, 13 insertions(+), 1 deletion(-)

Comments

David Miller April 17, 2018, 7:05 p.m. UTC | #1
From: Matthias Schiffer <mschiffer@universe-factory.net>
Date: Tue, 17 Apr 2018 12:04:50 +0200

> Many distributions and users prefer to handle router advertisements in
> userspace; one example is OpenWrt, which includes a combined RA and DHCPv6
> client. For such configurations, accept_ra should not be enabled by
> default.
> 
> As setting net.ipv6.conf.default.accept_ra via sysctl.conf or similar
> facilities may be too late to catch all interfaces and common sysctl.conf
> tools do not allow setting an option for all existing interfaces, this
> patch provides a Kconfig option to control the default value of
> default.accept_ra.
> 
> Using default.accept_ra is preferable to all.accept_ra for our usecase,
> as disabling all.accept_ra would preclude users from explicitly enabling
> accept_ra on individual interfaces.
> 
> Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>

This kind of Kconfig option makes an irreversible behavior choice at
compile time, which satisfies one set of users whilst completely
precluding another set.

So no matter what setting a distribution chooses, one set of users are
basically out of luck.

For that reason I consider this a poor approach.

I hate module options, but at least with that the user can choose
regardless of what the distribution maker decided to do with their
kernel.

This is essentially how we handle "disable_ipv6"

I'm not applying this, because it is as much of a step backwards as
it is a step forward, sorry.
diff mbox series

Patch

diff --git a/net/ipv6/Kconfig b/net/ipv6/Kconfig
index 6794ddf0547c..0f453110f288 100644
--- a/net/ipv6/Kconfig
+++ b/net/ipv6/Kconfig
@@ -20,6 +20,18 @@  menuconfig IPV6
 
 if IPV6
 
+config IPV6_ACCEPT_RA_DEFAULT
+	bool "IPv6: Accept router advertisements by default"
+	default y
+	help
+	  The kernel can internally handle IPv6 router advertisements for
+	  stateless address autoconfiguration (SLAAC) and route configuration,
+	  which can be configured in detail and per-interface using a number of
+	  sysctl options. This option controls the default value of
+	  net.ipv6.conf.default.accept_ra.
+
+	  If unsure, say Y.
+
 config IPV6_ROUTER_PREF
 	bool "IPv6: Router Preference (RFC 4191) support"
 	---help---
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 62b97722722c..5fd6d2120a35 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -245,7 +245,7 @@  static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
 	.forwarding		= 0,
 	.hop_limit		= IPV6_DEFAULT_HOPLIMIT,
 	.mtu6			= IPV6_MIN_MTU,
-	.accept_ra		= 1,
+	.accept_ra		= IS_ENABLED(CONFIG_IPV6_ACCEPT_RA_DEFAULT),
 	.accept_redirects	= 1,
 	.autoconf		= 1,
 	.force_mld_version	= 0,