From 7cba2fb63df2c7cf915b374195d7f28dea48da91 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Sun, 20 Oct 2019 16:07:21 +0200 Subject: [PATCH] gnrc_ipv6_nib: don't auto-configure IPv6 w/o SLAAC on non-6LN interface When the NIB is compiled for 6LN mode (but not a 6LBR), the Stateless Address Autoconfiguration (SLAAC) functionality is disabled, as it is typically not required; see `sys/include/net/gnrc/ipv6/nib/conf.h`, ll. 46 and 55. However, if a non-6LN interface is also compiled in (still without making the node a border router) an auto-configured address will be assigned in accordance with [RFC 6775] to the interface, just assuming the interface is a 6LN interface. As it then only performs duplicate address detection RFC-6775-style then, the address then never becomes valid, as the duplicate address detection according to [RFC 4862] (part of the SLAAC functionality) is never performed. As auto-configuring an address without SLAAC doesn't make sense, this fix makes the interface skip it completely, but provides a warning to the user, so they know what to do. [RFC 6775]: https://tools.ietf.org/html/rfc6775#section-5.2 [RFC 4862]: https://tools.ietf.org/html/rfc4862#section-5.4 --- sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.c b/sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.c index c27b2199dd..a3dd6c7da0 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.c +++ b/sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.c @@ -15,6 +15,7 @@ #include +#include "log.h" #include "luid.h" #include "net/gnrc/netif/internal.h" @@ -34,6 +35,15 @@ void _auto_configure_addr(gnrc_netif_t *netif, const ipv6_addr_t *pfx, int idx; uint8_t flags = GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_TENTATIVE; +#if !GNRC_IPV6_NIB_CONF_SLAAC + if (!gnrc_netif_is_6ln(netif)) { + LOG_WARNING("SLAAC not activated; will not auto-configure IPv6 address " + "for interface %u.\n" + " Use GNRC_IPV6_NIB_CONF_SLAAC=1 to activate.\n", + netif->pid); + return; + } +#endif if (!(netif->flags & GNRC_NETIF_FLAGS_HAS_L2ADDR)) { DEBUG("nib: interface %i has no link-layer addresses\n", netif->pid); return;