diff mbox series

[net-next,v2] Add support for PIO p flag

Message ID 20240729220059.3018247-1-prohr@google.com (mailing list archive)
State Accepted
Commit 990c304930138dcd7a49763417e6e5313b81293e
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v2] Add support for PIO p flag | 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/ynl success Generated files up to date; no warnings/errors; no diff in generated;
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: 58 this patch: 58
netdev/build_tools success Errors and warnings before: 10 this patch: 10
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 74 this patch: 74
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: 2024 this patch: 2024
netdev/checkpatch warning WARNING: line length of 88 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 5 this patch: 5
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-07-31--12-00 (tests: 707)

Commit Message

Patrick Rohr July 29, 2024, 10 p.m. UTC
draft-ietf-6man-pio-pflag is adding a new flag to the Prefix Information
Option to signal that the network can allocate a unique IPv6 prefix per
client via DHCPv6-PD (see draft-ietf-v6ops-dhcp-pd-per-device).

When ra_honor_pio_pflag is enabled, the presence of a P-flag causes
SLAAC autoconfiguration to be disabled for that particular PIO.

An automated test has been added in Android (r.android.com/3195335) to
go along with this change.

Cc: Maciej Żenczykowski <maze@google.com>
Cc: Lorenzo Colitti <lorenzo@google.com>
Cc: David Lamparter <equinox@opensourcerouting.org>
Cc: Simon Horman <horms@kernel.org>
Signed-off-by: Patrick Rohr <prohr@google.com>
---
 Documentation/networking/ip-sysctl.rst | 14 ++++++++++++++
 include/linux/ipv6.h                   |  1 +
 include/net/addrconf.h                 | 10 +++++++---
 net/ipv6/addrconf.c                    | 15 ++++++++++++++-
 4 files changed, 36 insertions(+), 4 deletions(-)

Comments

Maciej Żenczykowski July 30, 2024, 12:06 a.m. UTC | #1
On Mon, Jul 29, 2024 at 3:01 PM Patrick Rohr <prohr@google.com> wrote:
>
> draft-ietf-6man-pio-pflag is adding a new flag to the Prefix Information
> Option to signal that the network can allocate a unique IPv6 prefix per
> client via DHCPv6-PD (see draft-ietf-v6ops-dhcp-pd-per-device).
>
> When ra_honor_pio_pflag is enabled, the presence of a P-flag causes
> SLAAC autoconfiguration to be disabled for that particular PIO.
>
> An automated test has been added in Android (r.android.com/3195335) to
> go along with this change.
>
> Cc: Maciej Żenczykowski <maze@google.com>
> Cc: Lorenzo Colitti <lorenzo@google.com>
> Cc: David Lamparter <equinox@opensourcerouting.org>
> Cc: Simon Horman <horms@kernel.org>
> Signed-off-by: Patrick Rohr <prohr@google.com>
> ---
>  Documentation/networking/ip-sysctl.rst | 14 ++++++++++++++
>  include/linux/ipv6.h                   |  1 +
>  include/net/addrconf.h                 | 10 +++++++---
>  net/ipv6/addrconf.c                    | 15 ++++++++++++++-
>  4 files changed, 36 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst
> index 3616389c8c2d..eacf8983e230 100644
> --- a/Documentation/networking/ip-sysctl.rst
> +++ b/Documentation/networking/ip-sysctl.rst
> @@ -2362,6 +2362,20 @@ ra_honor_pio_life - BOOLEAN
>
>         Default: 0 (disabled)
>
> +ra_honor_pio_pflag - BOOLEAN
> +       The Prefix Information Option P-flag indicates the network can
> +       allocate a unique IPv6 prefix per client using DHCPv6-PD.
> +       This sysctl can be enabled when a userspace DHCPv6-PD client
> +       is running to cause the P-flag to take effect: i.e. the
> +       P-flag suppresses any effects of the A-flag within the same
> +       PIO. For a given PIO, P=1 and A=1 is treated as A=0.
> +
> +       - If disabled, the P-flag is ignored.
> +       - If enabled, the P-flag will disable SLAAC autoconfiguration
> +         for the given Prefix Information Option.
> +
> +       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 383a0ea2ab91..a6e2aadbb91b 100644
> --- a/include/linux/ipv6.h
> +++ b/include/linux/ipv6.h
> @@ -89,6 +89,7 @@ struct ipv6_devconf {
>         __u8            ioam6_enabled;
>         __u8            ndisc_evict_nocarrier;
>         __u8            ra_honor_pio_life;
> +       __u8            ra_honor_pio_pflag;
>
>         struct ctl_table_header *sysctl_header;
>  };
> diff --git a/include/net/addrconf.h b/include/net/addrconf.h
> index 62a407db1bf5..b18e81f0c9e1 100644
> --- a/include/net/addrconf.h
> +++ b/include/net/addrconf.h
> @@ -37,10 +37,14 @@ struct prefix_info {
>                 struct __packed {
>  #if defined(__BIG_ENDIAN_BITFIELD)
>                         __u8    onlink : 1,
> -                               autoconf : 1,
> -                               reserved : 6;
> +                               autoconf : 1,
> +                               routeraddr : 1,
> +                               preferpd : 1,
> +                               reserved : 4;
>  #elif defined(__LITTLE_ENDIAN_BITFIELD)
> -                       __u8    reserved : 6,
> +                       __u8    reserved : 4,
> +                               preferpd : 1,
> +                               routeraddr : 1,
>                                 autoconf : 1,
>                                 onlink : 1;
>  #else
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index 55a0fd589fc8..4febf679a435 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -239,6 +239,7 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = {
>         .ioam6_id_wide          = IOAM6_DEFAULT_IF_ID_WIDE,
>         .ndisc_evict_nocarrier  = 1,
>         .ra_honor_pio_life      = 0,
> +       .ra_honor_pio_pflag     = 0,
>  };
>
>  static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
> @@ -302,6 +303,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
>         .ioam6_id_wide          = IOAM6_DEFAULT_IF_ID_WIDE,
>         .ndisc_evict_nocarrier  = 1,
>         .ra_honor_pio_life      = 0,
> +       .ra_honor_pio_pflag     = 0,
>  };
>
>  /* Check if link is ready: is it up and is a valid qdisc available */
> @@ -2762,6 +2764,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)
>         u32 addr_flags = 0;
>         struct inet6_dev *in6_dev;
>         struct net *net = dev_net(dev);
> +       bool ignore_autoconf = false;

