-
Notifications
You must be signed in to change notification settings - Fork 2.1k
gnrc_ipv6_nib: add forwarding table component #7253
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_ipv6_nib: add forwarding table component #7253
Conversation
775cad7
to
3fc6298
Compare
89a9dff
to
fa71fc8
Compare
99a6afe
to
5f89b17
Compare
Rebased to current master and current dependencies |
5f89b17
to
9b933fb
Compare
9b933fb
to
9a6b1ff
Compare
Rebased to current master |
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.
more comments to look at.
sys/include/net/gnrc/ipv6/nib/ft.h
Outdated
* | ||
* @param[in] dst The destination. | ||
* @param[in] ctx Packet that is supposed to go to that destination | ||
* (is handed over to a reactive routing protocol if one exist |
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.
exists
.
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.
Why isn't this named pkt
, but ctx
, if the documentation says packet
?
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 this be const
probably?
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.
Why isn't this named pkt, but
ctx
, if the documentation says packet?
Because it is the context of the forwarding step, but I don't care. I can call it pkt if you want.
Can this be const probably?
Maybe, but I'm not sure if this is guaranteed for every reactive routing protocol (even RPL adds stuff like routing headers to a packet and that's not even reactive).
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.
Because it is the context of the forwarding step, but I don't care. I can call it pkt if you want.
Yes, please.
bool _nib_offl_is_entry(const _nib_offl_entry_t *entry) | ||
{ | ||
return (entry >= _dsts) && | ||
(entry < (_dsts + GNRC_IPV6_NIB_OFFL_NUMOF)); |
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_dsts()
DEBUG("nib: get match for destination %s from NIB\n", | ||
ipv6_addr_to_str(addr_str, dst, sizeof(addr_str))); | ||
for (_nib_offl_entry_t *entry = _dsts; | ||
entry < (_dsts + GNRC_IPV6_NIB_OFFL_NUMOF); |
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_dsts()
int res = 0; | ||
|
||
assert((dst != NULL) && (fte != NULL)); | ||
do { /* goto, but cleaner ;-) */ |
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 don't think abusing a do { } while()
construct is cleaner than goto. In this case you can return res
anyway instead of using break
. There's nothing important after the loop.
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.
True to the last statement! and regarding "abusing" do { } while(0)
: it still provides a clear (stack-)frame structure, visible in the code. goto
does not and can easily get out of hand because of that.
sys/include/net/gnrc/ipv6/nib/ft.h
Outdated
* } | ||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
* | ||
* @note The list may change during iteration, but no duplication of already |
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.
Are you sure the latter part of this sentence is true? What happens if an entry gets removed and then added (after 3 other additions). Then the same value would end up later in the list, right?
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.
Yes, that may happen. But then it is also wrong for nib_pl_iter()
and nib_nc_iter()
. Shall I remove it?
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.
Shall I remove it?
Yup. No need to advertise features we cannot guarantee (:
2a08ed2
to
02aa064
Compare
Rebased to current master |
Addressed comments. |
@@ -483,6 +495,91 @@ _nib_offl_entry_t *_nib_offl_iter(const _nib_offl_entry_t *last) | |||
return NULL; | |||
} | |||
|
|||
bool _nib_offl_is_entry(const _nib_offl_entry_t *entry) | |||
{ | |||
return (entry >= _dsts) && _in_dsts(entry); |
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.
isn't _in_dsts()
also suppoed to check for >= _dsts
?
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.
you could probably remove _nib_offl_is_entry
and use _in_dsts()
everywhere
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.
Nope. Since it is used as a loop-target this check wouldn't make sense / would be more expensive
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 I can do the replacement for the cases where entry >= _dsts
must also be true ;-).
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 is no such case in _nib-internal.c
so all done ;-))
else { | ||
_nib_ft_get(offl, fte); | ||
} | ||
return 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.
else {
_nib_ft_get(offl, fte);
}
}
else {
_nib_ft_get(offl, fte);
}
Any chance to remove code duplication and / or level of nestedness?
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'll try something
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.
Done
9cc359a
to
2cdae91
Compare
Rebased and addressed comments |
much better, please squash! |
2cdae91
to
c60cacc
Compare
Squashed |
cross another one off the list! (: |
Implements the forwarding table component of the NIB.
Depends on #7212.This PR is part of the network layer remodelling effort:
