Skip to content

Conversation

miri64
Copy link
Member

@miri64 miri64 commented Oct 23, 2018

Contribution description

Since with #10233 we now assume IPv6 packets always to not be pre-parsed, we can iterate over the extension headers by gradually "eating" them away. This allows us to move the iteration over them out of gnrc_ipv6_ext_demux() and into gnrc_ipv6_demux().

By moving the iteration over all extension headers out of gnrc_ipv6_ext_demux() we also can

  1. simplify the extension header handling a lot, as it now just a loop inside gnrc_ipv6_demux(),
  2. remove the recursion to gnrc_ipv6_demux() within gnrc_ipv6_ext_demux().
  3. some cleanup, possible due to all the things above.

I also piggy-backed some follow-up work that are related to demuxing and the fact that they are not pre-parsed:

  • since they are not preparsed, we don't haved to specifically write-protect all the extension headers up to the IPv6 packet, as the whole (un-parsed) packet was already write protected when first received.
  • since the gnrc_ipv6_ext doesn't recurse into gnrc_ipv6_demux() anymore, that function can be made private again.

Testing procedure

I used scapy to inject packets with and without extension headers into a native instance of gnrc_networking:

On RIOT:

udp server start 1337

Within scapy (be aware that to send Ethernet frames, root privileges are required, so best start it with sudo scapy):

DST_ADDR = "fe80::ac4e:aeff:fec0:caab" # use your RIOT node's address here instead
# first send a simple UDP packet to test if the server is working
sendp(Ether() / 
      IPv6(dst=DST_ADDR) /
      UDP(sport=1339, dport=1337) /
      "\x00\x01", iface="tapbr0")
# now send some extension headers (we assume they all are not parsed)
sendp(Ether() /
      IPv6(dst=DST_ADDR) /
      IPv6ExtHdrDestOpt() /
      UDP(sport=1339, dport=1337) /
      "\x00\x01", iface="tapbr0")
sendp(Ether() /
      IPv6(dst=DST_ADDR) /
      IPv6ExtHdrRouting() /
      UDP(sport=1339, dport=1337) /
      "\x00\x01", iface="tapbr0")
# ...

You can find some documentation on IPv6 extension headers in this document

You can also just redo the testing procedures in #10229.

Issues/PRs references

Depends on #10233 (and its dependencies)

PR dependencies

@miri64 miri64 added Area: network Area: Networking Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation State: waiting for other PR State: The PR requires another PR to be merged first labels Oct 23, 2018
@miri64 miri64 added the Process: API change Integration Process: PR contains or issue proposes an API change. Should be handled with care. label Oct 23, 2018
@miri64 miri64 force-pushed the gnrc_ipv6/enh/iterate-out-of-ext branch from 8a4ff3e to b766b10 Compare October 23, 2018 22:58
miri64 added a commit to miri64/RIOT that referenced this pull request Oct 23, 2018
miri64 added a commit to miri64/RIOT that referenced this pull request Oct 24, 2018
@miri64 miri64 force-pushed the gnrc_ipv6/enh/iterate-out-of-ext branch from 870a055 to 252540e Compare October 24, 2018 12:56
@miri64 miri64 force-pushed the gnrc_ipv6/enh/iterate-out-of-ext branch 2 times, most recently from 92f18bb to 8029b4f Compare October 24, 2018 19:33
miri64 added a commit to miri64/RIOT that referenced this pull request Oct 24, 2018
@miri64 miri64 force-pushed the gnrc_ipv6/enh/iterate-out-of-ext branch from 8029b4f to 90c8cea Compare October 25, 2018 17:53
@miri64
Copy link
Member Author

miri64 commented Oct 25, 2018

Rebased to current #10233

@RIOT-OS RIOT-OS deleted a comment Oct 26, 2018
@miri64 miri64 force-pushed the gnrc_ipv6/enh/iterate-out-of-ext branch from 82308cd to b1f1b81 Compare October 29, 2018 19:31
@miri64
Copy link
Member Author

