Skip to contentSkip to conversation

ipv6/addrconf: allow to use SLAAC with prefixes < /64

RFC PATCH New Benjamin Valentin 1 participant 1 message Jul 15, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 ipv6/addrconf: allow to use SLAAC with prefixes < /64

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

---
 net/ipv6/addrconf.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
net/ipv6/addrconf.c +3 -2
index 49cc6587dd77..aacf01d8cdb6 100644
@@ -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);