Skip to content
Snippets Groups Projects
Commit a7066daa authored by Oleg Hahm's avatar Oleg Hahm
Browse files

Merge pull request #2934 from authmillenon/sixlowpan_frag/fix/gc

sixlowpan_frag: fix reassembly buffer garbage collection
parents 2682c38e bc41cfc9
No related branches found
No related tags found
No related merge requests found
...@@ -222,8 +222,8 @@ static bool _rbuf_update_ints(rbuf_t *entry, uint16_t offset, size_t frag_size) ...@@ -222,8 +222,8 @@ static bool _rbuf_update_ints(rbuf_t *entry, uint16_t offset, size_t frag_size)
DEBUG("6lo rfrag: add interval (%" PRIu16 ", %" PRIu16 ") to entry (%s, ", DEBUG("6lo rfrag: add interval (%" PRIu16 ", %" PRIu16 ") to entry (%s, ",
new->start, new->end, ng_netif_addr_to_str(l2addr_str, new->start, new->end, ng_netif_addr_to_str(l2addr_str,
sizeof(l2addr_str), entry->src, entry->src_len)); sizeof(l2addr_str), entry->src, entry->src_len));
DEBUG("%s, %zu, %" PRIu16 ")\n", ng_netif_addr_to_str(l2addr_str, DEBUG("%s, %u, %" PRIu16 ")\n", ng_netif_addr_to_str(l2addr_str,
sizeof(l2addr_str), entry->dst, entry->dst_len), entry->datagram_size, sizeof(l2addr_str), entry->dst, entry->dst_len), entry->datagram_size,
entry->tag); entry->tag);
LL_PREPEND(entry->ints, new); LL_PREPEND(entry->ints, new);
...@@ -240,11 +240,14 @@ static void _rbuf_gc(void) ...@@ -240,11 +240,14 @@ static void _rbuf_gc(void)
vtimer_now(&now); vtimer_now(&now);
for (i = 0; i < RBUF_SIZE; i++) { for (i = 0; i < RBUF_SIZE; i++) {
if ((rbuf[i].pkt != NULL) && if (rbuf[i].pkt == NULL) { /* leave GC early if there is still room */
((now.seconds - rbuf[i].arrival) > RBUF_TIMEOUT)) { return;
}
else if ((rbuf[i].pkt != NULL) &&
((now.seconds - rbuf[i].arrival) > RBUF_TIMEOUT)) {
DEBUG("6lo rfrag: entry (%s, ", ng_netif_addr_to_str(l2addr_str, DEBUG("6lo rfrag: entry (%s, ", ng_netif_addr_to_str(l2addr_str,
sizeof(l2addr_str), rbuf[i].src, rbuf[i].src_len)); sizeof(l2addr_str), rbuf[i].src, rbuf[i].src_len));
DEBUG("%s, %zu, %" PRIu16 ") timed out\n", DEBUG("%s, %u, %" PRIu16 ") timed out\n",
ng_netif_addr_to_str(l2addr_str, sizeof(l2addr_str), rbuf[i].dst, ng_netif_addr_to_str(l2addr_str, sizeof(l2addr_str), rbuf[i].dst,
rbuf[i].dst_len), rbuf[i].dst_len),
rbuf[i].datagram_size, rbuf[i].tag); rbuf[i].datagram_size, rbuf[i].tag);
...@@ -258,7 +261,7 @@ static void _rbuf_gc(void) ...@@ -258,7 +261,7 @@ static void _rbuf_gc(void)
} }
if ((i >= RBUF_SIZE) && (oldest != NULL) && (oldest->pkt != NULL)) { if ((i >= RBUF_SIZE) && (oldest != NULL) && (oldest->pkt != NULL)) {
DEBUG("6lo rfrag: reassembly buffer full, remove oldest entry"); DEBUG("6lo rfrag: reassembly buffer full, remove oldest entry\n");
ng_pktbuf_release(oldest->pkt); ng_pktbuf_release(oldest->pkt);
_rbuf_rem(oldest); _rbuf_rem(oldest);
} }
...@@ -280,9 +283,10 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len, ...@@ -280,9 +283,10 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len,
(rbuf[i].dst_len == dst_len) && (rbuf[i].dst_len == dst_len) &&
(memcmp(rbuf[i].src, src, src_len) == 0) && (memcmp(rbuf[i].src, src, src_len) == 0) &&
(memcmp(rbuf[i].dst, dst, dst_len) == 0)) { (memcmp(rbuf[i].dst, dst, dst_len) == 0)) {
DEBUG("6lo rfrag: entry (%s, ", ng_netif_addr_to_str(l2addr_str, DEBUG("6lo rfrag: entry %p (%s, ", (void *)(&rbuf[i]),
sizeof(l2addr_str), rbuf[i].src, rbuf[i].src_len)); ng_netif_addr_to_str(l2addr_str, sizeof(l2addr_str),
DEBUG("%s, %zu, %" PRIu16 ") found\n", rbuf[i].src, rbuf[i].src_len));
DEBUG("%s, %u, %" PRIu16 ") found\n",
ng_netif_addr_to_str(l2addr_str, sizeof(l2addr_str), ng_netif_addr_to_str(l2addr_str, sizeof(l2addr_str),
rbuf[i].dst, rbuf[i].dst_len), rbuf[i].dst, rbuf[i].dst_len),
rbuf[i].datagram_size, rbuf[i].tag); rbuf[i].datagram_size, rbuf[i].tag);
...@@ -315,9 +319,10 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len, ...@@ -315,9 +319,10 @@ static rbuf_t *_rbuf_get(const void *src, size_t src_len,
res->datagram_size = size; res->datagram_size = size;
res->cur_size = 0; res->cur_size = 0;
DEBUG("6lo rfrag: entry (%s, ", ng_netif_addr_to_str(l2addr_str, DEBUG("6lo rfrag: entry %p (%s, ", (void *)res,
sizeof(l2addr_str), res->src, res->src_len)); ng_netif_addr_to_str(l2addr_str, sizeof(l2addr_str), res->src,
DEBUG("%s, %zu, %" PRIu16 ") created\n", res->src_len));
DEBUG("%s, %u, %" PRIu16 ") created\n",
ng_netif_addr_to_str(l2addr_str, sizeof(l2addr_str), res->dst, ng_netif_addr_to_str(l2addr_str, sizeof(l2addr_str), res->dst,
res->dst_len), res->datagram_size, res->tag); res->dst_len), res->datagram_size, res->tag);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment