Skip to contentSkip to conversation

Add support for PIO p flag

PATCH Superseded Patrick Rohr 3 participants 5 messages Jul 26, 2024 – Jul 29, 2024

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add support for PIO p flag

draft-ietf-6man-pio-pflag is adding a new flag to the Prefix Information Option to signal the pd-per-device addressing mechanism.

When accept_pio_pflag is enabled, the presence of the p-flag will cause an a flag in the same PIO to be ignored.

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

Cc Maciej Żenczykowski <[email protected]>
Cc Lorenzo Colitti <[email protected]>
Cc David Lamparter <[email protected]>
---
 Documentation/networking/ip-sysctl.rst | 11 +++++++++++
 include/linux/ipv6.h                   |  1 +
 include/net/addrconf.h                 |  8 ++++++--
 net/ipv6/addrconf.c                    | 15 ++++++++++++++-
 4 files changed, 32 insertions(+), 3 deletions(-)
Documentation/networking/ip-sysctl.rst +11 -0
index 3616389c8c2d..322a0329b366 100644
@@ -2362,6 +2362,17 @@ ra_honor_pio_life - BOOLEAN
 
 	Default: 0 (disabled)
 
+accept_pio_pflag - BOOLEAN
+	Used to indicate userspace support for a DHCPv6-PD client.
+	If enabled, the presence of the PIO p flag indicates to the
+	kernel to ignore the autoconf flag.
+
+	- If disabled, the P flag is ignored.
+	- If enabled, disables SLAAC to obtain new addresses from
+	  prefixes with the P flag set.
+
+	Default: 0 (disabled)
+
 accept_ra_rt_info_min_plen - INTEGER
 	Minimum prefix length of Route Information in RA.
 
include/linux/ipv6.h +1 -0
index 383a0ea2ab91..396b87d76b55 100644
@@ -89,6 +89,7 @@ struct ipv6_devconf {
 	__u8		ioam6_enabled;
 	__u8		ndisc_evict_nocarrier;
 	__u8		ra_honor_pio_life;
+	__u8		accept_pio_pflag;
 
 	struct ctl_table_header *sysctl_header;
 };
