gnrc_ipv6_nib: provide internal implementation for off-link entries#7212
Conversation
sys/include/net/gnrc/ipv6/nib/conf.h
Outdated
| /** | ||
| * @brief Number of off-link entries in NIB | ||
| * | ||
| * @note **This number has direct influence on the maximum number of |
There was a problem hiding this comment.
instead of enclosing this with ** ... ** you could rather use @attention instead of @note
There was a problem hiding this comment.
Tried to keep the style of the original ones.
There was a problem hiding this comment.
I understand - and docu styling might be separate more general issue anyway 😉
There was a problem hiding this comment.
Will fix in a different PR ;-)
sys/include/net/gnrc/ipv6/nib/conf.h
Outdated
| /** | ||
| * @brief Number of off-link entries in NIB | ||
| * | ||
| * @attention This number has direct influence on the maximum number of |
There was a problem hiding this comment.
just to clarify: how exactly does GNRC_IPV6_NIB_OFFL_NUMOF influences the max. number? I would assume it is the max. number, or is there another number that is added to that?
|
|
||
| if ((_nib_onl_get_if(tmp) == iface) && | ||
| (ipv6_addr_equal(addr, &tmp->ipv6))) { | ||
| ((addr == NULL) || (ipv6_addr_equal(addr, &tmp->ipv6)))) { |
There was a problem hiding this comment.
why do you need this check for addr == NULL here? There's a @pre in the doxygen of this function, that addr != NULL.
There was a problem hiding this comment.
you probably need to remove the doxygen @pre then.
There was a problem hiding this comment.
The @pre is wrong. For prefix list entries the next-hop address may be NULL.
There was a problem hiding this comment.
Found an error here, while debugging NDP-RD. Will fix.
|
|
||
| assert(addr != NULL); | ||
| DEBUG("nib: Allocating on-link node entry (addr = %s, iface = %u)\n", | ||
| ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)), iface); |
There was a problem hiding this comment.
this line will crash if addr == NULL
| } | ||
|
|
||
| _nib_offl_entry_t *_nib_offl_alloc(const ipv6_addr_t *next_hop, unsigned iface, | ||
| const ipv6_addr_t *pfx, unsigned pfx_len) |
| _nib_offl_entry_t *dst = NULL; | ||
|
|
||
| assert((pfx != NULL) && (!ipv6_addr_is_unspecified(pfx)) && | ||
| (pfx_len != 0) && (pfx_len <= 128)); |
There was a problem hiding this comment.
just taste, but I like pfx_len > 0 more, because it's in harmony with px_len <= 128
There was a problem hiding this comment.
Dito, don't know what came over me.
| _nib_offl_entry_t *_nib_dst_alloc(const ipv6_addr_t *next_hop, unsigned iface, | ||
| const ipv6_addr_t *pfx, unsigned pfx_len); | ||
| _nib_offl_entry_t *_nib_offl_alloc(const ipv6_addr_t *next_hop, unsigned iface, | ||
| const ipv6_addr_t *pfx, unsigned pfx_len); |
| const ipv6_addr_t *dst) | ||
| { | ||
| return _nib_dst_add(next_hop, iface, dst, IPV6_ADDR_BIT_LEN, _DC); | ||
| assert(next_hop != NULL); |
There was a problem hiding this comment.
please also add assert(dst != NULL);
There was a problem hiding this comment.
But it's checked in _nib_offl_alloc() (which is called by _nib_offl_add())...
There was a problem hiding this comment.
That may be true for now, but what if this code changes with time and possibly by another developer?. IMO these asserts also have a documentational character.
| * interfaces and then tries to add another. | ||
| * Expected result: should return NULL | ||
| */ | ||
| static void test_nib_offl_alloc__no_space_left_diff_next_hop_iface(void) |
There was a problem hiding this comment.
I dont' think you need the above two test cases when you introduce this test case that combines both
There was a problem hiding this comment.
I disagree, checking for behavior different addresses, different interfaces and different addresses and different interfaces are disjunct test-cases. One simple mix-up of && and || in the implementation would let fail at least one of them.
| * tries to add another. | ||
| * Expected result: should return NULL | ||
| */ | ||
| static void test_nib_offl_alloc__no_space_left_diff_next_hop_iface_pfx(void) |
There was a problem hiding this comment.
here the same, the above two test cases are not really necessary, are they?
| * equal to the last. | ||
| * Expected result: should return not NULL (the last) | ||
| */ | ||
| static void test_nib_offl_alloc__success_duplicate(void) |
There was a problem hiding this comment.
So many test cases that are very similar .. can you collapse them? It is hard to maintain so many test cases in case of changes.
There was a problem hiding this comment.
There are subtle differences that are not easily parameterized out. Ideally, this API shouldn't change much.
|
Comments addressed. |
Done: the problem was, if a Prefix List entry was allocated first and a neighbor cache entry to the same interface later, the allocation would create a new entry. The last two commits add a fix and a corresponding test for this. |
|
Oops, now the address isn't set ^^ will fix |
|
(fixed and |
|
Ping @cgundogan? You promised to review last week :( |
cgundogan
left a comment
There was a problem hiding this comment.
looks better now .. the goal draws nearer (:
| (_nib_onl_get_if(tmp_node) == iface) && | ||
| ((next_hop == NULL) || ipv6_addr_is_unspecified(&tmp_node->ipv6) || | ||
| (ipv6_addr_equal(next_hop, &tmp_node->ipv6))) && | ||
| (ipv6_addr_match_prefix(&tmp->pfx, pfx) >= pfx_len)) { |
There was a problem hiding this comment.
That's a pretty ugly chain of conditions. Care to outsource into an inlined function or provide code documentation on what happens here?
| * | ||
| * @pre `(addr != NULL)`. | ||
| * | ||
| * @param[in] addr An IPv6 address. May not be NULL. |
| const ipv6_addr_t *dst) | ||
| { | ||
| return _nib_dst_add(next_hop, iface, dst, IPV6_ADDR_BIT_LEN, _DC); | ||
| assert(next_hop != NULL); |
There was a problem hiding this comment.
That may be true for now, but what if this code changes with time and possibly by another developer?. IMO these asserts also have a documentational character.
|
Addressed comments |
|
@miri64 great, thanks for your patience! Please squash the commits and then let's murdock have some fun! |
34ab23a to
124d6c8
Compare
|
Squashed |
|
Murdock spits out some errors here. |
124d6c8 to
c1f9b15
Compare
Problem was the amended inline function requested in #7212 (comment). Fixed and squashed immediately. |
|
Now murdock is happy (: GO |
Implementation off the off-link component of the NIB back-end.
I needed to move some stuff around, to keep consistency, but other than that the change should be straight forward.
This PR is part of the network layer remodelling effort:
