gnrc_ipv6_nib: initial import of internal NIB functions#6325
gnrc_ipv6_nib: initial import of internal NIB functions#6325cgundogan merged 2 commits intoRIOT-OS:masterfrom
Conversation
sys/include/net/gnrc/ipv6/nib/conf.h
Outdated
| #define GNRC_IPV6_NIB_QUEUE_PACKETS (1) | ||
| #endif | ||
|
|
||
| #ifndef GNRC_IPV6_NIB_DO_HANDLE_NBR_SOL |
There was a problem hiding this comment.
What's the idea of incuding this long list of compile time flags? It should suffice to check their availability with if[n]def where they are needed. Maybe I misunderstand and they are used not as compile time switches, sorry if so, but there is no code using them currently (:
There was a problem hiding this comment.
They are used as compile switches, but I did not want them to be #ifndef enabled flags, but #if enabled flags, so you can deactivate them beyond the default config easily, too. This is actually more important than activating them, since e.g. 6Lo-ND doesn't need to handle TLLAOs or redirect messages.
|
Added the default router selection algorithm from RFC 4861. |
f47e419 to
381f5c3
Compare
|
Rebased to current master |
381f5c3 to
9c3a642
Compare
|
Rebased to current master and adapted to the new model |
|
Ready for review. |
|
Just found another issue with this PR, when working with the NC component. Will fix asap. |
|
Issue resolved. |
2cdfc2b to
bc182a5
Compare
|
|
||
| _nib_onl_entry_t *_nib_onl_iter(const _nib_onl_entry_t *last) | ||
| { | ||
| for (const _nib_onl_entry_t *node = (last) ? last + 1 : _nodes; |
There was a problem hiding this comment.
I don't understand the motivation for const here, since the array that is iterated over is also not an array of const elements. IMO there's no need for that and makes the below lines less verbose.
There was a problem hiding this comment.
Const correctness is important for preventing coding mistakes and may help the compiler how to optimize.
There was a problem hiding this comment.
IMO there's no need for that and makes the below lines less verbose.
How that?
| assert(cstate != GNRC_IPV6_NIB_NC_INFO_NUD_STATE_PROBE); | ||
| assert(cstate != GNRC_IPV6_NIB_NC_INFO_NUD_STATE_REACHABLE); | ||
| _nib_onl_entry_t *node = _nib_onl_alloc(addr, iface); | ||
| if (node != NULL) { |
There was a problem hiding this comment.
I would prefer
if (node == NULL) {
return _cache_out_onl_entry(addr, iface, cstate);;
}to remove the indentation below. Leads to a much better readability of the code.
The members of the default router entry struct would still have to be required be added to the off-link-router entry struct, so we then would also waste memory there (since most of them would only be required for default routers). Since the default router list maintenance functions are one of the least complex I also think that the ROM salvage we get from this isn't as big as the RAM salvage we get (percent-wise). As soon as the whole NIB is in place however we can experiment with that. That's the nice thing about levels of abstraction :-). |
Just consider, that for a typical 6LN (where we need to save the most memory) we can assume, that it only has one off-link-entry (a prefix in its prefix list) and one default router, so by joining those to data structure we would double the required RAM, because they have completely orthogonally required fields (disregarding prefix, which we are currently saving by implicitly having it |
| { | ||
| /* if there isn't already a default router selected or | ||
| * its reachability is suspect */ | ||
| if ((_prime_def_router == NULL) || |
There was a problem hiding this comment.
Can you also change this to an early exit? This function has 3 levels of indentation ..
| TEST_ASSERT_NULL(_nib_drl_iter(NULL)); | ||
| } | ||
|
|
||
|
|
| TEST_ASSERT(nib_res == node); | ||
| TEST_ASSERT_NOT_NULL((nib_res = _nib_drl_get_dr())); | ||
| TEST_ASSERT(nib_res == node); | ||
| TEST_ASSERT_NOT_NULL((nib_res = _nib_drl_get_dr())); |
There was a problem hiding this comment.
testing nib_res == node 2 times is enough ..
| } | ||
|
|
||
| /* | ||
| * Tries to get the default router from a list of two routers |
There was a problem hiding this comment.
tests with two routers are obsolete when you are testing the permutation of three routers below ..
|
Addressed latest batch of comments on tests |
|
ACK from @BytesGalore and me ! please squash. |
65033f0 to
22ec0c1
Compare
|
Squashed and rebased |
|
please address murdock's findings. |
|
Already on it :-) |
|
Fixed (but not squashed in case you want to review those changes, because they are quite largish) |
|
The doc fixes look good. Please squash and then let's see what murdock has to say. It's getting real now (: |
c4a5fd5 to
0bf52f0
Compare
|
Squashed |
|
Murdock likes it :-) |
Reasoning for this PR
To put it mildly: the new NDP implementation will be a cluster fuck of interdependent PRs anyways, so I started with an import of the internal structure needed for a working Address Resolution/Registration (AR) and Neighbor Unreachable Discovery (NUD). Including tests, doc and headers this is already ~2000 loc, but thankfully the implementation itself is only 250 loc long ;-).
Structure
The internal structure of the NIB is made to waste the least amount of RAM considering its complex structure:
Off-link entries are currently omitted from this PR, as they are not required for AR and NUD.
Edit: model was updated and is still WIP https://miri64.github.io/riot-ndp-model/