From 7a2ce9e93d8a0cf08342a471e4d2b7af786c37f7 Mon Sep 17 00:00:00 2001 From: Jiacheng Guo Date: Sat, 24 Oct 2020 01:40:03 +0800 Subject: [PATCH] [api] check on prefix length when slaac is enabled (#5530) --- src/core/api/border_router_api.cpp | 4 ++++ tests/toranj/test-010-on-mesh-prefix-config-gateway.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/api/border_router_api.cpp b/src/core/api/border_router_api.cpp index 80b31974f..a25b655fd 100644 --- a/src/core/api/border_router_api.cpp +++ b/src/core/api/border_router_api.cpp @@ -62,6 +62,10 @@ otError otBorderRouterAddOnMeshPrefix(otInstance *aInstance, const otBorderRoute // Thread 1.1 Specification 5.13.2 says // "A valid prefix MUST NOT allow both DHCPv6 and SLAAC for address configuration" VerifyOrExit(!aConfig->mDhcp || !aConfig->mSlaac, error = OT_ERROR_INVALID_ARGS); + // RFC 4944 Section 6 says: + // An IPv6 address prefix used for stateless autoconfiguration [RFC4862] + // of an IEEE 802.15.4 interface MUST have a length of 64 bits. + VerifyOrExit(!aConfig->mSlaac || aConfig->mPrefix.mLength == OT_IP6_PREFIX_BITSIZE, error = OT_ERROR_INVALID_ARGS); error = instance.Get().AddOnMeshPrefix(*config); #if OPENTHREAD_FTD && OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE diff --git a/tests/toranj/test-010-on-mesh-prefix-config-gateway.py b/tests/toranj/test-010-on-mesh-prefix-config-gateway.py index ef2890e23..62b36ee38 100644 --- a/tests/toranj/test-010-on-mesh-prefix-config-gateway.py +++ b/tests/toranj/test-010-on-mesh-prefix-config-gateway.py @@ -249,7 +249,7 @@ wpan.verify_within(check_prefix4_removed_from_r1, WAIT_TIME) r1.add_prefix( prefix4, - 48, + 64, priority="-1", stable=True, on_mesh=False, @@ -262,7 +262,7 @@ r1.add_prefix( verify_prefix( [r1], prefix4, - 48, + 64, priority="low", stable=True, on_mesh=False,