gnrc_ipv6: handle hop-by-hop option before forwarding#10244
gnrc_ipv6: handle hop-by-hop option before forwarding#10244jia200x merged 6 commits intoRIOT-OS:masterfrom
Conversation
1fc934a to
5d076df
Compare
5d076df to
8028f6e
Compare
|
Rebased to current #10234. |
|
Already found some errors due to my tests :-) |
486c053 to
92369f2
Compare
|
Rebased to current #10234. |
92369f2 to
6b5b714
Compare
|
Rebased to current master and dependencies (and added #8594 as a dependency and updated accordingly). |
6b5b714 to
84a6e5a
Compare
|
Rebased to current #10244. |
84a6e5a to
7140adc
Compare
|
Rebased to current master. No longer dependent on other PRs. |
|
(also squashed) |
sys/include/net/gnrc/ipv6/ext.h
Outdated
| uint8_t *nh); | ||
| #else /* defined(MODULE_GNRC_IPV6_EXT) || defined(DOXYGEN) */ | ||
| /* NOPs to make the usage code more readable */ | ||
| #define gnrc_ipv6_ext_process_all(pkt, first_nh) (pkt); |
There was a problem hiding this comment.
This is a little bit misleading IMO. This macro looks like a function and someone could spend some time looking to the actual implementation of gnrc_ipv6_ext_process_all instead of the NOP.
Also I would prefer to move this macro to the C file and just leave only the prototype here.
I would do something like:
[gnrc_ipv6_ext.c]
#ifdef MODULE_GNRC_IPV6_EXT
#define GNRC_IPV6_EXT_PROCESS_ALL(pkt, first_nh) gnrc_ipv6_ext_process_all(pkt, nh)
#else
#define GNRC_IPV6_EXT_PROCESS_ALL(pkt, first_nh) (pkt)
#endif
That way, it's clear GNRC_IPV6_EXT_PROCESS_ALL is a macro
There was a problem hiding this comment.
This is non-sensical. Then the user needs to use ifdefs anyway. The point of these NOP-macros is so you can use the functions in your code without worrying that the module is included or not.
There was a problem hiding this comment.
I don't like the uppercase wrapper-solution either ;)
There was a problem hiding this comment.
Then the user needs to use ifdefs anyway.
But at the same time the user shouldn't use gnrc_ipv6_ext_process_all if the module is not included. I see this only as a helper for gnrc_ipv6_ext.c
There was a problem hiding this comment.
(I won't block the PR for this but still prefer helpers rather than NOPs :)
There was a problem hiding this comment.
To be more accurate, I meant I'm not convinced with mixing a macro and a function with the same name. I would prefer just use a second macro (as I described) or a weak-like symbol mechanism.
Or at least add a tiny note before the usage of this function indicating it resolves to pkt if MODULE_GNRC_IPV6_EXT is not included :)
There was a problem hiding this comment.
This mechanism is already used through-out the code and the behavior is the same as if gnrc_ipv6_ext would be in (but since the stack doesn't know about extension headers it is not handling them).
There was a problem hiding this comment.
Some examples:
RIOT/sys/include/net/gnrc/icmpv6/error.h
Lines 95 to 102 in b709e63
RIOT/sys/include/net/gnrc/netif/internal.h
Lines 470 to 471 in b709e63
The ironic thing: Some reviewers specifically asked me to do it this way...
There was a problem hiding this comment.
yes, I see. There are several ways to handle stubs. I'm fine ;)
|
I'm ok with |
|
Sending one HopByHop header: I receive: When sending a malformed packet: I get As expected |
|
nothing interesting to report code-style-wise |
They are handled separately anyway and this allows us to handle the Hop-by-hop option *before* forwarding in a later step.
This way e.g. a raw socket listening for an extension headers protocol number also get's it.
The function is now only called by `gnrc_ipv6_ext_process_hopopt()` and `gnrc_ipv6_ext_process_all()`, both are part of the `gnrc_ipv6_ext` module.
439d58d to
d711cef
Compare
miri64
left a comment
There was a problem hiding this comment.
Fixed comments and squashed immediately. I also added a fix for a broken debug message I noticed in your dump above (that is already present in master, but no harm piggy-backing it here, right)
d711cef to
c90f2c2
Compare
(Well it does if Git resolves the conflict automatically but wrong. Fixed that) |
c90f2c2 to
864ce4f
Compare
|
ACK. Thanks! |
|
Thank you for the review and thorough testing :-) |
Contribution description
Hop-by-hop options need to be handled separately, as they are required to be handled hop-by-hop, as the name implies. Now after weeks of rework, we are now finally able to do this cleanly within
gnrc_ipv6.Testing procedure
Since there is no proper hop-by-hop option support yet, I repeated my tests from #10234, but also tested with duplicate Hop-by-hop header, as this is an error case now, as per RFC 8200 and activated DEBUG output to verify that it is indeed handled as an error.
Issues/PRs references
Depends on
#8594(merged) and#10234 (and its dependencies)(merged).