This ' = false' appears to be spurious (as ignore_autoconf is only
read after being written), but is of course harmless.

Reviewed-by: Maciej Żenczykowski <maze@google.com>

>         pinfo = (struct prefix_info *) opt;
>
> @@ -2864,7 +2867,8 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)
>
>         /* Try to figure out our local address for this prefix */
>
> -       if (pinfo->autoconf && in6_dev->cnf.autoconf) {
> +       ignore_autoconf = READ_ONCE(in6_dev->cnf.ra_honor_pio_pflag) && pinfo->preferpd;
> +       if (pinfo->autoconf && in6_dev->cnf.autoconf && !ignore_autoconf) {
>                 struct in6_addr addr;
>                 bool tokenized = false, dev_addr_generated = false;
>
> @@ -6926,6 +6930,15 @@ static const struct ctl_table addrconf_sysctl[] = {
>                 .extra1         = SYSCTL_ZERO,
>                 .extra2         = SYSCTL_ONE,
>         },
> +       {
> +               .procname       = "ra_honor_pio_pflag",
> +               .data           = &ipv6_devconf.ra_honor_pio_pflag,
> +               .maxlen         = sizeof(u8),
> +               .mode           = 0644,
> +               .proc_handler   = proc_dou8vec_minmax,
> +               .extra1         = SYSCTL_ZERO,
> +               .extra2         = SYSCTL_ONE,
> +       },
>  #ifdef CONFIG_IPV6_ROUTER_PREF
>         {
>                 .procname       = "accept_ra_rtr_pref",
> --
> 2.46.0.rc1.232.g9752f9e123-goog
>
patchwork-bot+netdevbpf@kernel.org July 31, 2024, 12:50 p.m. UTC | #2
Hello:

This patch was applied to netdev/net-next.git (main)
by David S. Miller <davem@davemloft.net>:

On Mon, 29 Jul 2024 15:00:59 -0700 you wrote:
> draft-ietf-6man-pio-pflag is adding a new flag to the Prefix Information
> Option to signal that the network can allocate a unique IPv6 prefix per
> client via DHCPv6-PD (see draft-ietf-v6ops-dhcp-pd-per-device).
> 
> When ra_honor_pio_pflag is enabled, the presence of a P-flag causes
> SLAAC autoconfiguration to be disabled for that particular PIO.
> 
> [...]

Here is the summary with links:
  - [net-next,v2] Add support for PIO p flag
    https://git.kernel.org/netdev/net-next/c/990c30493013

You are awesome, thank you!
diff mbox series

Patch

diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst
index 3616389c8c2d..eacf8983e230 100644
--- a/Documentation/networking/ip-sysctl.rst
+++ b/Documentation/networking/ip-sysctl.rst
@@ -2362,6 +2362,20 @@  ra_honor_pio_life - BOOLEAN
 
 	Default: 0 (disabled)
 
+ra_honor_pio_pflag - BOOLEAN
+	The Prefix Information Option P-flag indicates the network can
+	allocate a unique IPv6 prefix per client using DHCPv6-PD.
+	This sysctl can be enabled when a userspace DHCPv6-PD client
+	is running to cause the P-flag to take effect: i.e. the
+	P-flag suppresses any effects of the A-flag within the same
+	PIO. For a given PIO, P=1 and A=1 is treated as A=0.
+
+	- If disabled, the P-flag is ignored.
+	- If enabled, the P-flag will disable SLAAC autoconfiguration
+	  for the given Prefix Information Option.
+
+	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 383a0ea2ab91..a6e2aadbb91b 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -89,6 +89,7 @@  struct ipv6_devconf {
 	__u8		ioam6_enabled;
 	__u8		ndisc_evict_nocarrier;
 	__u8		ra_honor_pio_life;
+	__u8		ra_honor_pio_pflag;
 
 	struct ctl_table_header *sysctl_header;
 };
diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index 62a407db1bf5..b18e81f0c9e1 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -37,10 +37,14 @@  struct prefix_info {
 		struct __packed {
 #if defined(__BIG_ENDIAN_BITFIELD)
 			__u8	onlink : 1,
-			 	autoconf : 1,
-				reserved : 6;
+				autoconf : 1,
+				routeraddr : 1,
+				preferpd : 1,
+				reserved : 4;
 #elif defined(__LITTLE_ENDIAN_BITFIELD)
-			__u8	reserved : 6,
+			__u8	reserved : 4,
+				preferpd : 1,
+				routeraddr : 1,
 				autoconf : 1,
 				onlink : 1;
 #else
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 55a0fd589fc8..4febf679a435 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -239,6 +239,7 @@  static struct ipv6_devconf ipv6_devconf __read_mostly = {
 	.ioam6_id_wide		= IOAM6_DEFAULT_IF_ID_WIDE,
 	.ndisc_evict_nocarrier	= 1,
 	.ra_honor_pio_life	= 0,
+	.ra_honor_pio_pflag	= 0,
 };
 
 static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
@@ -302,6 +303,7 @@  static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
 	.ioam6_id_wide		= IOAM6_DEFAULT_IF_ID_WIDE,
 	.ndisc_evict_nocarrier	= 1,
 	.ra_honor_pio_life	= 0,
+	.ra_honor_pio_pflag	= 0,
 };
 
 /* Check if link is ready: is it up and is a valid qdisc available */
@@ -2762,6 +2764,7 @@  void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)
 	u32 addr_flags = 0;
 	struct inet6_dev *in6_dev;
 	struct net *net = dev_net(dev);
+	bool ignore_autoconf = false;
 
 	pinfo = (struct prefix_info *) opt;
 
@@ -2864,7 +2867,8 @@  void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)
 
 	/* Try to figure out our local address for this prefix */
 
-	if (pinfo->autoconf && in6_dev->cnf.autoconf) {
+	ignore_autoconf = READ_ONCE(in6_dev->cnf.ra_honor_pio_pflag) && pinfo->preferpd;
+	if (pinfo->autoconf && in6_dev->cnf.autoconf && !ignore_autoconf) {
 		struct in6_addr addr;
 		bool tokenized = false, dev_addr_generated = false;
 
@@ -6926,6 +6930,15 @@  static const struct ctl_table addrconf_sysctl[] = {
 		.extra1		= SYSCTL_ZERO,
 		.extra2		= SYSCTL_ONE,
 	},
+	{
+		.procname	= "ra_honor_pio_pflag",
+		.data		= &ipv6_devconf.ra_honor_pio_pflag,
+		.maxlen		= sizeof(u8),
+		.mode		= 0644,
+		.proc_handler	= proc_dou8vec_minmax,
+		.extra1		= SYSCTL_ZERO,
+		.extra2		= SYSCTL_ONE,
+	},
 #ifdef CONFIG_IPV6_ROUTER_PREF
 	{
 		.procname	= "accept_ra_rtr_pref",