1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2026-01-01 01:41:18 +01:00

Merge pull request #8089 from miri64/gnrc_netif/fix/add-sol-nodes

gnrc_netif: join/leave solicited nodes IPv6 address add/remove
This commit is contained in:
Koen Zandberg 2017-11-20 14:35:49 +01:00 committed by GitHub
commit e5cf4a5396
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 15 deletions

View File

@ -554,6 +554,24 @@ int gnrc_netif_ipv6_addr_add(gnrc_netif_t *netif, const ipv6_addr_t *addr,
netif->ipv6.addrs_flags[idx] = flags;
memcpy(&netif->ipv6.addrs[idx], addr, sizeof(netif->ipv6.addrs[idx]));
#ifdef MODULE_GNRC_IPV6_NIB
#if GNRC_IPV6_NIB_CONF_ARSM
ipv6_addr_t sol_nodes;
int res;
/* TODO: SHOULD delay join between 0 and MAX_RTR_SOLICITATION_DELAY
* for SLAAC */
ipv6_addr_set_solicited_nodes(&sol_nodes, addr);
res = gnrc_netif_ipv6_group_join(netif, &sol_nodes);
#if ENABLE_DEBUG
if (res < 0) {
DEBUG("nib: Can't join solicited-nodes of %s on interface %u\n",
ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
netif->pid);
}
#else
(void)res;
#endif
#endif /* GNRC_IPV6_NIB_CONF_ARSM */
if (_get_state(netif, idx) == GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_VALID) {
void *state = NULL;
gnrc_ipv6_nib_pl_t ple;
@ -584,14 +602,30 @@ int gnrc_netif_ipv6_addr_add(gnrc_netif_t *netif, const ipv6_addr_t *addr,
void gnrc_netif_ipv6_addr_remove(gnrc_netif_t *netif,
const ipv6_addr_t *addr)
{
int idx;
bool remove_sol_nodes = true;
ipv6_addr_t sol_nodes;
assert((netif != NULL) && (addr != NULL));
ipv6_addr_set_solicited_nodes(&sol_nodes, addr);
gnrc_netif_acquire(netif);
idx = _addr_idx(netif, addr);
if (idx >= 0) {
netif->ipv6.addrs_flags[idx] = 0;
ipv6_addr_set_unspecified(&netif->ipv6.addrs[idx]);
for (unsigned i = 0; i < GNRC_NETIF_IPV6_ADDRS_NUMOF; i++) {
if (ipv6_addr_equal(&netif->ipv6.addrs[i], addr)) {
netif->ipv6.addrs_flags[i] = 0;
ipv6_addr_set_unspecified(&netif->ipv6.addrs[i]);
}
else {
ipv6_addr_t tmp;
ipv6_addr_set_solicited_nodes(&tmp, &netif->ipv6.addrs[i]);
/* there is still an address on the interface with the same
* solicited nodes address */
if (ipv6_addr_equal(&tmp, &sol_nodes)) {
remove_sol_nodes = false;
}
}
}
if (remove_sol_nodes) {
gnrc_netif_ipv6_group_leave(netif, &sol_nodes);
}
gnrc_netif_release(netif);
}

View File

@ -1334,16 +1334,6 @@ static void _auto_configure_addr(gnrc_netif_t *netif, const ipv6_addr_t *pfx,
(void)idx;
/* TODO: make this line conditional on 6LN when there is a SLAAC
* implementation */
#if GNRC_IPV6_NIB_CONF_ARSM
/* TODO: SHOULD delay join between 0 and MAX_RTR_SOLICITATION_DELAY
* for SLAAC */
ipv6_addr_set_solicited_nodes(&addr, &addr);
if (gnrc_netif_ipv6_group_join(netif, &addr) < 0) {
DEBUG("nib: Can't join solicited-nodes of link-local address on "
"interface %u\n", netif->pid);
return;
}
#endif /* GNRC_IPV6_NIB_CONF_ARSM */
#if GNRC_IPV6_NIB_CONF_6LN
if (new_address && gnrc_netif_is_6ln(netif) &&
!gnrc_netif_is_6lbr(netif)) {