Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kconfig: Expose gnrc/ipv6/ext/frag configurations #12958

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion makefiles/kconfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions sys/include/net/gnrc/ipv6/ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand All @@ -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

/**
Expand All @@ -75,17 +75,17 @@ 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

/**
* @brief Timeout for IPv6 fragmentation reassembly buffer entries in microseconds
*
* @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

/** @} **/
Expand Down
2 changes: 1 addition & 1 deletion sys/include/net/gnrc/ipv6/ext/frag.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
/** @} */
Expand Down
1 change: 1 addition & 0 deletions sys/net/gnrc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
43 changes: 43 additions & 0 deletions sys/net/gnrc/network_layer/ipv6/ext/frag/Kconfig
Original file line number Diff line number Diff line change
@@ -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
leandrolanzieri marked this conversation as resolved.
Show resolved Hide resolved
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
18 changes: 9 additions & 9 deletions sys/net/gnrc/network_layer/ipv6/ext/frag/gnrc_ipv6_ext_frag.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand All @@ -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]);
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) &&
Expand Down Expand Up @@ -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);
}
}
Expand Down
10 changes: 9 additions & 1 deletion tests/gnrc_ipv6_ext_frag/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export TAP ?= tap0

CFLAGS += -DOUTPUT=TEXT
CFLAGS += -DTEST_SUITES="gnrc_ipv6_ext_frag"
CFLAGS += -DGNRC_IPV6_EXT_FRAG_LIMITS_POOL_SIZE=3

ifeq (native,$(BOARD))
TERMFLAGS ?= $(TAP)
Expand Down Expand Up @@ -42,9 +41,18 @@ 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:
$(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
miri64 marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 3 additions & 0 deletions tests/gnrc_ipv6_ext_frag/app.config
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions tests/gnrc_ipv6_ext_frag/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down