From 54a859917029dc4ccf56da39d68445523d22fe9b Mon Sep 17 00:00:00 2001 From: "Martine S. Lenders" Date: Fri, 29 Nov 2019 17:58:02 +0100 Subject: [PATCH 1/3] gnrc_sixlowpan_frag_vrb: call base_rm() with gnrc_sixlowpan_frag_rb `gnrc_sixlowpan_frag_rb_base_rm()` cleans up the intervals which is part of `gnrc_sixlowpan_frag_rb`, not `gnrc_sixlowpan_frag`, so when the `gnrc_sixlowpan_frag` is not compiled in, but `gnrc_sixlowpan_frag_rb`, the intervals allocated in the reassembly buffer and inherited by the virtual reassembly buffer are never released. --- sys/include/net/gnrc/sixlowpan/frag/vrb.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/include/net/gnrc/sixlowpan/frag/vrb.h b/sys/include/net/gnrc/sixlowpan/frag/vrb.h index e21347e729..3bb859195a 100644 --- a/sys/include/net/gnrc/sixlowpan/frag/vrb.h +++ b/sys/include/net/gnrc/sixlowpan/frag/vrb.h @@ -25,6 +25,7 @@ #include #include +#include "kernel_defines.h" #include "net/gnrc/netif.h" #include "net/gnrc/sixlowpan/config.h" #ifdef MODULE_GNRC_SIXLOWPAN_FRAG @@ -123,9 +124,9 @@ gnrc_sixlowpan_frag_vrb_t *gnrc_sixlowpan_frag_vrb_get( */ static inline void gnrc_sixlowpan_frag_vrb_rm(gnrc_sixlowpan_frag_vrb_t *vrb) { -#ifdef MODULE_GNRC_SIXLOWPAN_FRAG - gnrc_sixlowpan_frag_rb_base_rm(&vrb->super); -#endif /* MODULE_GNRC_SIXLOWPAN_FRAG */ + if (IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_RB)) { + gnrc_sixlowpan_frag_rb_base_rm(&vrb->super); + } vrb->super.src_len = 0; } From 0251d6585ed1bb4419d087fe416c260c3386c113 Mon Sep 17 00:00:00 2001 From: "Martine S. Lenders" Date: Fri, 29 Nov 2019 18:00:54 +0100 Subject: [PATCH 2/3] gnrc_sixlowpan_frag_rb: error when interval buffer is full --- .../sixlowpan/frag/rb/gnrc_sixlowpan_frag_rb.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/net/gnrc/network_layer/sixlowpan/frag/rb/gnrc_sixlowpan_frag_rb.c b/sys/net/gnrc/network_layer/sixlowpan/frag/rb/gnrc_sixlowpan_frag_rb.c index 7a08aee543..a0f782ef28 100644 --- a/sys/net/gnrc/network_layer/sixlowpan/frag/rb/gnrc_sixlowpan_frag_rb.c +++ b/sys/net/gnrc/network_layer/sixlowpan/frag/rb/gnrc_sixlowpan_frag_rb.c @@ -307,6 +307,12 @@ static int _rbuf_add(gnrc_netif_hdr_t *netif_hdr, gnrc_pktsnip_t *pkt, memcpy(((uint8_t *)entry->pkt->data) + offset, data, frag_size); } + else { + /* no space left in rbuf interval buffer*/ + gnrc_pktbuf_release(entry->pkt); + gnrc_sixlowpan_frag_rb_remove(entry); + res = RBUF_ADD_ERROR; + } /* no errors and not consumed => release packet */ gnrc_pktbuf_release(pkt); return res; From d9ecc0b9bb0a97ec7f5cfe7553fc310287f817d5 Mon Sep 17 00:00:00 2001 From: "Martine S. Lenders" Date: Tue, 3 Dec 2019 12:23:56 +0100 Subject: [PATCH 3/3] gnrc_sixlowpan_frag_vrb: append intervals of given base if entry exists Otherwise the list in `base->ints` will get lost. --- .../frag/vrb/gnrc_sixlowpan_frag_vrb.c | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/sys/net/gnrc/network_layer/sixlowpan/frag/vrb/gnrc_sixlowpan_frag_vrb.c b/sys/net/gnrc/network_layer/sixlowpan/frag/vrb/gnrc_sixlowpan_frag_vrb.c index 9a78e26aca..a1e15ad88b 100644 --- a/sys/net/gnrc/network_layer/sixlowpan/frag/vrb/gnrc_sixlowpan_frag_vrb.c +++ b/sys/net/gnrc/network_layer/sixlowpan/frag/vrb/gnrc_sixlowpan_frag_vrb.c @@ -80,6 +80,34 @@ gnrc_sixlowpan_frag_vrb_t *gnrc_sixlowpan_frag_vrb_add( vrbe->super.dst_len, addr_str), vrbe->out_tag); } + /* _equal_index() => append intervals of `base`, so they don't get + * lost. We use append, so we don't need to change base! */ + else if (base->ints != NULL) { + gnrc_sixlowpan_frag_rb_int_t *tmp = vrbe->super.ints; + + if (tmp != base->ints) { + /* base->ints is not already vrbe->super.ints */ + if (tmp != NULL) { + /* iterate before appending and check if `base->ints` is + * not already part of list */ + while (tmp->next != NULL) { + if (tmp == base->ints) { + tmp = NULL; + } + /* cppcheck-suppress nullPointer + * (reason: possible bug in cppcheck, tmp can't + * clearly be a NULL pointer here) */ + tmp = tmp->next; + } + if (tmp != NULL) { + tmp->next = base->ints; + } + } + else { + vrbe->super.ints = base->ints; + } + } + } break; } }