Skip to content
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

Merged
merged 2 commits into from
Sep 2, 2015

Conversation

miri64
Copy link
Member

@miri64 miri64 commented Aug 31, 2015

This imports host behavior for NDP router discovery. This encompasses:

  • building and sending of (semi-periodic) router solicitations (including all available options specified in RFC 4861)
  • handling of router advertisements and their options

Depends on:

@miri64 miri64 added Type: new feature The issue requests / The PR implemements a new feature for RIOT Process: API change Integration Process: PR contains or issue proposes an API change. Should be handled with care. State: waiting for other PR State: The PR requires another PR to be merged first NSTF labels Aug 31, 2015
@miri64 miri64 added this to the Release 2015.08 milestone Aug 31, 2015
@miri64 miri64 force-pushed the gnrc_ndp_host/feat/initial branch from 128fbe4 to 67c7ca4 Compare August 31, 2015 13:34
@miri64 miri64 force-pushed the gnrc_ndp_host/feat/initial branch from 67c7ca4 to e9d77f9 Compare August 31, 2015 20:05
@miri64
Copy link
Member Author

miri64 commented Aug 31, 2015

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))
Copy link
Member

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?

Copy link
Member Author

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' ;-)

Copy link
Member Author

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)

@miri64 miri64 force-pushed the gnrc_ndp_host/feat/initial branch from e9d77f9 to d89da6d Compare August 31, 2015 22:49
@miri64
Copy link
Member Author

miri64 commented Aug 31, 2015

Rebased to current #3628 to incorporate miri64#17.

@miri64 miri64 force-pushed the gnrc_ndp_host/feat/initial branch 2 times, most recently from d1c8aa2 to 8878f4d Compare September 1, 2015 17:52
@miri64
Copy link
Member Author

miri64 commented Sep 1, 2015

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;
Copy link
Member Author

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

Copy link
Member

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`.

Copy link
Member Author

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)

Copy link
Member

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"?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

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

Copy link
Member

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.

@miri64
Copy link
Member Author

miri64 commented Sep 2, 2015

Addressed comments in previous commits.

@OlegHahm
Copy link
Member

OlegHahm commented Sep 2, 2015

Please rebase

@OlegHahm OlegHahm removed the State: waiting for other PR State: The PR requires another PR to be merged first label Sep 2, 2015
@miri64 miri64 force-pushed the gnrc_ndp_host/feat/initial branch from 14df47e to 1a84e42 Compare September 2, 2015 12:11
@miri64
Copy link
Member Author

miri64 commented Sep 2, 2015

Rebased to current master

@miri64 miri64 force-pushed the gnrc_ndp_host/feat/initial branch from 1a84e42 to f76d89d Compare September 2, 2015 12:16
@OlegHahm OlegHahm added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Sep 2, 2015
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) ||
Copy link
Member

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.

Copy link
Member Author

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.

@OlegHahm OlegHahm added the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Sep 2, 2015
/* 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));
Copy link
Member

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. ;)

Copy link
Member Author

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?

Copy link
Member

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;
Copy link
Member

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.

@OlegHahm
Copy link
Member

OlegHahm commented Sep 2, 2015

apart from the minor comments: code is okay, test didn't break anything. ACK after addressing and squashing if Travis agrees, too.

@miri64 miri64 force-pushed the gnrc_ndp_host/feat/initial branch from 3fcf32f to c367477 Compare September 2, 2015 15:31
@miri64
Copy link
Member Author

miri64 commented Sep 2, 2015

Addressed and squashed immediately. One minor thing I changed: I put the calculation and setting of reachable time related gnrc_ipv6_netif_t members into their own inline function and used that function on interface initialization as well.

@miri64 miri64 removed the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Sep 2, 2015
OlegHahm added a commit that referenced this pull request Sep 2, 2015
gnrc_ndp_host: Initial import of host behavior of router discovery
@OlegHahm OlegHahm merged commit b625d72 into RIOT-OS:master Sep 2, 2015
@miri64 miri64 deleted the gnrc_ndp_host/feat/initial branch September 2, 2015 16:54
@miri64
Copy link
Member Author

miri64 commented Sep 2, 2015

Thanks for the review! :-)

@miri64 miri64 added the Area: network Area: Networking label Sep 30, 2018
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. Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants