-
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_ndp_host: Initial import of host behavior of router discovery #3746
Conversation
128fbe4
to
67c7ca4
Compare
67c7ca4
to
e9d77f9
Compare
Rebased to current dependencies |
@@ -264,6 +338,7 @@ void gnrc_ipv6_netif_remove(kernel_pid_t pid); | |||
*/ | |||
gnrc_ipv6_netif_t *gnrc_ipv6_netif_get(kernel_pid_t pid); | |||
|
|||
#if (defined(MODULE_GNRC_NDP_ROUTER) || defined(MODULE_GNRC_SIXLOWPAN_ND_ROUTER)) |
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 this ifdef?
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.
This was introduced in #3745 and proposed by @cgundogan (#3745 (comment)). I liked the idea because it prevents that the function is called 'accidentally' ;-)
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.
But to answer your question in a direct manner: To generate NOP macros in the else case. (You will see this technique quite a bit throughout the NDP-expansions)
e9d77f9
to
d89da6d
Compare
d1c8aa2
to
8878f4d
Compare
Rebased to current master and dependencies. |
/* calculate new random reachable time */ | ||
uint32_t reach_time = genrand_uint32_range(GNRC_NDP_MIN_RAND, GNRC_NDP_MAX_RAND); | ||
if_entry->reach_time_base = byteorder_ntohl(rtr_adv->reach_time); | ||
reach_time = (reach_time * if_entry->reach_time_base) / 10; |
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 10 comes from the fact, that GNRC_NDP_MIN_RAND
and GNRC_NDP_MAX_RAND
are bigger by a factor of 10 than in the RFC (because they are fractions). Don't know how to express that, other than already documented here: https://github.com/RIOT-OS/RIOT/blob/master/sys/include/net/gnrc/ipv6/netif.h#L296
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.
Actually, I understand neither this explanation nor the relation to the documentation of reach_time_base`.
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.
reach_time
is calculated by taking gnrc_ipv6_netif_t::reach_time_base
(set by the advertisement) and multiply it by a random value between 0.5 and 1.5 (https://tools.ietf.org/html/rfc4861#section-10). To avoid floating point numbers (and also have some variation) I used 5 and 15 as values for GNRC_NDP_MIN_RAND
and GNRC_NDP_MAX_RAND
. To get back to the original value I devided by ten (as I did on interface initialization)
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.
Ok, so, how about a comment here saying something like "to avoid floating point number computations, the boundaries for the random values are multiplied by 10"?
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.
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.
"in order to avoid division, we divide." :)
I did not say to avoid division, I said to avoid going to floating point computations ;-) I basically introduce a low-profile fixed-point number calculation here, if you want to call it that ;-P
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.
Just add a comment here and all is fine.
Addressed comments in previous commits. |
Please rebase |
14df47e
to
1a84e42
Compare
Rebased to current master |
1a84e42
to
f76d89d
Compare
int sicmpv6_size = (int)icmpv6_size, l2src_len = 0; | ||
uint16_t opt_offset = 0; | ||
assert(if_entry != NULL); | ||
if (!ipv6_addr_is_link_local(&ipv6->src) || |
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.
Styling question, but for readability I prefer a newline between variable initializations and actual start of the functionality.
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 agree. Don't know, why I did it that way.
/* set flags from message */ | ||
if_entry->flags &= ~GNRC_IPV6_NETIF_FLAGS_RTR_ADV_MASK; | ||
if_entry->flags |= ((rtr_adv->flags << GNRC_IPV6_NETIF_FLAGS_RTR_ADV_POS) & | ||
(GNRC_IPV6_NETIF_FLAGS_RTR_ADV_MASK)); |
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.
nitpicking, but I think you overdid with parens here. ;)
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.
Who are you and where is @OlegHahm?
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.
(())
ndp_opt_pi_t *pi_opt) | ||
{ | ||
ipv6_addr_t *prefix; | ||
gnrc_ipv6_netif_addr_t *a; |
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 would prefer addr
or something more speaking.
apart from the minor comments: code is okay, test didn't break anything. ACK after addressing and squashing if Travis agrees, too. |
3fcf32f
to
c367477
Compare
Addressed and squashed immediately. One minor thing I changed: I put the calculation and setting of reachable time related |
gnrc_ndp_host: Initial import of host behavior of router discovery
Thanks for the review! :-) |
This imports host behavior for NDP router discovery. This encompasses:
Depends on:
gnrc_ndp: add support for address-less link-layers #3628: address-less link-layer handling for NDPgnrc_ipv6_netif: prepare for router discovery #3745:(merged)gnrc_ipv6_netif
adaptations for router discovery