Skip to content

Commit

Permalink
gnrc_ipv6_nib: auto-configure link-local address on UP event
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Oct 11, 2022
1 parent f34f296 commit ab32ad5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ void _auto_configure_addr(gnrc_netif_t *netif, const ipv6_addr_t *pfx,
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN)
bool new_address = false;
#endif /* CONFIG_GNRC_IPV6_NIB_6LN */
gnrc_netif_ipv6_get_iid(netif, (eui64_t *)&addr.u64[1]);
if (gnrc_netif_ipv6_get_iid(netif, (eui64_t *)&addr.u64[1]) < 0) {
DEBUG("nib: Can't get IID on interface %u\n", netif->pid);
return;
}
ipv6_addr_init_prefix(&addr, pfx, pfx_len);
if ((idx = gnrc_netif_ipv6_addr_idx(netif, &addr)) < 0) {
if ((idx = gnrc_netif_ipv6_addr_add_internal(netif, &addr, pfx_len,
Expand Down
8 changes: 7 additions & 1 deletion sys/net/gnrc/network_layer/ipv6/nib/nib.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ void gnrc_ipv6_nib_iface_up(gnrc_netif_t *netif)
netif->ipv6.rs_sent = 0;
#endif /* CONFIG_GNRC_IPV6_NIB_6LN */
netif->ipv6.na_sent = 0;
_auto_configure_addr(netif, &ipv6_addr_link_local_prefix, 64U);
if (!(gnrc_netif_is_rtr_adv(netif)) ||
(gnrc_netif_is_6ln(netif) && !gnrc_netif_is_6lbr(netif))) {
uint32_t next_rs_time = random_uint32_range(0, NDP_MAX_RS_MS_DELAY);
Expand Down Expand Up @@ -175,6 +176,12 @@ void gnrc_ipv6_nib_iface_down(gnrc_netif_t *netif, bool send_final_ra)
#else
(void)send_final_ra;
#endif
for (unsigned i = 0; i < CONFIG_GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
if (ipv6_addr_is_link_local(&netif->ipv6.addrs[i])) {
/* link-local address might change on reconnect */
gnrc_netif_ipv6_addr_remove_internal(netif, &netif->ipv6.addrs[i]);
}
}

gnrc_netif_release(netif);
}
Expand All @@ -201,7 +208,6 @@ void gnrc_ipv6_nib_init_iface(gnrc_netif_t *netif)
return;
}
_add_static_lladdr(netif);
_auto_configure_addr(netif, &ipv6_addr_link_local_prefix, 64U);

gnrc_netif_release(netif);
}
Expand Down

0 comments on commit ab32ad5

Please sign in to comment.