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: automatically create 6ctx for downstream networks #21086

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

benpicco
Copy link
Contributor

Contribution description

When gnrc_ipv6_auto_subnets announces the creation of a downstream subnet to the upstream router, if that router is a 6lbr, it might as well create a compression context for that network.

To also inform the downstream router about this compression context, send another RA to the downstream router, containing only the 6ctx information (to avoid creating a packet ping-pong loop if it also contained a prefix information option).

Testing procedure

An instance of examples/gnrc_border_router and one of examples/gnrc_networking with both ZEP and TAP enabled (I used two instances of the border router with #21081 to only enable the ABR functionality of one at run-time).

start 6LBR on-demand
static gnrc_netif_t *_get_6lo_interface(void)
{
    gnrc_netif_t *netif = NULL;
    while ((netif = gnrc_netif_iter(netif))) {
        if (gnrc_netif_is_6ln(netif)) {
            return netif;
        }
    }

    return NULL;
}

static int cmd_start_network(int argc, char **argv)
{
    (void)argc;
    (void)argv;

    gnrc_netif_t *downstream = _get_6lo_interface();
    if (!downstream) {
        puts("can't find 6lo interface");
        return;
    }

    ipv6_addr_t prefix;
    int len = ipv6_prefix_from_str(&prefix, "fd12::/16");
    if (len <= 0) {
        puts("Can't parse prefix string");
        return;
    }

    /* configure subnet on downstream interface */
    int idx = gnrc_netif_ipv6_add_prefix(downstream, &prefix, len,
                                         UINT32_MAX, UINT32_MAX);
    if (idx < 0) {
        DEBUG("adding prefix to %u failed\n", downstream->pid);
        return;
    }

    netopt_enable_t enable = NETOPT_ENABLE;
    gnrc_netapi_set(downstream->pid, NETOPT_6LO_ABR, 0, &enable, sizeof(enable));
    gnrc_netapi_set(downstream->pid, NETOPT_IPV6_SND_RTR_ADV, 0, &enable, sizeof(enable));

    return 0;
}
SHELL_COMMAND(leader, "Make the node a leader", cmd_start_network);

Downstream node receives the fd12::/16 prefix and creates a fd12:1284:c87:1fb7::/64 prefix from it, sends this to the upstream router. Upstream router creates a compression context and response with yet another RA that contains the updated list of compression contexts.

6ctx on both nodes shows the same information:

cid|prefix                                     |C|ltime
-----------------------------------------------------------
  0|                                 fd12::/16 |1| 6046min
  1|                   fd12:1284:c87:1fb7::/64 |1| 6046min

Issues/PRs references

@github-actions github-actions bot added Area: network Area: Networking Area: sys Area: System labels Dec 13, 2024
@@ -1787,6 +1787,28 @@ static const char *_prio_string(uint8_t prio)
return "invalid";
}

static gnrc_pktsnip_t *_build_ctxs(_nib_abr_entry_t *abr)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't there already be a function like this somewhere in the code base?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only a function that adds all options

Copy link
Member

Choose a reason for hiding this comment

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

To avoid code duplication, does it make sense to call the function at hand there as well?

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants