1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #12848 from miri64/gnrc_sixlowpan_frag_rb/fix/interval-fixes

gnrc_sixlowpan_frag_vrb: fix issues with interval marker inherited from base
This commit is contained in:
Alexandre Abadie 2020-01-15 20:57:49 +01:00 committed by GitHub
commit fc45c2cc83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 3 deletions

View File

@ -25,6 +25,7 @@
#include <stdbool.h>
#include <stdint.h>
#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
if (IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_RB)) {
gnrc_sixlowpan_frag_rb_base_rm(&vrb->super);
#endif /* MODULE_GNRC_SIXLOWPAN_FRAG */
}
vrb->super.src_len = 0;
}

View File

@ -302,6 +302,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;

View File

@ -83,6 +83,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;
}
}