Skip to content

Commit

Permalink
Merge pull request #17350 from benpicco/gnrc_rpl/auto_init_on_prefix
Browse files Browse the repository at this point in the history
gnrc/ipv6_auto_subnets: init RPL root when adding a prefix
  • Loading branch information
benpicco authored May 2, 2022
2 parents 5db3ddd + a881af8 commit 1b92fb9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions sys/include/net/gnrc/netif/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,9 @@ static inline int gnrc_netif_ipv6_group_to_l2_group(gnrc_netif_t *netif,
* @param[in] pref Preferred lifetime of the prefix in seconds
*
* @return >= 0, on success
* The returned value is the index of the newly created address
* based on the prefix and the interfaces IID in the interface's
* address array.
* @return -ENOMEM, when no space for new addresses (or its solicited nodes
* multicast address) is left on the interface
*/
Expand Down
18 changes: 15 additions & 3 deletions sys/net/gnrc/routing/ipv6_auto_subnets/gnrc_ipv6_auto_subnets.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
#include "net/gnrc/udp.h"
#include "net/gnrc/ipv6/nib.h"
#include "net/gnrc/ndp.h"
#include "net/gnrc/rpl.h"
#include "random.h"
#include "xtimer.h"

Expand Down Expand Up @@ -286,6 +287,7 @@ static void _configure_subnets(uint8_t subnets, uint8_t start_idx, gnrc_netif_t
while ((downstream = gnrc_netif_iter(downstream))) {
gnrc_pktsnip_t *tmp;
ipv6_addr_t new_prefix;
int idx;

if (downstream == upstream) {
continue;
Expand All @@ -299,11 +301,18 @@ static void _configure_subnets(uint8_t subnets, uint8_t start_idx, gnrc_netif_t
new_prefix_len, downstream->pid);

/* first remove old prefix if the prefix changed */
_remove_old_prefix(downstream, &new_prefix, new_prefix_len, &ext_opts);
if (_remove_old_prefix(downstream, &new_prefix, new_prefix_len, &ext_opts)) {
/* if the prefix did not change, there is nothing to do here */
continue;
}

/* configure subnet on downstream interface */
gnrc_netif_ipv6_add_prefix(downstream, &new_prefix, new_prefix_len,
valid_ltime, pref_ltime);
idx = gnrc_netif_ipv6_add_prefix(downstream, &new_prefix, new_prefix_len,
valid_ltime, pref_ltime);
if (idx < 0) {
DEBUG("auto_subnets: adding prefix to %u failed\n", downstream->pid);
continue;
}

/* start advertising subnet */
gnrc_ipv6_nib_change_rtr_adv_iface(downstream, true);
Expand All @@ -316,6 +325,9 @@ static void _configure_subnets(uint8_t subnets, uint8_t start_idx, gnrc_netif_t
} else {
ext_opts = tmp;
}

/* configure RPL root if applicable */
gnrc_rpl_configure_root(downstream, &downstream->ipv6.addrs[idx]);
}

/* immediately send an RA with RIO */
Expand Down

0 comments on commit 1b92fb9

Please sign in to comment.