From 5602bd55edacc3ef4a9740b612b0e7e524a38f6c Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Fri, 13 Dec 2019 15:54:05 +0100 Subject: [PATCH 1/5] gnrc/ipv6/ext/frag: Move configurations to 'CONFIG_' namespace Macros that changed: GNRC_IPV6_EXT_FRAG_SEND_SIZE -> CONFIG_GNRC_IPV6_EXT_FRAG_SEND_SIZE GNRC_IPV6_EXT_FRAG_RBUF_SIZE -> CONFIG_GNRC_IPV6_EXT_FRAG_RBUF_SIZE GNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE -> CONFIG_GNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US -> CONFIG_GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US --- sys/include/net/gnrc/ipv6/ext.h | 16 ++++++++-------- sys/include/net/gnrc/ipv6/ext/frag.h | 2 +- .../ipv6/ext/frag/gnrc_ipv6_ext_frag.c | 18 +++++++++--------- tests/gnrc_ipv6_ext_frag/Makefile | 2 +- tests/gnrc_ipv6_ext_frag/main.c | 6 +++--- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/sys/include/net/gnrc/ipv6/ext.h b/sys/include/net/gnrc/ipv6/ext.h index 72d8500ceba1..e06b650e41e0 100644 --- a/sys/include/net/gnrc/ipv6/ext.h +++ b/sys/include/net/gnrc/ipv6/ext.h @@ -52,8 +52,8 @@ extern "C" { * * @note Only applicable with [gnrc_ipv6_ext_frag](@ref net_gnrc_ipv6_ext_frag) module */ -#ifndef GNRC_IPV6_EXT_FRAG_SEND_SIZE -#define GNRC_IPV6_EXT_FRAG_SEND_SIZE (1U) +#ifndef CONFIG_GNRC_IPV6_EXT_FRAG_SEND_SIZE +#define CONFIG_GNRC_IPV6_EXT_FRAG_SEND_SIZE (1U) #endif /** @@ -63,8 +63,8 @@ extern "C" { * * @note Only applicable with [gnrc_ipv6_ext_frag](@ref net_gnrc_ipv6_ext_frag) module */ -#ifndef GNRC_IPV6_EXT_FRAG_RBUF_SIZE -#define GNRC_IPV6_EXT_FRAG_RBUF_SIZE (1U) +#ifndef CONFIG_GNRC_IPV6_EXT_FRAG_RBUF_SIZE +#define CONFIG_GNRC_IPV6_EXT_FRAG_RBUF_SIZE (1U) #endif /** @@ -75,8 +75,8 @@ extern "C" { * * @note Only applicable with [gnrc_ipv6_ext_frag](@ref net_gnrc_ipv6_ext_frag) module */ -#ifndef GNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE -#define GNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE (GNRC_IPV6_EXT_FRAG_RBUF_SIZE * 2U) +#ifndef CONFIG_GNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE +#define CONFIG_GNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE (CONFIG_GNRC_IPV6_EXT_FRAG_RBUF_SIZE * 2U) #endif /** @@ -84,8 +84,8 @@ extern "C" { * * @note Only applicable with [gnrc_ipv6_ext_frag](@ref net_gnrc_ipv6_ext_frag) module */ -#ifndef GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US -#define GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US (10U * US_PER_SEC) +#ifndef CONFIG_GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US +#define CONFIG_GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US (10U * US_PER_SEC) #endif /** @} **/ diff --git a/sys/include/net/gnrc/ipv6/ext/frag.h b/sys/include/net/gnrc/ipv6/ext/frag.h index 4c571dd1222f..c8852857ed1f 100644 --- a/sys/include/net/gnrc/ipv6/ext/frag.h +++ b/sys/include/net/gnrc/ipv6/ext/frag.h @@ -182,7 +182,7 @@ static inline void gnrc_ipv6_ext_frag_rbuf_del(gnrc_ipv6_ext_frag_rbuf_t *rbuf) * * This calls @ref gnrc_ipv6_ext_frag_rbuf_del() for all reassembly buffer * entries for which * gnrc_ipv6_ext_frag_rbuf_t::arrival is - * @ref GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US in the past. + * @ref CONFIG_GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US in the past. */ void gnrc_ipv6_ext_frag_rbuf_gc(void); /** @} */ diff --git a/sys/net/gnrc/network_layer/ipv6/ext/frag/gnrc_ipv6_ext_frag.c b/sys/net/gnrc/network_layer/ipv6/ext/frag/gnrc_ipv6_ext_frag.c index e7025a4efff5..95b756a0a245 100644 --- a/sys/net/gnrc/network_layer/ipv6/ext/frag/gnrc_ipv6_ext_frag.c +++ b/sys/net/gnrc/network_layer/ipv6/ext/frag/gnrc_ipv6_ext_frag.c @@ -34,9 +34,9 @@ #define ENABLE_DEBUG (0) #include "debug.h" -static gnrc_ipv6_ext_frag_send_t _snd_bufs[GNRC_IPV6_EXT_FRAG_SEND_SIZE]; -static gnrc_ipv6_ext_frag_rbuf_t _rbuf[GNRC_IPV6_EXT_FRAG_RBUF_SIZE]; -static gnrc_ipv6_ext_frag_limits_t _limits_pool[GNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE]; +static gnrc_ipv6_ext_frag_send_t _snd_bufs[CONFIG_GNRC_IPV6_EXT_FRAG_SEND_SIZE]; +static gnrc_ipv6_ext_frag_rbuf_t _rbuf[CONFIG_GNRC_IPV6_EXT_FRAG_RBUF_SIZE]; +static gnrc_ipv6_ext_frag_limits_t _limits_pool[CONFIG_GNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE]; static clist_node_t _free_limits; static xtimer_t _gc_xtimer; static msg_t _gc_msg = { .type = GNRC_IPV6_EXT_FRAG_RBUF_GC }; @@ -61,7 +61,7 @@ void gnrc_ipv6_ext_frag_init(void) memset(_rbuf, 0, sizeof(_rbuf)); #endif _last_id = random_uint32(); - for (unsigned i = 0; i < GNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE; i++) { + for (unsigned i = 0; i < CONFIG_GNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE; i++) { clist_rpush(&_free_limits, (clist_node_t *)&_limits_pool[i]); } } @@ -272,7 +272,7 @@ void gnrc_ipv6_ext_frag_send(gnrc_ipv6_ext_frag_send_t *snd_buf) static gnrc_ipv6_ext_frag_send_t *_snd_buf_alloc(void) { - for (unsigned i = 0; i < GNRC_IPV6_EXT_FRAG_SEND_SIZE; i++) { + for (unsigned i = 0; i < CONFIG_GNRC_IPV6_EXT_FRAG_SEND_SIZE; i++) { gnrc_ipv6_ext_frag_send_t *snd_buf = &_snd_bufs[i]; if (snd_buf->pkt == NULL) { return snd_buf; @@ -420,7 +420,7 @@ gnrc_pktsnip_t *gnrc_ipv6_ext_frag_reass(gnrc_pktsnip_t *pkt) goto error_release; } rbuf->arrival = xtimer_now_usec(); - xtimer_set_msg(&_gc_xtimer, GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US, &_gc_msg, + xtimer_set_msg(&_gc_xtimer, CONFIG_GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US, &_gc_msg, sched_active_pid); nh = fh->nh; offset = ipv6_ext_frag_get_offset(fh); @@ -538,7 +538,7 @@ gnrc_ipv6_ext_frag_rbuf_t *gnrc_ipv6_ext_frag_rbuf_get(ipv6_hdr_t *ipv6, uint32_t id) { gnrc_ipv6_ext_frag_rbuf_t *res = NULL, *oldest = NULL; - for (unsigned i = 0; i < GNRC_IPV6_EXT_FRAG_RBUF_SIZE; i++) { + for (unsigned i = 0; i < CONFIG_GNRC_IPV6_EXT_FRAG_RBUF_SIZE; i++) { gnrc_ipv6_ext_frag_rbuf_t *tmp = &_rbuf[i]; if (tmp->ipv6 != NULL) { if ((tmp->id == id) && @@ -580,9 +580,9 @@ void gnrc_ipv6_ext_frag_rbuf_free(gnrc_ipv6_ext_frag_rbuf_t *rbuf) void gnrc_ipv6_ext_frag_rbuf_gc(void) { uint32_t now = xtimer_now_usec(); - for (unsigned i = 0; i < GNRC_IPV6_EXT_FRAG_RBUF_SIZE; i++) { + for (unsigned i = 0; i < CONFIG_GNRC_IPV6_EXT_FRAG_RBUF_SIZE; i++) { gnrc_ipv6_ext_frag_rbuf_t *rbuf = &_rbuf[i]; - if ((now - rbuf->arrival) > GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US) { + if ((now - rbuf->arrival) > CONFIG_GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US) { gnrc_ipv6_ext_frag_rbuf_del(rbuf); } } diff --git a/tests/gnrc_ipv6_ext_frag/Makefile b/tests/gnrc_ipv6_ext_frag/Makefile index eaac0d07b86d..8862249f3b4e 100644 --- a/tests/gnrc_ipv6_ext_frag/Makefile +++ b/tests/gnrc_ipv6_ext_frag/Makefile @@ -6,7 +6,7 @@ export TAP ?= tap0 CFLAGS += -DOUTPUT=TEXT CFLAGS += -DTEST_SUITES="gnrc_ipv6_ext_frag" -CFLAGS += -DGNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE=3 +CFLAGS += -DCONFIG_GNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE=3 ifeq (native,$(BOARD)) TERMFLAGS ?= $(TAP) diff --git a/tests/gnrc_ipv6_ext_frag/main.c b/tests/gnrc_ipv6_ext_frag/main.c index 16bab89290fa..6526b608b17b 100644 --- a/tests/gnrc_ipv6_ext_frag/main.c +++ b/tests/gnrc_ipv6_ext_frag/main.c @@ -110,7 +110,7 @@ static void test_ipv6_ext_frag_rbuf_get(void) TEST_ASSERT_MESSAGE(&ipv6 == rbuf->ipv6, "IPv6 header is not the same"); /* check that reassembly buffer never gets full */ - for (unsigned i = 1; i < (2 * GNRC_IPV6_EXT_FRAG_RBUF_SIZE); i++) { + for (unsigned i = 1; i < (2 * CONFIG_GNRC_IPV6_EXT_FRAG_RBUF_SIZE); i++) { rbuf = gnrc_ipv6_ext_frag_rbuf_get( &ipv6, TEST_ID + i ); @@ -171,7 +171,7 @@ static void test_ipv6_ext_frag_rbuf_gc(void) TEST_ASSERT_NOT_NULL(rbuf->pkt); TEST_ASSERT_MESSAGE(pkt->data == rbuf->ipv6, "IPv6 header is not the same"); - rbuf->arrival -= GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US; + rbuf->arrival -= CONFIG_GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US; gnrc_ipv6_ext_frag_rbuf_gc(); TEST_ASSERT_NULL(rbuf->pkt); TEST_ASSERT_NULL(rbuf->ipv6); @@ -410,7 +410,7 @@ static void test_ipv6_ext_frag_reass_out_of_order_rbuf_full(void) static const uint32_t foreign_id = TEST_ID + 44U; - TEST_ASSERT_EQUAL_INT(1, GNRC_IPV6_EXT_FRAG_RBUF_SIZE); + TEST_ASSERT_EQUAL_INT(1, CONFIG_GNRC_IPV6_EXT_FRAG_RBUF_SIZE); /* prepare fragment from a from a foreign datagram */ ipv6->nh = PROTNUM_IPV6_EXT_FRAG; ipv6->hl = TEST_HL; From fe820d8d9d293f8fa76fd10df2aa68be70991a20 Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Mon, 16 Dec 2019 09:56:59 +0100 Subject: [PATCH 2/5] Kconfig: Expose gnrc/ipv6/ext/frag configurations --- sys/net/gnrc/Kconfig | 1 + .../gnrc/network_layer/ipv6/ext/frag/Kconfig | 43 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 sys/net/gnrc/network_layer/ipv6/ext/frag/Kconfig diff --git a/sys/net/gnrc/Kconfig b/sys/net/gnrc/Kconfig index 4d986c9a6824..a940e6d2463d 100644 --- a/sys/net/gnrc/Kconfig +++ b/sys/net/gnrc/Kconfig @@ -11,6 +11,7 @@ rsource "link_layer/lorawan/Kconfig" rsource "netif/Kconfig" rsource "network_layer/ipv6/Kconfig" rsource "network_layer/ipv6/blacklist/Kconfig" +rsource "network_layer/ipv6/ext/frag/Kconfig" rsource "network_layer/ipv6/whitelist/Kconfig" rsource "network_layer/sixlowpan/Kconfig" diff --git a/sys/net/gnrc/network_layer/ipv6/ext/frag/Kconfig b/sys/net/gnrc/network_layer/ipv6/ext/frag/Kconfig new file mode 100644 index 000000000000..192ea13f126e --- /dev/null +++ b/sys/net/gnrc/network_layer/ipv6/ext/frag/Kconfig @@ -0,0 +1,43 @@ +# Copyright (c) 2019 HAW Hamburg +# +# This file is subject to the terms and conditions of the GNU Lesser +# General Public License v2.1. See the file LICENSE in the top level +# directory for more details. +# +menuconfig KCONFIG_MODULE_GNRC_IPV6_EXT_FRAG + bool "Configure GNRC IPv6 fragmentation and reassembly" + depends on MODULE_GNRC_IPV6_EXT_FRAG + help + Configure GNRC IPv6 fragmentation and reassembly via Kconfig. + +if KCONFIG_MODULE_GNRC_IPV6_EXT_FRAG + +config GNRC_IPV6_EXT_FRAG_SEND_SIZE + int "Number of entries IPv6 in the send buffer" + default 1 + help + This limits the total amount of datagrams that can be fragmented at + the same time. + +config GNRC_IPV6_EXT_FRAG_RBUF_SIZE + int "Number of IPv6 fragmentation reassembly entries" + default 1 + help + This limits the total amount of datagrams that can be reassembled at + the same time. + +config GNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE + int "Number of allocatable fragment limit objects" + default 2 + help + Number of total allocable gnrc_ipv6_ext_frag_limits_t objects. This is + the maximum number of receivable fragments, shared between all + fragmented datagrams. + +config GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US + int "Timeout for IPv6 fragmentation reassembly buffer entries" + default 10000000 + help + This value is expressed in microseconds. + +endif # KCONFIG_MODULE_GNRC_IPV6_EXT_FRAG From e1e302f8d150f1b08ad5d72e253d5668daef5e8b Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Mon, 16 Dec 2019 09:57:21 +0100 Subject: [PATCH 3/5] tests/gnrc_ipv6_ext_frag: Set limits pool size if not set by Kconfig --- tests/gnrc_ipv6_ext_frag/Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/gnrc_ipv6_ext_frag/Makefile b/tests/gnrc_ipv6_ext_frag/Makefile index 8862249f3b4e..49593888fcb4 100644 --- a/tests/gnrc_ipv6_ext_frag/Makefile +++ b/tests/gnrc_ipv6_ext_frag/Makefile @@ -6,7 +6,6 @@ export TAP ?= tap0 CFLAGS += -DOUTPUT=TEXT CFLAGS += -DTEST_SUITES="gnrc_ipv6_ext_frag" -CFLAGS += -DCONFIG_GNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE=3 ifeq (native,$(BOARD)) TERMFLAGS ?= $(TAP) @@ -48,3 +47,8 @@ ethos: $(Q)env -u CC -u CFLAGS make -C $(RIOTTOOLS)/ethos include $(RIOTBASE)/Makefile.include + +# Set the pool size for limit objects if not being set by Kconfig +ifndef CONFIG_GNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE + CFLAGS += -DCONFIG_GNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE=3 +endif From f716cb1d3982fabc455cabd9f64fc9bdd92623ed Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Wed, 29 Jan 2020 11:58:49 +0100 Subject: [PATCH 4/5] makefiles/kconfig: Allow to override SHOULD_RUN_KCONFIG --- makefiles/kconfig.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefiles/kconfig.mk b/makefiles/kconfig.mk index 02b2c6e24958..98e41753fb5d 100644 --- a/makefiles/kconfig.mk +++ b/makefiles/kconfig.mk @@ -67,7 +67,7 @@ $(GENERATED_DIR): $(CLEAN) # configuration via Kconfig is disabled by default). Should this change, the # check would not longer be valid, and Kconfig would have to run on every # build. -SHOULD_RUN_KCONFIG := $(or $(wildcard $(APPDIR)/*.config), $(wildcard $(APPDIR)/Kconfig), $(wildcard $(KCONFIG_MERGED_CONFIG)), $(filter menuconfig, $(MAKECMDGOALS))) +SHOULD_RUN_KCONFIG ?= $(or $(wildcard $(APPDIR)/*.config), $(wildcard $(APPDIR)/Kconfig), $(wildcard $(KCONFIG_MERGED_CONFIG)), $(filter menuconfig, $(MAKECMDGOALS))) ifneq (,$(SHOULD_RUN_KCONFIG)) # Add configuration header to build dependencies From 6481076866395711052dc11df15dc4956b93e8cc Mon Sep 17 00:00:00 2001 From: Leandro Lanzieri Date: Wed, 29 Jan 2020 12:05:23 +0100 Subject: [PATCH 5/5] tests/gnrc_ipv6_ext_frag: Add Kconfig default configurations This test needs the pool size for limit objects set to 3 by default so it does not fail. As this is done with the 'app.config' file, we explicitly disable Kconfig by default. --- tests/gnrc_ipv6_ext_frag/Makefile | 4 ++++ tests/gnrc_ipv6_ext_frag/app.config | 3 +++ 2 files changed, 7 insertions(+) create mode 100644 tests/gnrc_ipv6_ext_frag/app.config diff --git a/tests/gnrc_ipv6_ext_frag/Makefile b/tests/gnrc_ipv6_ext_frag/Makefile index 49593888fcb4..a691e1a017cc 100644 --- a/tests/gnrc_ipv6_ext_frag/Makefile +++ b/tests/gnrc_ipv6_ext_frag/Makefile @@ -41,6 +41,10 @@ USEMODULE += ps # So it cannot currently be run TEST_ON_CI_BLACKLIST += all +# As there is an 'app.config' we want to explicitly disable Kconfig by setting +# the variable to empty +SHOULD_RUN_KCONFIG ?= + .PHONY: ethos ethos: diff --git a/tests/gnrc_ipv6_ext_frag/app.config b/tests/gnrc_ipv6_ext_frag/app.config new file mode 100644 index 000000000000..9e2fc064a036 --- /dev/null +++ b/tests/gnrc_ipv6_ext_frag/app.config @@ -0,0 +1,3 @@ +# This test fails if the pool size is less than 3 +CONFIG_KCONFIG_MODULE_GNRC_IPV6_EXT_FRAG=y +CONFIG_GNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE=3