Skip to content

Commit

Permalink
Merge pull request #17676 from benpicco/revert-gnrc_ipv6_nib-all_ifs
Browse files Browse the repository at this point in the history
Revert "gnrc_ipv6_nib: consider all local interfaces when looking for…
  • Loading branch information
miri64 authored Mar 14, 2022
2 parents 5acf191 + 32c89e7 commit bec2868
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 23 deletions.
24 changes: 8 additions & 16 deletions sys/net/gnrc/network_layer/ipv6/nib/nib.c
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,6 @@ static void _handle_nbr_sol(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
const ndp_nbr_sol_t *nbr_sol, size_t icmpv6_len)
{
size_t tmp_len = icmpv6_len - sizeof(ndp_nbr_sol_t);
gnrc_netif_t *tgt_netif;
int tgt_idx;
ndp_opt_t *opt;

Expand All @@ -942,23 +941,13 @@ static void _handle_nbr_sol(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
ipv6_addr_to_str(addr_str, &ipv6->dst, sizeof(addr_str)));
return;
}

/* check if the address belongs to this host */
tgt_netif = gnrc_netif_get_by_ipv6_addr(&nbr_sol->tgt);

if (tgt_netif != NULL) {
/* check if target is assigned only now in case the length was wrong */
tgt_idx = gnrc_netif_ipv6_addr_idx(tgt_netif, &nbr_sol->tgt);
} else {
tgt_idx = -1;
}

/* check if target is assigned only now in case the length was wrong */
tgt_idx = gnrc_netif_ipv6_addr_idx(netif, &nbr_sol->tgt);
if (tgt_idx < 0) {
DEBUG("nib: Target address %s is not assigned to the local interface\n",
ipv6_addr_to_str(addr_str, &nbr_sol->tgt, sizeof(addr_str)));
return;
}

/* pre-check option length */
FOREACH_OPT(nbr_sol, opt, tmp_len) {
if (tmp_len > icmpv6_len) {
Expand All @@ -980,16 +969,19 @@ static void _handle_nbr_sol(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
DEBUG(" - Destination address: %s\n",
ipv6_addr_to_str(addr_str, &ipv6->dst, sizeof(addr_str)));
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_SLAAC)
gnrc_netif_t *tgt_netif = gnrc_netif_get_by_ipv6_addr(&nbr_sol->tgt);

if (tgt_netif != NULL) {
int idx;

gnrc_netif_acquire(tgt_netif);
tgt_idx = gnrc_netif_ipv6_addr_idx(tgt_netif, &nbr_sol->tgt);
idx = gnrc_netif_ipv6_addr_idx(tgt_netif, &nbr_sol->tgt);
/* if idx < 0:
* nbr_sol->tgt was removed between getting tgt_netif by nbr_sol->tgt
* and gnrc_netif_acquire(tgt_netif). This is like `tgt_netif` would
* have been NULL in the first place so just continue as if it would
* have. */
if ((tgt_idx >= 0) && gnrc_netif_ipv6_addr_dad_trans(tgt_netif, tgt_idx)) {
if ((idx >= 0) && gnrc_netif_ipv6_addr_dad_trans(tgt_netif, idx)) {
if (!ipv6_addr_is_unspecified(&ipv6->src)) {
/* (see https://tools.ietf.org/html/rfc4862#section-5.4.3) */
DEBUG("nib: Neighbor is performing AR, but target address is "
Expand All @@ -999,7 +991,7 @@ static void _handle_nbr_sol(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
}
/* cancel validation timer */
evtimer_del(&_nib_evtimer,
&tgt_netif->ipv6.addrs_timers[tgt_idx].event);
&tgt_netif->ipv6.addrs_timers[idx].event);
/* _remove_tentative_addr() context switches to `tgt_netif->pid` so
* release `tgt_netif`. We are done here anyway. */
gnrc_netif_release(tgt_netif);
Expand Down
9 changes: 2 additions & 7 deletions sys/net/gnrc/network_layer/ndp/gnrc_ndp.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,16 +356,11 @@ void gnrc_ndp_nbr_adv_send(const ipv6_addr_t *tgt, gnrc_netif_t *netif,
gnrc_netif_acquire(netif);
do { /* XXX: hidden goto */
int tgt_idx;
gnrc_netif_t *tgt_netif = gnrc_netif_get_by_ipv6_addr(tgt);

if (tgt_netif == NULL) {
if ((tgt_idx = gnrc_netif_ipv6_addr_idx(netif, tgt)) < 0) {
DEBUG("ndp: tgt not assigned to interface. Abort sending\n");
break;
}

tgt_idx = gnrc_netif_ipv6_addr_idx(tgt_netif, tgt);
assert(tgt_idx >= 0);

if (gnrc_netif_is_rtr(netif) && gnrc_netif_is_rtr_adv(netif)) {
adv_flags |= NDP_NBR_ADV_FLAGS_R;
}
Expand Down Expand Up @@ -398,7 +393,7 @@ void gnrc_ndp_nbr_adv_send(const ipv6_addr_t *tgt, gnrc_netif_t *netif,
}
/* TODO: also check if the node provides proxy services for tgt */
if ((pkt != NULL) &&
(tgt_netif->ipv6.addrs_flags[tgt_idx] &
(netif->ipv6.addrs_flags[tgt_idx] &
GNRC_NETIF_IPV6_ADDRS_FLAGS_ANYCAST)) {
/* TL2A is not supplied and tgt is not anycast */
adv_flags |= NDP_NBR_ADV_FLAGS_O;
Expand Down

0 comments on commit bec2868

Please sign in to comment.