miri64 commented Oct 29, 2018

Rebased to current #10233.

@RIOT-OS RIOT-OS deleted a comment Oct 30, 2018
@miri64
Copy link
Member Author

miri64 commented Oct 30, 2018

Already found the first batch of errors due to my tests :-)

@RIOT-OS RIOT-OS deleted a comment Oct 31, 2018
@miri64
Copy link
Member Author

miri64 commented Dec 13, 2018

Fixed typo in as squashable commit.

@jia200x jia200x added the Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines label Dec 13, 2018
@jia200x
Copy link
Member

jia200x commented Dec 13, 2018

1-fundamentals done. Nice cleanup btw!

@jia200x jia200x added the Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines label Dec 13, 2018
@jia200x
Copy link
Member

jia200x commented Dec 13, 2018

well, it seems to work. I will run #10229 tests as well

@jia200x
Copy link
Member

jia200x commented Dec 13, 2018

#10229 tests run fine.

@jia200x jia200x added the Reviewed: 3-testing The PR was tested according to the maintainer guidelines label Dec 13, 2018
@miri64
Copy link
Member Author

miri64 commented Dec 13, 2018

May I squash?

@jia200x jia200x added the Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines label Dec 13, 2018
@jia200x
Copy link
Member

jia200x commented Dec 13, 2018

May I squash?

Yes, sure

@jia200x
Copy link
Member

jia200x commented Dec 13, 2018

vera++ doesn't report problems with the introduced changes. There are some consecutive empty lines but not in the scope of this PR.

@miri64
Copy link
Member Author

miri64 commented Dec 13, 2018

Squashed

@miri64 miri64 force-pushed the gnrc_ipv6/enh/iterate-out-of-ext branch from 76256a9 to d7c4078 Compare December 13, 2018 15:33
@jia200x jia200x added the Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines label Dec 13, 2018
miri64 and others added 6 commits December 13, 2018 17:22
Since with RIOT-OS#10233 we now assume IPv6 packets always to not be
pre-parsed, we can iterate over the extension headers by gradually
"eating" them away. This allows us to move the iteration over them
out of `gnrc_ipv6_ext_demux()` and into `gnrc_ipv6_demux()`.

By moving the iteration over all extension headers out of
`gnrc_ipv6_ext_demux()` we also can

1. simplify the extension header handling a lot, as it now
   just a loop inside `gnrc_ipv6_demux()`,
2. remove the recursion to `gnrc_ipv6_demux()` within
   `gnrc_ipv6_ext_demux()`.
As `pkt` isn't pre-parsed the write-protection of *the whole* packet
(except the netif-header) comes for free, when this was done in the
receive routine of IPv6.
Since the recursion into `gnrc_ipv6_demux()` was removed in
`gnrc_ipv6_ext`, `gnrc_ipv6.c` is the only user of this function,
so it can be made private. It was only made public so it can be used
from `gnrc_ipv6_ext`.
With the preceding changes the subject of the deprecation note on
`gnrc_pktbuf_duplicate_upto()` becomes actual and thus doesn't need to
be referred to in future but past tense.
@miri64 miri64 force-pushed the gnrc_ipv6/enh/iterate-out-of-ext branch from d7c4078 to 4257b70 Compare December 13, 2018 16:22
@miri64
Copy link
Member Author

miri64 commented Dec 13, 2018

Murdock likes it now :)

Copy link
Member

@jia200x jia200x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

@jia200x
Copy link
Member

jia200x commented Dec 14, 2018

Thanks @miri64 !

@jia200x jia200x merged commit b709e63 into RIOT-OS:master Dec 14, 2018
@miri64 miri64 deleted the gnrc_ipv6/enh/iterate-out-of-ext branch December 14, 2018 10:11
@miri64
Copy link
Member Author

miri64 commented Dec 14, 2018

Thanks for your review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: network Area: Networking CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Process: API change Integration Process: PR contains or issue proposes an API change. Should be handled with care. Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 3-testing The PR was tested according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants