diff mbox series

[net-next,v3] net: add sysctl to disable rfc4862 5.5.3e lifetime handling

Message ID 20230919180411.754981-1-prohr@google.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v3] net: add sysctl to disable rfc4862 5.5.3e lifetime handling | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3184 this patch: 3184
netdev/cc_maintainers warning 6 maintainers not CCed: corbet@lwn.net linux-doc@vger.kernel.org pabeni@redhat.com edumazet@google.com dsahern@kernel.org kuba@kernel.org
netdev/build_clang success Errors and warnings before: 1550 this patch: 1550
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 3432 this patch: 3432
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 89 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Patrick Rohr Sept. 19, 2023, 6:04 p.m. UTC
This change adds a sysctl to opt-out of RFC4862 section 5.5.3e's valid
lifetime derivation mechanism.

RFC4862 section 5.5.3e prescribes that the valid lifetime in a Router
Advertisement PIO shall be ignored if it less than 2 hours and to reset
the lifetime of the corresponding address to 2 hours. An in-progress
6man draft (see draft-ietf-6man-slaac-renum-07 section 4.2) is currently
looking to remove this mechanism. While this draft has not been moving
particularly quickly for other reasons, there is widespread consensus on
section 4.2 which updates RFC4862 section 5.5.3e.

Cc: Maciej Żenczykowski <maze@google.com>
Cc: Lorenzo Colitti <lorenzo@google.com>
Cc: Jen Linkova <furry@google.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Patrick Rohr <prohr@google.com>
---
 Documentation/networking/ip-sysctl.rst | 11 ++++++++
 include/linux/ipv6.h                   |  1 +
 net/ipv6/addrconf.c                    | 38 +++++++++++++++++---------
 3 files changed, 37 insertions(+), 13 deletions(-)

Comments

Jiri Pirko Sept. 20, 2023, 12:44 p.m. UTC | #1
Tue, Sep 19, 2023 at 08:04:11PM CEST, prohr@google.com wrote:
>This change adds a sysctl to opt-out of RFC4862 section 5.5.3e's valid
>lifetime derivation mechanism.
>
>RFC4862 section 5.5.3e prescribes that the valid lifetime in a Router
>Advertisement PIO shall be ignored if it less than 2 hours and to reset
>the lifetime of the corresponding address to 2 hours. An in-progress
>6man draft (see draft-ietf-6man-slaac-renum-07 section 4.2) is currently
>looking to remove this mechanism. While this draft has not been moving
>particularly quickly for other reasons, there is widespread consensus on
>section 4.2 which updates RFC4862 section 5.5.3e.
>
>Cc: Maciej Żenczykowski <maze@google.com>
>Cc: Lorenzo Colitti <lorenzo@google.com>
>Cc: Jen Linkova <furry@google.com>
>Cc: Jiri Pirko <jiri@resnulli.us>
>Signed-off-by: Patrick Rohr <prohr@google.com>

Reviewed-by: Jiri Pirko <jiri@nvidia.com>
David Ahern Sept. 20, 2023, 2:37 p.m. UTC | #2
On 9/19/23 12:04 PM, Patrick Rohr wrote:
> This change adds a sysctl to opt-out of RFC4862 section 5.5.3e's valid
> lifetime derivation mechanism.
> 
> RFC4862 section 5.5.3e prescribes that the valid lifetime in a Router
> Advertisement PIO shall be ignored if it less than 2 hours and to reset
> the lifetime of the corresponding address to 2 hours. An in-progress
> 6man draft (see draft-ietf-6man-slaac-renum-07 section 4.2) is currently
> looking to remove this mechanism. While this draft has not been moving
> particularly quickly for other reasons, there is widespread consensus on
> section 4.2 which updates RFC4862 section 5.5.3e.
> 
> Cc: Maciej Żenczykowski <maze@google.com>
> Cc: Lorenzo Colitti <lorenzo@google.com>
> Cc: Jen Linkova <furry@google.com>
> Cc: Jiri Pirko <jiri@resnulli.us>
> Signed-off-by: Patrick Rohr <prohr@google.com>
> ---
>  Documentation/networking/ip-sysctl.rst | 11 ++++++++
>  include/linux/ipv6.h                   |  1 +
>  net/ipv6/addrconf.c                    | 38 +++++++++++++++++---------
>  3 files changed, 37 insertions(+), 13 deletions(-)
> 
> diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst
> index a66054d0763a..45d700e04dba 100644
> --- a/Documentation/networking/ip-sysctl.rst
> +++ b/Documentation/networking/ip-sysctl.rst
> @@ -2304,6 +2304,17 @@ accept_ra_pinfo - BOOLEAN
>  		- enabled if accept_ra is enabled.
>  		- disabled if accept_ra is disabled.
>  
> +ra_honor_pio_life - BOOLEAN
> +	Whether to use RFC4862 Section 5.5.3e to determine the valid
> +	lifetime of an address matching a prefix sent in a Router
> +	Advertisement Prefix Information Option.
> +
> +	- If enabled, the PIO valid lifetime will always be honored.
> +	- If disabled, RFC4862 section 5.5.3e is used to determine
> +	  the valid lifetime of the address.
> +
> +	Default: 0 (disabled)
> +
>  accept_ra_rt_info_min_plen - INTEGER
>  	Minimum prefix length of Route Information in RA.
>  
> diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
> index 5883551b1ee8..59fcc4fee7b7 100644
> --- a/include/linux/ipv6.h
> +++ b/include/linux/ipv6.h
> @@ -35,6 +35,7 @@ struct ipv6_devconf {
>  	__s32		accept_ra_min_hop_limit;
>  	__s32		accept_ra_min_lft;
>  	__s32		accept_ra_pinfo;
> +	__s32		ra_honor_pio_life;

Any reason for this to be 4B entry for a boolean? all of these __s32
entries for what are really booleans is pushing devconf size over 256B
which means allocations are 512B. Unnecessary waste of memory.
diff mbox series

Patch

diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst
index a66054d0763a..45d700e04dba 100644
--- a/Documentation/networking/ip-sysctl.rst
+++ b/Documentation/networking/ip-sysctl.rst
@@ -2304,6 +2304,17 @@  accept_ra_pinfo - BOOLEAN
 		- enabled if accept_ra is enabled.
 		- disabled if accept_ra is disabled.
 
+ra_honor_pio_life - BOOLEAN
+	Whether to use RFC4862 Section 5.5.3e to determine the valid
+	lifetime of an address matching a prefix sent in a Router
+	Advertisement Prefix Information Option.
+
+	- If enabled, the PIO valid lifetime will always be honored.
+	- If disabled, RFC4862 section 5.5.3e is used to determine
+	  the valid lifetime of the address.
+
+	Default: 0 (disabled)
+
 accept_ra_rt_info_min_plen - INTEGER
 	Minimum prefix length of Route Information in RA.
 
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index 5883551b1ee8..59fcc4fee7b7 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -35,6 +35,7 @@  struct ipv6_devconf {
 	__s32		accept_ra_min_hop_limit;
 	__s32		accept_ra_min_lft;
 	__s32		accept_ra_pinfo;
+	__s32		ra_honor_pio_life;
 	__s32		ignore_routes_with_linkdown;
 #ifdef CONFIG_IPV6_ROUTER_PREF
 	__s32		accept_ra_rtr_pref;
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 47d1dd8501b7..edfb450e5893 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -204,6 +204,7 @@  static struct ipv6_devconf ipv6_devconf __read_mostly = {
 	.accept_ra_min_hop_limit= 1,
 	.accept_ra_min_lft	= 0,
 	.accept_ra_pinfo	= 1,
+	.ra_honor_pio_life	= 0,
 #ifdef CONFIG_IPV6_ROUTER_PREF
 	.accept_ra_rtr_pref	= 1,
 	.rtr_probe_interval	= 60 * HZ,
@@ -265,6 +266,7 @@  static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
 	.accept_ra_min_hop_limit= 1,
 	.accept_ra_min_lft	= 0,
 	.accept_ra_pinfo	= 1,
+	.ra_honor_pio_life	= 0,
 #ifdef CONFIG_IPV6_ROUTER_PREF
 	.accept_ra_rtr_pref	= 1,
 	.rtr_probe_interval	= 60 * HZ,
@@ -2657,22 +2659,23 @@  int addrconf_prefix_rcv_add_addr(struct net *net, struct net_device *dev,
 			stored_lft = ifp->valid_lft - (now - ifp->tstamp) / HZ;
 		else
 			stored_lft = 0;
-		if (!create && stored_lft) {
+
+		/* RFC4862 Section 5.5.3e:
+		 * "Note that the preferred lifetime of the
+		 *  corresponding address is always reset to
+		 *  the Preferred Lifetime in the received
+		 *  Prefix Information option, regardless of
+		 *  whether the valid lifetime is also reset or
+		 *  ignored."
+		 *
+		 * So we should always update prefered_lft here.
+		 */
+		update_lft = !create && stored_lft;
+
+		if (update_lft && !in6_dev->cnf.ra_honor_pio_life) {
 			const u32 minimum_lft = min_t(u32,
 				stored_lft, MIN_VALID_LIFETIME);
 			valid_lft = max(valid_lft, minimum_lft);
-
-			/* RFC4862 Section 5.5.3e:
-			 * "Note that the preferred lifetime of the
-			 *  corresponding address is always reset to
-			 *  the Preferred Lifetime in the received
-			 *  Prefix Information option, regardless of
-			 *  whether the valid lifetime is also reset or
-			 *  ignored."
-			 *
-			 * So we should always update prefered_lft here.
-			 */
-			update_lft = 1;
 		}
 
 		if (update_lft) {
@@ -6846,6 +6849,15 @@  static const struct ctl_table addrconf_sysctl[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec,
 	},
+	{
+		.procname	= "ra_honor_pio_life",
+		.data		= &ipv6_devconf.ra_honor_pio_life,
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= SYSCTL_ZERO,
+		.extra2		= SYSCTL_ONE,
+	},
 #ifdef CONFIG_IPV6_ROUTER_PREF
 	{
 		.procname	= "accept_ra_rtr_pref",