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_ipv6_nib: clean up _resolve_addr() #18939

Merged
merged 3 commits into from
Jan 10, 2023

Conversation

benpicco
Copy link
Contributor

@benpicco benpicco commented Nov 20, 2022

Contribution description

I'm still trying to find a proper fix for #16988 (border router does ARSM on the 6lo interface) but still no avail.

But as a first step, clean up _resolve_addr() by getting rid of unececary pre-processor conditionals and moving logic blocks to separate functions.

This makes it easier to figure out what's actually going on.

There should be no changes to the logic.

Testing procedure

All tests should continue yielding the same results as before.

Issues/PRs references

return false;
}

if (IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ARSM)) {
Copy link
Contributor Author

@benpicco benpicco Nov 20, 2022

Choose a reason for hiding this comment

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

I have a feeling that this should in fact be

Suggested change
if (IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ARSM)) {
if (IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ARSM) && !gnrc_netif_is_6lo(netif)) {

but I'll leave this PR to cleanups only.

Copy link
Member

Choose a reason for hiding this comment

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

No, it shoud still be possible to activate the ARSM optionally on 6Lo nodes.

Copy link
Member

Choose a reason for hiding this comment

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

(also resolution by address generation reversal is also a nice feature for non-6Lo-nodes to have (and will become necessary with SCHC at some point too).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it shoud still be possible to activate the ARSM optionally on 6Lo nodes.

But that would be a separate config then, right? Because right now we only have CONFIG_GNRC_IPV6_NIB_ARSM which globally turns on ARSM on all interfaces.

So the BR will do ARSM on the 6lo interface (because it needs it on the upstream interface) but the 6lo nodes do not.

Copy link
Contributor

@fabian18 fabian18 Nov 22, 2022

Choose a reason for hiding this comment

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

In my opinion, CONFIG_GNRC_IPV6_NIB_ARSM should even be enabled for all 6LN. Because our CONFIG_GNRC_IPV6_NIB_ARSM is actually responsible for two things:

  • address resolution obviously
    (Note: with private addresses, 6LN cannot reverse translate IPv6 addresses to L2 addresses, so they must look in the NC anyway. But this is a bit off-topic here currently.)
  • and Neighbor Unreachable Detection

6LN actually do NUD and additionally include an ARO option RFC6775.

Hosts send unicast NS messages to register their IPv6 addresses, and
also to do NUD to verify that their default routers are still
reachable.

For some things like joining the Solicited-node multicast address and multicast L2 address resolution, we just exclude 6LN interfaces.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Neighbor Unreachable Detection

hm might this be the reason for #17327

Copy link
Contributor

Choose a reason for hiding this comment

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

very hard to tell... To be honest I am not very familiar with RPL. I have to catch up here.

@benpicco benpicco force-pushed the gnrc_nib_resolve_addr-cleanup branch from d925acb to 71a01df Compare November 20, 2022 19:55
return false;
}

if (!IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ARSM)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

same here

Suggested change
if (!IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ARSM)) {
if (!IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_ARSM) || gnrc_netif_is_6lo(netif)) {

@benpicco benpicco added the Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation label Nov 20, 2022
@benpicco benpicco force-pushed the gnrc_nib_resolve_addr-cleanup branch from 71a01df to 14fc375 Compare November 20, 2022 20:00
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Nov 20, 2022
@riot-ci
Copy link

riot-ci commented Nov 20, 2022

Murdock results

✔️ PASSED

64a2fbc gnrc_ipv6_nib: clean up _resolve_addr()

Success Failures Total Runtime
6770 0 6770 14m:01s

Artifacts

Copy link
Contributor

@fabian18 fabian18 left a comment

Choose a reason for hiding this comment

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

Nice to see a clean up. I looked at it for a while and did not find a semantic change.

sys/net/gnrc/network_layer/ipv6/nib/nib.c Outdated Show resolved Hide resolved
res = true;

/* directly resolve 6lo address */
if (_resolve_addr_from_ipv6(dst, netif, nce)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency, this if clause could use a nice DEBUG() message too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if this should be moved above _resolve_addr_from_nc()

Copy link
Contributor

Choose a reason for hiding this comment

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

could be, maybe, but not necessarily.

static bool _resolve_addr_from_nc(gnrc_netif_t *netif, gnrc_ipv6_nib_nc_t *nce, const ipv6_addr_t * dst) {
    /* lookup _nib_onl_entry_t *entry by dst and netif */
    /* if exists get L2 address from NC */
    /* else if 6LN and link-local do reverse translation */
}

And if _resolve_addr_from_nc() fails to resolve the L2 address, we know we don´t have an NC entry and we have to add one, or it existed but was UNREACHABLE. Also having (netif + dst) and entry as input is a bit redundant.
... I don´t know, maybe the clean up could propagate upwards, but not without changing too much I guess.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure I understand what you want me to do 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I misread your last comment. I thought you wanted to merge _resolve_addr_from_nc() and _resolve_addr_from_ipv6() into one function. Then I thought about how this would look like.

Ok, moving _resolve_addr_from_ipv6() above _resolve_addr_from_nc() and keeping them as they are now,
would mean that every link-local destination address would be resolved immediately by reverse translation.
This would mean that link local addresses would not have to be registered. But this is somewhat required if the link local address is a private address (CGA or SLAAC pivacy extension) .

Let´s say R is the upstream router of host H. H implements the SLAAC privacy extension and builds a private link local address that it registers to R where due to an SLLA option an NCA is created there.
If R would not examine the NCE when it sends something to the private SLAAC address of H, it would put the wrong L2 address in the frame.

In fact, in my SEND branch, I added this:

    /* If any IPv6 privacy extension is used, we cannot derive the L2 address from the IP address */
    bool res = !IS_USED(MODULE_IPV6_CGA) &&
               (netif != NULL) &&
               gnrc_netif_is_6ln(netif) &&
               ipv6_addr_is_link_local(dst);

to _resolve_addr_from_ipv6().

@benpicco benpicco removed the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Nov 22, 2022
Copy link
Contributor

@fabian18 fabian18 left a comment

Choose a reason for hiding this comment

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

I once again looked through the changes and found no change in semantics.
Are we going to merge the clean up or is there something more to discuss regarding this PR?

@miri64
Copy link
Member

miri64 commented Jan 9, 2023

My comments were addressed.

@benpicco benpicco force-pushed the gnrc_nib_resolve_addr-cleanup branch from 9cff238 to 64a2fbc Compare January 9, 2023 13:04
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jan 9, 2023
Copy link
Member

@maribu maribu left a comment

Choose a reason for hiding this comment

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

bors merge

@bors
Copy link
Contributor

bors bot commented Jan 10, 2023

Build succeeded:

@bors bors bot merged commit 53176f7 into RIOT-OS:master Jan 10, 2023
@benpicco benpicco deleted the gnrc_nib_resolve_addr-cleanup branch January 10, 2023 15:25
@jia200x jia200x added this to the Release 2023.04 milestone Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: network Area: Networking Area: sys Area: System CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants