Netdev List
 help / color / mirror / Atom feed
From: Benjamin Valentin <benjamin.valentin@ml-pa.com>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
	Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
	David Ahern <dsahern@kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: [RFC][PATCH] ipv6/addrconf: allow to use SLAAC with prefixes < /64
Date: Fri, 15 Jul 2022 02:12:42 +0200	[thread overview]
Message-ID: <20220715021242.4abdade0@rechenknecht2k11> (raw)

This enables SLAAC with prefixes smaller than /64.
SLAAC is performed as usual using only the lower 64 bit of the address
for the interface identifier.
The bits not used by the prefix are simply considered 0 (and must be
considered 0 as they will be set by downstream subnets).

The idea is to being able to advertise a larger subnet, that can then
be autonomously split in a hierarchical fashion by downstream routers. [0]

[0] https://github.com/RIOT-OS/RIOT/blob/master/sys/net/gnrc/routing/ipv6_auto_subnets/gnrc_ipv6_auto_subnets.c

Signed-off-by: Benjamin Valentin <benjamin.valentin@ml-pa.com>
---
 net/ipv6/addrconf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 49cc6587dd77..aacf01d8cdb6 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2787,8 +2787,9 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len, bool sllao)
 		struct in6_addr addr;
 		bool tokenized = false, dev_addr_generated = false;
 
-		if (pinfo->prefix_len == 64) {
-			memcpy(&addr, &pinfo->prefix, 8);
+		if (pinfo->prefix_len <= 64) {
+			memset(&addr, 0, 8);
+			memcpy(&addr, &pinfo->prefix, (pinfo->prefix_len + 7) / 8);
 
 			if (!ipv6_addr_any(&in6_dev->token)) {
 				read_lock_bh(&in6_dev->lock);

                 reply	other threads:[~2022-07-15  0:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220715021242.4abdade0@rechenknecht2k11 \
    --to=benjamin.valentin@ml-pa.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox