1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/sys
Martine S. Lenders ea449f3f9e gnrc_ipv6: remove obsolete and harmful reception code
When reworking the reception of IPv6 packets I reset a previously set
`ipv6` snip as follows  when the IPv6 extension handler returns a
packet (see first hunk of this commit):

```C
ipv6 = pkt->next->next
```

With `gnrc_ipv6_ext` this makes *somewhat* sense, `pkt->next` was
previously equal to `ipv6` and after the function call `pkt->next`
is the marked extension header, while `pkt->next->next` is the IPv6
header. However, since `ipv6` is already write-protected i.e.
`ipv6->users == 1` (see ll. 665-675), any additional call of
`gnrc_pktbuf_start_write()` [won't][start-write-doc] duplicate the
packet. In fact, the only `gnrc_pktbuf_start_write()` in
`gnrc_ipv6_ext` is used to send the *result* to the subscribers of that
extension header type, leaving the original packet unchanged for the
caller. As such `ipv6` remains the pointer to the IPv6 header whether
we set it in the line above or not. So we actually don't need that
line.

However, the extension header handling also returns a packet when
`gnrc_ipv6_ext` is not compiled in. In that case it is just a dummy
define that returns the packet you give provide it which means that
this still holds true: `pkt->next == ipv6`.
So setting `ipv6` in this case is actually harmful, as `ipv6` now
points to the NETIF header [following the IPv6 header][pkt-structure]
in the packet and this causes the `user` counter of that NETIF header
`hdr` to be decremented if `hdr->users > 1` in the write-protection I
removed in hunk 2 of this commit:

```C
/* pkt might not be writable yet, if header was given above */
ipv6 = gnrc_pktbuf_start_write(ipv6);
if (ipv6 == NULL) {
    DEBUG("ipv6: unable to get write access to packet: dropping it\n");
    gnrc_pktbuf_release(pkt);
    return;
}
```

But as we already established, `ipv6->users` is already 1, so we don't
actually need the write protection here either.

Since the packet stays unchanged after the `ipv6` snip, we also don't
need to re-search for `netif_hdr` after the other two lines are
removed.

[start-write-doc]: https://doc.riot-os.org/group__net__gnrc__pktbuf.html#ga640418467294ae3d408c109ab27bd617
[pkt-structure]: https://doc.riot-os.org/group__net__gnrc__pkt.html#ga278e783e56a5ee6f1bd7b81077ed82a7
2019-07-03 14:44:03 +02:00
..
analog_util sys/analog_util: Refactor adc_map, fix compilation 2018-04-16 13:53:49 +02:00
app_metadata sys/app_metadata: Add app_metadata module 2019-03-05 16:10:06 +01:00
arduino Merge pull request #10150 from fedepell/arduino_2 2018-10-16 08:46:10 +02:00
auto_init usbus_cdc_ecm: provide auto init integration 2019-06-14 16:00:06 +02:00
base64 sys/base64: Add size estimation macros 2019-01-24 08:35:22 +01:00
benchmark sys/benchmark: incl irq.h and fixed output 2018-09-11 11:29:19 +02:00
bitfield doc: remove sys_util references 2018-04-05 14:39:59 +02:00
bloom sys/bloom: pass bitfield to bloom instead of allocating memory 2015-10-05 11:41:53 +02:00
can sys/can: reduce scope of variable 2018-02-22 19:13:39 +01:00
cb_mux sys/cb_mux: initial support 2018-05-28 15:43:41 -04:00
checksum Merge pull request #10228 from bergzand/pr/checksum/fletcher16_split 2019-05-28 22:49:19 +02:00
color color: Fix -Wdouble-promotion warnings 2018-09-28 09:33:40 +02:00
cpp11-compat core: Made thread state an enum 2019-02-13 13:31:52 +01:00
crypto Merge pull request #10120 from mtausig/ocb 2019-04-23 11:08:30 +02:00
div sys: fix doxygen grouping 2018-06-11 19:12:02 +02:00
ecc sys/ecc: add repetition code 2018-10-18 13:37:21 +02:00
eepreg sys/eepreg: initial EEPROM registration support 2018-10-20 09:30:40 -04:00
embunit embunit: Const test case names 2018-06-15 00:34:33 +02:00
event sys/event: add event_wait_timeout() 2019-05-16 12:01:36 +02:00
evtimer evtimer: use conversion macro US_PER_MS 2018-05-23 15:13:31 +02:00
fmt fmt: fix fmt_s32_dec() and fmt_s64_dec() sign bit handling 2019-01-16 15:23:19 +01:00
fs sys/auto_init: fix doxygen grouping 2018-06-11 19:12:02 +02:00
hashes hashes/sha256: don't call memcpy if len==0 2019-01-17 10:56:34 +01:00
include sys/net: add netopt options for lorawan 2019-06-25 13:53:25 +02:00
iolist add copyrights from IOTPUSH project 2019-05-02 12:09:37 +02:00
isrpipe isrpipe: change API to be in line with tsrb 2019-06-05 18:13:57 +02:00
libc/include/sys cleanup: apply headerguard script output 2017-05-24 17:54:02 +02:00
log make: replace curly braces with parenthesis 2018-03-22 20:43:15 +01:00
luid sys/drivers: renamed uuid module to luid 2017-02-27 11:01:20 +01:00
matstat sys/matstat: change ingroup directive 2018-08-24 18:14:03 +02:00
memarray memarray: add fixed-size memory block allocator 2018-04-10 14:37:29 +02:00
mineplex sys: added 5x5 font 'Mineplex' 2016-11-09 11:59:45 +01:00
net gnrc_ipv6: remove obsolete and harmful reception code 2019-07-03 14:44:03 +02:00
newlib_syscalls_default boards/cpu/drivers/sys: use generic stdio_ if 2018-08-22 10:54:25 +02:00
od sys/od: add ASCII representation to memory dump 2017-11-14 09:22:02 +01:00
oneway-malloc doc/mem_management: add implementations and utils 2018-09-27 10:54:39 +02:00
phydat sys/phydat: Add capacitance unit (F) 2019-02-15 13:37:45 +01:00
pipe tests: adapt for arduino uno and duemilanove support 2016-09-21 21:12:58 +02:00
pm_layered pm_layered: Use {} for empty while loops 2018-02-01 06:55:49 +01:00
posix posix_sockets.c: fix send()/write() for connected UDP sockets 2019-04-10 11:19:13 +02:00
ps core: rename thread_state_t to thread_status_t 2019-05-11 12:25:07 +02:00
puf_sram sys/puf_sram: CPU specific attributes for variables 2018-11-20 08:34:53 +01:00
quad_math cppcheck: add/correct reason for cppcheck-suppress 2018-09-25 12:03:58 +02:00
random add copyrights from IOTPUSH project 2019-05-02 12:09:37 +02:00
riotboot sys/riotboot: RIOTBOOT_HDR_LEN generic definition 2019-06-18 15:12:54 +02:00
saul_reg sys: saul: add missing stddef.h include (for NULL) 2018-09-20 23:54:46 +02:00
sema sys/sema: re-test value after owning mutex 2017-03-06 18:03:27 +01:00
seq sys/seq: change ingroup directive 2018-08-24 18:14:03 +02:00
shell shell_commands: gnrc_netif: fix _newline() handling 2019-06-20 16:18:23 +02:00
ssp sys, ssp: fix doxygen grouping 2017-07-03 10:55:35 +02:00
stdio_rtt stdio/vfs: generalized VFS mapping for STDIO 2018-08-30 11:14:59 +02:00
stdio_uart drivers: sys: replace USE_ETHOS_FOR_STDIO macro by MODULE_STDIO_ETHOS 2019-06-23 22:16:03 +02:00
timex sys/timex: fix incompatible atmega time.h 2018-05-28 13:04:55 -04:00
trickle trickle: remove msg_time member from struct 2018-05-17 10:40:12 +02:00
tsrb tsrb: remove now unnecessary cast 2019-06-05 17:10:26 +02:00
ubjson Merge pull request #11703 from fhessel/fix-ubjson-i64 2019-06-18 11:14:11 +02:00
universal_address cppcheck: add/correct reason for cppcheck-suppress 2018-09-25 12:03:58 +02:00
usb/usbus usbus: simplify adding entry to list 2019-06-19 22:22:10 +02:00
uuid uuid: add uuid_from_string() 2018-10-03 10:44:14 +02:00
vfs stdio/vfs: generalized VFS mapping for STDIO 2018-08-30 11:14:59 +02:00
xtimer sys/xtimer: make xtimer_mutex_lock_timeout() actually use us arg 2019-03-12 16:09:04 +01:00
doc.txt sys/doc: add net_lorawan group 2019-04-12 15:51:15 +02:00
Makefile usbus: Initial work to a unified USB stack 2019-06-05 14:22:16 +02:00
Makefile.dep shell: Add command i2c_scan 2019-03-25 14:10:04 +01:00
Makefile.include sys: add pseudomodule scanf_float 2019-05-28 12:10:39 +02:00