-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gnrc_icmpv6_error: initial import #3184
Conversation
b153ed7
to
fbbf7cc
Compare
95bb856
to
e900705
Compare
Removed some code duplication. |
|
||
static inline size_t _min(size_t a, size_t b) | ||
{ | ||
return (a < b) ? a : b; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess a macro would be fine for this.
addressed comments. |
6d77a49
to
10ac802
Compare
Rebased |
10ac802
to
44e466d
Compare
Rebased and adapted to current master |
gnrc_pktsnip_t *gnrc_icmpv6_error_time_exc_build(uint8_t code, gnrc_pktsnip_t *orig_pkt) | ||
{ | ||
return _icmpv6_error_build(ICMPV6_TIME_EXC, code, orig_pkt, 0); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of these wrapper functions? Don't seem to shorten anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are the API functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All other ICMPv6 messages have their own build functions, too. So it would be inconsistent to have only two (these three in one and the param_prob one) for the errors. Especially since the 4th parameter of _icmpv6_error_build()
is for the most cases just used to set the reserved field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All other ICMPv6 messages have their own build functions, too
With #3693 not any more. ;)
I think providing _icmpv6_error_build()
as an API function is sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The case of gnrc_icmpv6_echo_build()
is a totally different one as this one. A generic gnrc_icmpv6_error_build()
would expose reserved fields (which have to be 0) to the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also how would you understandably document the fourth parameter?
Sets the x-th offseted word in the packet. Needs to be 0 for ICMPV6_DST_UNR and ICMPV6_TIME_EXC and the MTU of the interface for ICMPV6_PKT_TOO_BIG.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which "user" needs to send ICMPv6 echo packets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Me e.g. (and these are echo packages). Let's discuss this on Monday f2f.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any result of this discussion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#3693 was merged, but I still argue that it doesn't make sense here. The different message types have different default values (some need code to be 0, some need the "value" field [which is not existent in any of the packet types] to be 0 [when it is the unused-field]) and param_prob even expects a pointer inside orig_pkt
making it the odd one out and an API that would be like @OlegHahm proposed inconsistent.
c7e0096
to
32edf53
Compare
Rebased to #3691 and addressed comments |
needs a rebase to master, since #3691 is no more. |
Is this PR still waiting on anything? |
32edf53
to
fb97bb6
Compare
Nope, rebased to current master (the commit in master was still in here), squashed and adapted commit message |
Untested ACK. |
static inline size_t _fit(gnrc_pktsnip_t *pkt) | ||
{ | ||
/* TODO: replace GNRC_IPV6_NETIF_DEFAULT_MTU with known path MTU? */ | ||
return MIN((gnrc_pkt_len(pkt) + ICMPV6_ERROR_SZ), GNRC_IPV6_NETIF_DEFAULT_MTU); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can GNRC_IPV6_NETIF_DEFAULT_MTU
be greater than IPV6_MIN_MTU
? RFC requires it must be less than IPV6_MIN_MTU
https://tools.ietf.org/html/rfc4443#section-2.4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The RFC refers to the minimum MTU as a minimum, so a packet MUST NOT be smaller than it. It is pretty common to have a bigger MTU: The MTU for Ethernet is typically 1500 (which is exactly the maximum packet size of Ethernet)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It says "without making the error message packet exceed the minimum IPv6 MTU [IPv6]." Doesn't it means we should not exceed 1280 bytes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, my intent is that "it" in "RFC requires it must be less than ..." refers the return value of the _fit
function. Very confusing sentence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, the error message's size must not be greater than the minimum MTU. This implementation is older than the introduction of IPV6_MIN_MTU
so it needs to be adapted, yes.
fb97bb6
to
d1cdee2
Compare
Generalized and centralized. |
d1cdee2
to
80198f1
Compare
I meant rebased and adapted to current master… |
c1e41eb
to
27dc1b4
Compare
27dc1b4
to
70c3d29
Compare
Code was already acked, doesn't seem to break anything, and also should have no affects for other stuff. ACK and go! |
gnrc_icmpv6_error: initial import
Provides capabilities to build ICMPv6 error messages.