BACKPORT: Add support for PIO p flag

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>
Reviewed-by: Maciej Żenczykowski <maze@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Link: https://lore.kernel.org/all/20240729220059.3018247-1-prohr@google.com/
Bug: 315069348
(cherry picked from commit 990c304930138dcd7a49763417e6e5313b81293e)
Change-Id: I212cfbd558d265885ec63d3c97182bc012ea34e4
Signed-off-by: Patrick Rohr <prohr@google.com>
This commit is contained in:
Patrick Rohr
2024-07-29 15:00:59 -07:00
parent 29bf3aa759
commit 8d1ac3f3fc
4 changed files with 42 additions and 3 deletions

View File

@@ -1918,6 +1918,20 @@ accept_ra_pinfo - BOOLEAN
- enabled if accept_ra is enabled.
- disabled if accept_ra is 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.

View File

@@ -84,7 +84,7 @@ struct ipv6_devconf {
ANDROID_KABI_RESERVE(2);
ANDROID_KABI_RESERVE(3);
ANDROID_KABI_BACKPORT_OK(4);
ANDROID_KABI_BACKPORT_USE(4, struct { __u8 ra_honor_pio_pflag; __u8 padding4[7]; });
};
struct ipv6_params {

View File

@@ -42,10 +42,22 @@ struct prefix_info {
#endif
#if defined(__BIG_ENDIAN_BITFIELD)
__u8 onlink : 1,
autoconf : 1,
autoconf : 1,
# ifdef __GENKSYMS__
reserved : 6;
# else
routeraddr : 1,
preferpd : 1,
reserved : 4;
# endif
#elif defined(__LITTLE_ENDIAN_BITFIELD)
# ifdef __GENKSYMS__
__u8 reserved : 6,
# else
__u8 reserved : 4,
preferpd : 1,
routeraddr : 1,
# endif
autoconf : 1,
onlink : 1;
#else

View File

@@ -240,6 +240,7 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = {
.addr_gen_mode = IN6_ADDR_GEN_MODE_EUI64,
.disable_policy = 0,
.rpl_seg_enabled = 0,
.ra_honor_pio_pflag = 0,
};
static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
@@ -297,6 +298,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
.addr_gen_mode = IN6_ADDR_GEN_MODE_EUI64,
.disable_policy = 0,
.rpl_seg_enabled = 0,
.ra_honor_pio_pflag = 0,
};
/* Check if link is ready: is it up and is a valid qdisc available */
@@ -2734,6 +2736,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;
@@ -2827,7 +2830,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;
@@ -6793,6 +6797,15 @@ static const struct ctl_table addrconf_sysctl[] = {
.mode = 0644,
.proc_handler = proc_dointvec,
},
{
.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",