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

39 Commits

Author SHA1 Message Date
Marian Buschsieweke
3a80878848
sys/net/gnrc_pktbuf: make static buffer internal 2022-07-21 16:25:14 +02:00
Marian Buschsieweke
32bb9743e4
sys/net/gnrc/pktbuf_static: make use of alignas()
Since we are now using C11, we can make use of `alignas()` provided by
`<stdalign.h>` to make the alignment code easier to read.
2022-07-20 17:52:15 +02:00
Benjamin Valentin
0b3f66f0db sys/net/gnrc_pktbuf_static: fix documentation of use-after-free detection 2022-06-23 00:31:32 +02:00
Benjamin Valentin
a165093b10 sys/net/gnrc_pktbuf_static: add use-after-free detection 2022-06-22 15:41:15 +02:00
Marian Buschsieweke
b7269c39e8
sys/net/gnrc_pktbuf_static: fix compilation with -Wcast-align
Comparing the pointers as `uintptr_t` won't hurt but makes the compiler
happy.
2021-12-03 10:12:34 +01:00
Martine Lenders
ecba5fa1d0
gnrc_pktbuf_static: expose _align() function to be used for tests 2021-02-19 12:23:22 +01:00
Marian Buschsieweke
3970b667aa
sys/net/gnrc_pktbuf: deduplicate code
Implement gnrc_pktbuf_release_error() in gnrc_pktbuf once, rather than providing
two implementations in gnrc_pktbuf_static and gnrc_pktbuf_malloc
2021-01-26 10:50:19 +01:00
Bas Stottelaar
1b35d06a51 sys/*: realign ENABLE_DEBUG 2020-10-23 11:27:48 +02:00
Marian Buschsieweke
28d4bf7751
sys/net/gnrc/pktbuf_static: Fix alignment
The buffer _pktbuf was previously only aligned to a 1 byte boundary. This could
result in run time issues.
2020-09-22 15:04:56 +02:00
Akshai M
5523d119b6 gnrc/pktbuf : Move 'GNRC_PKTBUF_SIZE' to 'CONFIG_' 2020-06-11 14:46:36 +05:30
Martine Lenders
41708d9f03 gnrc_pktbuf_static: unify NULL pointer output for stats
Different platforms evaluate `printf()` for NULL pointers differently,
resulting tests checking for a certain output to fail. This unifies that
(debug) output for the static packet buffer statistics.
2019-10-23 14:56:29 +02:00
Martine S. Lenders
b83430aa62 gnrc_pktbuf: remove gnrc_pktbuf_duplicate_upto
The removal of this function was already announced for the 2019.04
release. So it is safe to remove it.
2019-07-03 15:09:18 +02:00
Martine Lenders
efb658a67c gnrc_pktbuf_static: allow write-protect of size 0 snips
Size 0 snips are legal packet snips (empty payload e.g.) so it doesn't
make sense to issue an error in the write-protection in that case.

API documentation doesn't mention it either and the tests still pass
with the check removed.
2019-03-12 14:34:49 +01:00
a2d679c76f gnrc/pktbuf: avoid memcpy if size <= 0 2019-01-16 16:13:14 +01:00
Martine Lenders
acfe57a52b gnrc_pktbuf_static: reduce checks to be in line with new alignment 2018-06-27 17:19:34 +02:00
Martine Lenders
8a75d8d189 gnrc_pktbuf_static: fix alignment issue / leaks
This fixes an alignment issue I encountered in the static version of
the packet buffer.

The bug is caused by a race-condition where a certain order of
operations leads to a chunk being released according to the
byte-alignment of the platform, but overlapping potential space for
a future `_unused_t` struct e.g. (x mark allocated regions):

                    Future leak of size sizeof(_unused_t)       Time
                    v                                            |
    +------------+-----+--------------------+                    |
    |xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|                    +
    +------------+-----+--------------------+                    |
                                                                 |
    +------------+--+--+--------------------+                    |
    |               |xxxxxxxxxxxxxxxxxxxxxxx|                    +
    +------------+--+--+--------------------+                    |
                                                                 |
    +-----+------+--+--+--------------------+                    |
    |xxxxx|         |xxxxxxxxxxxxxxxxxxxxxxx|                    +
    +-----+------+--+--+--------------------+                    |
                                                                 |
    +-----+------+-----+---------+----------+                    |
    |xxxxx|                      |xxxxxxxxxx|                    +
    +-----+------+-----+---------+----------+                    |
                                                                 |
    +-----+------+-----+--------------------+                    |
    |xxxxx|      |xxxxxxxxxxxxxxxxxxxxxxxxxx|                    +
    +-----+------+-----+--------------------+                    |
                                                                 |
    +------------+-----+--------------------+                    |
    |xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|                    +
    +------------+-----+--------------------+                    |
                                                                 |
    +------------+-----+--------------------+                    |
    |xxxxxxxxxxxxxxxxxx|                    |                    +
    +------------+-----+--------------------+                    |
                                                                 |
    +------------+-----+--------------------+                    |
    |            |xxxxx|                    |                    +
    +------------+-----+--------------------+                    |
                                                                 v

Sadly, I wasn't able to create a reproducable unittest that show-cases
this corner-case, since I don't understand the order of operations that
cause this one 100%, but the bug is reproducable (but also not
reliably) by sending large (i.e. fragmented) packets to a 6Lo-enabled
host from more than 1 host simultaneously (use `gnrc_pktbuf_cmd` to
check).

By making the size of `_unused_t` the only condition for alignment,
this bug is fixed.
2018-06-27 17:18:24 +02:00
Joakim Nohlgård
8514ff5f15 gnrc/pktbuf: Const correctness on gnrc_pktbuf_add 2018-06-15 00:44:23 +02:00
Martine Lenders
f8c2078f94
gnrc_pktbuf_static: assert that users > 0 on release 2017-11-06 15:27:44 +01:00
Martine Lenders
f51e4ca767
fixup! gnrc_pktbuf: move common auxiliary functions to common module 2017-06-15 15:15:02 +02:00
Martine Lenders
d8336c38b6
gnrc_pktbuf: move common auxiliary functions to common module
The packet buffer was originally designed to have a replaceable
back-end. This is why the actual module is called `gnrc_pktbuf_static`.
However, since than some auxiliary functions snuck into the static
back-end, which should go into the common module (which is a
pseudo-module at the moment).

This fix makes the `gnrc_pktbuf` pseudo-module an actual module and
moves the auxiliary functions to that module.
2017-06-14 12:24:56 +02:00
Martine Lenders
4ed199a9ad gnrc_pktbuf: adapt pktbuf to od change 2017-03-28 19:14:59 +02:00
Martine Lenders
490b907cd3 Merge pull request #6086 from miri64/gnrc_pktbuf_static/fix/i5748
gnrc_pktbuf_static: fix #5748
2016-12-16 07:18:38 +01:00
Martine Lenders
5e236cdc16 gnrc_pktbuf_static: fix #5748 2016-12-15 20:57:32 +01:00
smlng
ad698267fb gnrc_pktbuf: add asserts
- fix static analyzer warning
    - update @pre doc accordingly
2016-12-13 18:18:11 +01:00
Martine Lenders
5dad8f1edd gnrc_pktbuf: allow for 0-sized payload snips 2016-09-27 21:49:57 +02:00
Yonezawa-T2
6443a2bb5c gnrc_pktbuf: Adds a function to duplicate packet chain 2016-03-24 18:20:28 +09:00
Joakim Nohlgård
d770d6ab31 gnrc_sixlowpan: Preserve order when replacing 6lowpan header by decoded IPv6 header 2016-03-12 11:36:24 +01:00
Cenk Gündoğan
03f34927cd pktbuf: do not inline gnrc_pktbuf_remove_snip 2016-02-10 16:38:40 +01:00
Martine Lenders
131cae626c Merge pull request #3362 from authmillenon/ng_neterr/feat/initial
[RFC] gnrc: initial import of an asynchronous error reporting API
2016-01-26 21:35:30 +01:00
Martine Lenders
da23ffe096 gnrc: initial import of an asynchroneous error reporting API 2016-01-23 16:42:19 +01:00
Martine Lenders
4d877c7bf7 gnrc_pktbuf_static: add stat variable for maximum packet buffer byte 2016-01-23 16:41:01 +01:00
Johann Fischer
2f94d669d7 gnrc_pktbuf_static.c: fix overflow in gnrc_pktbuf_realloc_data
This patch fixes overflow, which is caused by
(pkt->size - aligned_size). This happens if pkt->size and
new size are unaligned and the difference
between pkt->size and new size is less than four.
2016-01-07 15:17:52 +01:00
Martine Lenders
a463279331 gnrc_pktbuf_static: print chunk addresses in stats 2015-10-05 14:18:56 +02:00
Oleg Hahm
c309e43b73 gnrc pktbuf: satisfying my parentheses obsession 2015-10-02 12:10:43 +02:00
Martine Lenders
e20451edd8 gnrc_pktbuf_static: fix order of calling 2015-09-29 15:27:49 +02:00
Oleg Hahm
30885a2a2d pktbuf: correct size for printing chunk dumps 2015-09-23 16:44:45 +02:00
Martine Lenders
e5c6e3da54 gnrc_pktbuf_static: fix marking of pktsnips with short payload 2015-09-22 10:50:57 +02:00
Cenk Gündoğan
55c938636b gnrc_pktbuf_static: fix DEBUG 2015-09-16 14:35:02 +02:00
Martine Lenders
58ff31bfe9 gnrc: make all gnrc modules sub-modules of gnrc 2015-08-18 23:00:07 +02:00