From d99012561ac5f80b17a53cff4f6d58c3ceb801ea Mon Sep 17 00:00:00 2001 From: "Martine S. Lenders" Date: Thu, 30 Jan 2020 17:03:28 +0100 Subject: [PATCH] gnrc_ipv6_ext_frag: add configuration option to keep oldest entry --- sys/include/net/gnrc/ipv6/ext.h | 13 +++++++++++++ sys/net/gnrc/network_layer/ipv6/ext/frag/Kconfig | 7 +++++++ .../ipv6/ext/frag/gnrc_ipv6_ext_frag.c | 3 ++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/sys/include/net/gnrc/ipv6/ext.h b/sys/include/net/gnrc/ipv6/ext.h index e06b650e41..f7118cbcca 100644 --- a/sys/include/net/gnrc/ipv6/ext.h +++ b/sys/include/net/gnrc/ipv6/ext.h @@ -88,6 +88,19 @@ extern "C" { #define CONFIG_GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US (10U * US_PER_SEC) #endif +/** + * @brief Do not override oldest datagram when reassembly buffer is full + * + * @note Only applicable with [gnrc_ipv6_ext_frag](@ref net_gnrc_ipv6_ext_frag) module + * + * When not set, it will cause the reassembly buffer to override the oldest + * entry when a fragment for a new datagram is received. When set to 1, no entry + * will be overwritten (they will still timeout normally) + */ +#ifdef DOXYGEN +#define CONFIG_GNRC_IPV6_EXT_FRAG_RBUF_DO_NOT_OVERRIDE +#endif + /** @} **/ /** diff --git a/sys/net/gnrc/network_layer/ipv6/ext/frag/Kconfig b/sys/net/gnrc/network_layer/ipv6/ext/frag/Kconfig index 192ea13f12..b4820917f6 100644 --- a/sys/net/gnrc/network_layer/ipv6/ext/frag/Kconfig +++ b/sys/net/gnrc/network_layer/ipv6/ext/frag/Kconfig @@ -40,4 +40,11 @@ config GNRC_IPV6_EXT_FRAG_RBUF_TIMEOUT_US help This value is expressed in microseconds. +config GNRC_IPV6_EXT_FRAG_RBUF_DO_NOT_OVERRIDE + bool "Do not override oldest datagram when reassembly buffer is full" + help + When not set, it will cause the reassembly buffer to override the oldest + entry when a fragment for a new datagram is received. When set to 1, no + entry will be overwritten (they will still timeout normally) + endif # KCONFIG_MODULE_GNRC_IPV6_EXT_FRAG 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 95b756a0a2..a807831d59 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 @@ -557,7 +557,8 @@ gnrc_ipv6_ext_frag_rbuf_t *gnrc_ipv6_ext_frag_rbuf_get(ipv6_hdr_t *ipv6, oldest = tmp; } } - if (res == NULL) { + if ((res == NULL) && + !IS_ACTIVE(CONFIG_GNRC_IPV6_EXT_FRAG_RBUF_DO_NOT_OVERRIDE)) { assert(oldest != NULL); /* reassembly buffer is full, so there needs * to be an oldest entry */ DEBUG("ipv6_ext_frag: dropping oldest entry\n");