1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

nib/_nib-6ln: bail out early if address is no longer assigned

This commit is contained in:
Benjamin Valentin 2023-10-19 19:45:34 +02:00
parent 14b608cb23
commit 7c6b367035

View File

@ -185,12 +185,19 @@ void _handle_rereg_address(const ipv6_addr_t *addr)
{
gnrc_netif_t *netif = gnrc_netif_get_by_ipv6_addr(addr);
if (netif == NULL) {
DEBUG("nib: Couldn't re-register %s, address wasn't assigned to any "
"interface anymore.\n",
ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)));
return;
}
gnrc_netif_acquire(netif);
_nib_dr_entry_t *router = _nib_drl_get(NULL, netif->pid);
const bool router_reachable = (router != NULL) &&
_is_reachable(router->next_hop);
if (router_reachable && (netif != NULL)) {
if (router_reachable) {
assert((unsigned)netif->pid == _nib_onl_get_if(router->next_hop));
DEBUG("nib: Re-registering %s",
ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)));
@ -200,13 +207,11 @@ void _handle_rereg_address(const ipv6_addr_t *addr)
_snd_ns(&router->next_hop->ipv6, netif, addr, &router->next_hop->ipv6);
}
else {
DEBUG("nib: Couldn't re-register %s, no current router found or address "
"wasn't assigned to any interface anymore.\n",
DEBUG("nib: Couldn't re-register %s, no current router found.\n",
ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)));
}
if (netif != NULL) {
int idx = gnrc_netif_ipv6_addr_idx(netif, addr);
int idx = gnrc_netif_ipv6_addr_idx(netif, addr);
if (idx < 0) {
DEBUG("nib: %s is not assigned to interface %d anymore.\n",
ipv6_addr_to_str(addr_str, addr, sizeof(addr_str)),
@ -233,7 +238,6 @@ void _handle_rereg_address(const ipv6_addr_t *addr)
netif->ipv6.rs_sent = 0;
_handle_search_rtr(netif);
}
}
gnrc_netif_release(netif);
}