gnrc/nib: gnrc_ipv6_nib_get_next_hop_l2addr(): only assume neighbor cache entries to always be on-link#16671
Conversation
437c37c to
e33f429
Compare
miri64
left a comment
There was a problem hiding this comment.
TBH it looks to me like you want to remove the neighbor cache altogether with this PR and I don't really understand how this makes sense. Even with your explanation.
| ipv6_addr_to_str(addr_str, dst, sizeof(addr_str))); | ||
| DEBUG("nib: %s is %s, start address resolution\n", | ||
| ipv6_addr_to_str(addr_str, dst, sizeof(addr_str)), | ||
| node ? "in NC" : "on-link"); |
There was a problem hiding this comment.
If an entry is in the NC it is by definition on-link. Not sure why the distinction is made in this debug message...
There was a problem hiding this comment.
I just found it useful for debugging to know whether _on_link() returned true or if node was not NULL.
|
Ok, so I think the 'original patch' would be --- a/sys/net/gnrc/network_layer/ipv6/nib/nib.c
+++ b/sys/net/gnrc/network_layer/ipv6/nib/nib.c
@@ -220,7 +220,7 @@ int gnrc_ipv6_nib_get_next_hop_l2addr(const ipv6_addr_t *dst,
/* consider neighbor cache entries first */
unsigned iface = (node == NULL) ? 0 : _nib_onl_get_if(node);
- if ((node != NULL) || _on_link(dst, &iface)) {
+ if (((node != NULL) && (nce->mode & _NC)) || _on_link(dst, &iface)) {
DEBUG("nib: %s is on-link or in NC, start address resolution\n",
ipv6_addr_to_str(addr_str, dst, sizeof(addr_str)));
/* on-link prefixes return their interface */Then I was wondering if it even makes sense for If I'm wrong I can also add a |
Yes, have a look at the original model. Regarding that particular line, it might be the case, that we only want the neighbor cache entry here, indeed, but not non-NC entries... |
419007d to
53efcd4
Compare
Consider the following: A node tries to forward a packet to another host for which it does not know the route yet. It assumes it to be on-link and starts a neighbor solicitation, putting the node address in the destinatio cache. Later the route is known (via a second hop) but the host is still in the NIB. The result is that gnrc_ipv6_nib_get_next_hop_l2addr() ends up in the "nib: %s is in NC or on-link, start address resolution" case and does not attempt to resolve the route. This results in the host remaining unreachable even though now a route is present.
53efcd4 to
5ad58b1
Compare
|
Ok I kept If too controversial, I can drop the last two commits 😉 |
|
It looks alright, but I am still wondering what type of on-link entry you get that this happens. Did you check (you could just output the flags in a debug line)?
Also why wasn't RIOT/sys/net/gnrc/network_layer/ipv6/nib/_nib-6lr.c Lines 89 to 94 in 5ad58b1 updated? |
|
I guess the PR title should also be updated now ;-). |
I suspect it's
It's not checking for |
|
It's |
|
Ah right! That mode is used when an
Just from the title I know wonder: so no FIB lookup happens now in |
|
On the other hand: why is there a global address as next hop in the first place? Typically, (while not necessarily) they are link-local. |
#16665 👀 |
I don't see the relation between source address selection and next-hops of routes... |
|
If the node takes the source address of the packet it got from the next hop as it's next-hop-node, then it will do just that. |
Not really sure how to parse this sentence? Why would a packet come from the next hop? My understanding of routing is that packets go to a next hop. And why does this decide the source address of a packet sent by the host at hand? Forwarding a packet should not change the addresses of a packet. |
|
This is with #16568. If the Router Advertisement contains a RIO, the node that receives it will use the source address of the RA as the next hop to reach the the network advertised in the RIO. This however is wholly unrelated to this PR. |
Then those next hops should not be global, as RA source addresses MUST be link-local. If that's not the case, this is the bug that needs fixing. |
|
That a router advertisement has a link-local address as source should be assured by RIOT/sys/net/gnrc/network_layer/ndp/gnrc_ndp.c Lines 493 to 502 in feac187 src was initialized on call of course, which isn't the case in current master:
$ git grep "rtr_adv_send" | grep -v "^tests"
sys/include/net/gnrc/ndp.h:void gnrc_ndp_rtr_adv_send(gnrc_netif_t *netif, const ipv6_addr_t *src,
sys/net/gnrc/network_layer/ipv6/nib/_nib-router.c: gnrc_ndp_rtr_adv_send(netif, NULL, dst, final, ext_opts);
sys/net/gnrc/network_layer/ndp/gnrc_ndp.c:void gnrc_ndp_rtr_adv_send(gnrc_netif_t *netif, const ipv6_addr_t *src, |
|
RAs with non-link-local addresses should also be rejected via this check RIOT/sys/net/gnrc/network_layer/ipv6/nib/nib.c Lines 597 to 614 in feac187 |
|
tbh I'm not sure anymore with which state of my PRs I got to this case, however this PR should be useful regardless as it only does two things:
|
Not sure this is the right way to go. Only because an entry is not in the neighbor cache (yet), does not mean it is not on-link. A routing protocol (or for that matter a user using the
That I don't argue with :-). |
|
Another reason could be, that the node simply just cached out from the neighbor cache (but still is kept in the |
|
But in that case we would still do the |
This somehow contradicts the title of this PR, but maybe only that needs adaption. Apart from that, I think the claim is valid. If there is no NC, there is no link-layer address. |
|
Does this make for a better PR title? 😉 |
|
@miri64 ping 😉 |
Contribution description
Consider the following: A node tries to forward a packet to another host for which it does not know the route yet. It assumes it to be on-link and starts a neighbor solicitation, putting the node address in the destination cache.
Later the route is known (via a second hop) but the host is still in the NIB.
The result is that
gnrc_ipv6_nib_get_next_hop_l2addr()ends up in the"nib: %s is in NC or on-link, start address resolution"case and does not attempt to resolve the route.This results in the host remaining unreachable even though now a route is present.
The fix should make sense since only neighbor cache entries are guaranteed to be on-link.
Testing procedure
Issues/PRs references