include/net/addrconf.h +6 -2
index 62a407db1bf5..59496aa23012 100644
@@ -38,9 +38,13 @@ struct prefix_info {
 #if defined(__BIG_ENDIAN_BITFIELD)
 			__u8	onlink : 1,
 			 	autoconf : 1,
-				reserved : 6;
+			 	routeraddr : 1,
+				pdpreferred : 1,
+				reserved : 4;
 #elif defined(__LITTLE_ENDIAN_BITFIELD)
-			__u8	reserved : 6,
+			__u8	reserved : 4,
+				pdpreferred : 1,
+			 	routeraddr : 1,
 				autoconf : 1,
 				onlink : 1;
 #else
net/ipv6/addrconf.c +14 -1
index 55a0fd589fc8..3e27725a12fc 100644
@@ -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,
+	.accept_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,
+	.accept_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_flag = 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_flag = READ_ONCE(in6_dev->cnf.accept_pio_pflag) && pinfo->pdpreferred;
+	if (pinfo->autoconf && in6_dev->cnf.autoconf && !ignore_autoconf_flag) {
 		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	= "accept_pio_pflag",
+		.data		= &ipv6_devconf.accept_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",
Signature · 1 line
2.46.0.rc1.232.g9752f9e123-goog
reviewer
#1 lore raw
Quoted 6 lines · Patrick Rohr

draft-ietf-6man-pio-pflag is adding a new flag to the Prefix Information Option to signal the pd-per-device addressing mechanism.

When accept_pio_pflag is enabled, the presence of the p-flag will cause an a flag in the same PIO to be ignored.

Quoted 7 lines

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

Cc Maciej Żenczykowski <[email protected]>
Cc Lorenzo Colitti <[email protected]>
Cc David Lamparter <[email protected]>

Hi Patrick,

This is not a full review, and as per the form letter below, net-next is closed, so you'd be best to repost. But I will offer some very minor review in the meantime.

Firstly, please seed the CC list for Networking patches using get_maintainers.pl --git-min-percent 25 this.patch

Secondly, as noted inline, there are two cases of mixed of tabs and spaces used for indenting in this patch.

## Form letter - net-next-closed

The merge window for v6.11 has begun and therefore net-next is closed for new drivers, features, code refactoring and optimizations. We are currently accepting bug fixes only.

Please repost when net-next reopens after 15th July

RFC patches sent for review only are welcome at any time.

See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle
--
pw-bot: defer

...

include/net/addrconf.h struct prefix_info { · line 41

Quoted 10 lines
include/net/addrconf.h +1 -1
index 62a407db1bf5..59496aa23012 100644
@@ -38,9 +38,13 @@ struct prefix_info {
 #if defined(__BIG_ENDIAN_BITFIELD)
 			__u8	onlink : 1,
 			 	autoconf : 1,
-				reserved : 6;
+			 	routeraddr : 1,

The line above puts a space before a tab in indentation. This is already the case on the autoconf line, but let's not add another instance.

Flagged by checkpatch.

include/net/addrconf.h struct prefix_info { · line 47

Quoted 7 lines
include/net/addrconf.h +5 -1
+				pdpreferred : 1,
+				reserved : 4;
 #elif defined(__LITTLE_ENDIAN_BITFIELD)
-			__u8	reserved : 6,
+			__u8	reserved : 4,
+				pdpreferred : 1,
+			 	routeraddr : 1,

Here too.

Quoted 3 lines
include/net/addrconf.h +0 -0
 				autoconf : 1,
 				onlink : 1;
 #else

...

reviewer
#2 lore raw
Quoted 27 lines · Simon Horman
Quoted 6 lines · Patrick Rohr

draft-ietf-6man-pio-pflag is adding a new flag to the Prefix Information Option to signal the pd-per-device addressing mechanism.

When accept_pio_pflag is enabled, the presence of the p-flag will cause an a flag in the same PIO to be ignored.

Quoted 7 lines

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

Cc Maciej Żenczykowski <[email protected]>
Cc Lorenzo Colitti <[email protected]>
Cc David Lamparter <[email protected]>

Hi Patrick,

This is not a full review, and as per the form letter below, net-next is closed, so you'd be best to repost. But I will offer some very minor review in the meantime.

Firstly, please seed the CC list for Networking patches using get_maintainers.pl --git-min-percent 25 this.patch

Secondly, as noted inline, there are two cases of mixed of tabs and spaces used for indenting in this patch.

Quoted 7 lines

## Form letter - net-next-closed

The merge window for v6.11 has begun and therefore net-next is closed for new drivers, features, code refactoring and optimizations. We are currently accepting bug fixes only.

Please repost when net-next reopens after 15th July

Sorry, I'm not sure why I wrote the 15th, I meant the 29th.

Quoted 4 lines

RFC patches sent for review only are welcome at any time.

See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle

...

#3 lore raw
Quoted 37 lines · Simon Horman
Quoted 27 lines · Simon Horman
Quoted 6 lines · Patrick Rohr

draft-ietf-6man-pio-pflag is adding a new flag to the Prefix Information Option to signal the pd-per-device addressing mechanism.

When accept_pio_pflag is enabled, the presence of the p-flag will cause an a flag in the same PIO to be ignored.

Quoted 7 lines

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

Cc Maciej Żenczykowski <[email protected]>
Cc Lorenzo Colitti <[email protected]>
Cc David Lamparter <[email protected]>

Hi Patrick,

This is not a full review, and as per the form letter below, net-next is closed, so you'd be best to repost. But I will offer some very minor review in the meantime.

Firstly, please seed the CC list for Networking patches using get_maintainers.pl --git-min-percent 25 this.patch

Secondly, as noted inline, there are two cases of mixed of tabs and spaces used for indenting in this patch.

Quoted 7 lines

## Form letter - net-next-closed

The merge window for v6.11 has begun and therefore net-next is closed for new drivers, features, code refactoring and optimizations. We are currently accepting bug fixes only.

Please repost when net-next reopens after 15th July

Quoted 8 lines

Sorry, I'm not sure why I wrote the 15th, I meant the 29th.

Quoted 4 lines

RFC patches sent for review only are welcome at any time.

See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle

...

Thank you, Simon! I will follow up with a v2 when the branch reopens.

#4 lore raw
In reply to Patrick Rohr
Quoted 26 lines · Patrick Rohr

draft-ietf-6man-pio-pflag is adding a new flag to the Prefix Information Option to signal the pd-per-device addressing mechanism.

When accept_pio_pflag is enabled, the presence of the p-flag will cause an a flag in the same PIO to be ignored.

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

Cc Maciej Żenczykowski <[email protected]>
Cc Lorenzo Colitti <[email protected]>
Cc David Lamparter <[email protected]>
---
 Documentation/networking/ip-sysctl.rst | 11 +++++++++++
 include/linux/ipv6.h                   |  1 +
 include/net/addrconf.h                 |  8 ++++++--
 net/ipv6/addrconf.c                    | 15 ++++++++++++++-
 4 files changed, 32 insertions(+), 3 deletions(-)
Documentation/networking/ip-sysctl.rst +0 -0
index 3616389c8c2d..322a0329b366 100644

Documentation/networking/ip-sysctl.rst ra_honor_pio_life - BOOLEAN · line 2365

Quoted 4 lines
Documentation/networking/ip-sysctl.rst +1 -0
@@ -2362,6 +2362,17 @@ ra_honor_pio_life - BOOLEAN
 
        Default: 0 (disabled)
 
+accept_pio_pflag - BOOLEAN

I wonder if this should be 'honour_pio_pflag' instead? accept seems weird since the result is actually to ignore...

Documentation/networking/ip-sysctl.rst ra_honor_pio_life - BOOLEAN · line 2372

Quoted 7 lines
Documentation/networking/ip-sysctl.rst +7 -0
+       Used to indicate userspace support for a DHCPv6-PD client.
+       If enabled, the presence of the PIO p flag indicates to the
+       kernel to ignore the autoconf flag.
+
+       - If disabled, the P flag is ignored.
+       - If enabled, disables SLAAC to obtain new addresses from
+         prefixes with the P flag set.

I think the phrasing/grammar here could use some work...

perhaps 'if enabled, the P flag will disable SLAAC autoconfiguration.'

Quoted 11 lines
Documentation/networking/ip-sysctl.rst +3 -0
+
+       Default: 0 (disabled)
+
 accept_ra_rt_info_min_plen - INTEGER
        Minimum prefix length of Route Information in RA.
 
include/linux/ipv6.h +0 -0
index 383a0ea2ab91..396b87d76b55 100644

include/linux/ipv6.h struct ipv6_devconf { · line 92

Quoted 4 lines
include/linux/ipv6.h +1 -0
@@ -89,6 +89,7 @@ struct ipv6_devconf {
        __u8            ioam6_enabled;
        __u8            ndisc_evict_nocarrier;
        __u8            ra_honor_pio_life;
+       __u8            accept_pio_pflag;

perhaps 'ra_honor_pio_pflag' to match 'ra_honor_pio_life'

Quoted 8 lines
include/linux/ipv6.h +0 -0
        struct ctl_table_header *sysctl_header;
 };
include/net/addrconf.h +0 -0
index 62a407db1bf5..59496aa23012 100644

include/net/addrconf.h struct prefix_info { · line 42

Quoted 6 lines
include/net/addrconf.h +2 -1
@@ -38,9 +38,13 @@ struct prefix_info {
 #if defined(__BIG_ENDIAN_BITFIELD)
                        __u8    onlink : 1,
                                autoconf : 1,
-                               reserved : 6;
+                               routeraddr : 1,
+                               pdpreferred : 1,

would 'preferpd' be better/shorter?

Quoted 30 lines
include/net/addrconf.h +4 -1
+                               reserved : 4;
 #elif defined(__LITTLE_ENDIAN_BITFIELD)
-                       __u8    reserved : 6,
+                       __u8    reserved : 4,
+                               pdpreferred : 1,
+                               routeraddr : 1,
                                autoconf : 1,
                                onlink : 1;
 #else
net/ipv6/addrconf.c +2 -0
index 55a0fd589fc8..3e27725a12fc 100644
@@ -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,
+       .accept_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,
+       .accept_pio_pflag       = 0,
 };
 
 /* Check if link is ready: is it up and is a valid qdisc available */

net/ipv6/addrconf.c void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao) · line 2767

Quoted 4 lines
net/ipv6/addrconf.c +1 -0
@@ -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_flag = false;

I think you can skip '_flag'

Quoted 32 lines
net/ipv6/addrconf.c +11 -2
        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_flag = READ_ONCE(in6_dev->cnf.accept_pio_pflag) && pinfo->pdpreferred;
+       if (pinfo->autoconf && in6_dev->cnf.autoconf && !ignore_autoconf_flag) {
                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       = "accept_pio_pflag",
+               .data           = &ipv6_devconf.accept_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