mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
ea449f3f9e
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 |
||
---|---|---|
.. | ||
analog_util | ||
app_metadata | ||
arduino | ||
auto_init | ||
base64 | ||
benchmark | ||
bitfield | ||
bloom | ||
can | ||
cb_mux | ||
checksum | ||
color | ||
cpp11-compat | ||
crypto | ||
div | ||
ecc | ||
eepreg | ||
embunit | ||
event | ||
evtimer | ||
fmt | ||
fs | ||
hashes | ||
include | ||
iolist | ||
isrpipe | ||
libc/include/sys | ||
log | ||
luid | ||
matstat | ||
memarray | ||
mineplex | ||
net | ||
newlib_syscalls_default | ||
od | ||
oneway-malloc | ||
phydat | ||
pipe | ||
pm_layered | ||
posix | ||
ps | ||
puf_sram | ||
quad_math | ||
random | ||
riotboot | ||
saul_reg | ||
sema | ||
seq | ||
shell | ||
ssp | ||
stdio_rtt | ||
stdio_uart | ||
timex | ||
trickle | ||
tsrb | ||
ubjson | ||
universal_address | ||
usb/usbus | ||
uuid | ||
vfs | ||
xtimer | ||
doc.txt | ||
Makefile | ||
Makefile.dep | ||
Makefile.include |