Skip to content

Commit

Permalink
ipv6/nib: bugfix handle SLLAO on 6LR if ARO is not present
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian18 committed Apr 4, 2022
1 parent 7bcc673 commit 475e081
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 22 deletions.
36 changes: 17 additions & 19 deletions sys/net/gnrc/network_layer/ipv6/nib/_nib-6lr.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,28 +136,26 @@ gnrc_pktsnip_t *_copy_and_handle_aro(gnrc_netif_t *netif,
const ndp_opt_t *sl2ao)
{
gnrc_pktsnip_t *reply_aro = NULL;

if (aro != NULL) {
uint8_t status = _handle_aro(netif, ipv6, (icmpv6_hdr_t *)nbr_sol, aro,
sl2ao, NULL);

if ((status != _ADDR_REG_STATUS_TENTATIVE) &&
(status != _ADDR_REG_STATUS_IGNORE)) {
reply_aro = gnrc_sixlowpan_nd_opt_ar_build(status,
byteorder_ntohs(aro->ltime),
(eui64_t *)&aro->eui64,
NULL);
if (reply_aro == NULL) {
DEBUG("nib: No space left in packet buffer. Not replying NS");
}
assert(aro);
uint8_t status = _handle_aro(netif, ipv6, (icmpv6_hdr_t *)nbr_sol, aro,
sl2ao, NULL);

if ((status != _ADDR_REG_STATUS_TENTATIVE) &&
(status != _ADDR_REG_STATUS_IGNORE)) {
reply_aro = gnrc_sixlowpan_nd_opt_ar_build(status,
byteorder_ntohs(aro->ltime),
(eui64_t *)&aro->eui64,
NULL);
if (reply_aro == NULL) {
DEBUG("nib: No space left in packet buffer. Not replying NS");
}
}
#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_MULTIHOP_DAD)
else if (status != _ADDR_REG_STATUS_IGNORE) {
DEBUG("nib: Address was marked TENTATIVE => not replying NS, "
"waiting for DAC\n");
}
#endif /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_DAD */
else if (status != _ADDR_REG_STATUS_IGNORE) {
DEBUG("nib: Address was marked TENTATIVE => not replying NS, "
"waiting for DAC\n");
}
#endif /* CONFIG_GNRC_IPV6_NIB_MULTIHOP_DAD */
return reply_aro;
}
#else /* CONFIG_GNRC_IPV6_NIB_6LR */
Expand Down
2 changes: 1 addition & 1 deletion sys/net/gnrc/network_layer/ipv6/nib/_nib-6lr.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ uint8_t _reg_addr_upstream(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
* @param[in] nbr_sol The neighbor solicitation carrying the original ARO
* (handed over as @ref icmpv6_hdr_t, since it is just
* handed to @ref _handle_aro()).
* @param[in] aro The original ARO
* @param[in] aro The original ARO, must not be NULL
* @param[in] sl2ao SL2AO associated with the ARO.
*
* @return registration status of the address (including
Expand Down
14 changes: 12 additions & 2 deletions sys/net/gnrc/network_layer/ipv6/nib/nib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1027,7 +1027,7 @@ static void _handle_nbr_sol(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
if (gnrc_netif_is_6lr(netif)) {
DEBUG("nib: Storing SL2AO for later handling\n");
sl2ao = opt;
break;
break; /* SL2AO is handled below together with an ARO */
}
#endif /* CONFIG_GNRC_IPV6_NIB_6LR */
_handle_sl2ao(netif, ipv6, (const icmpv6_hdr_t *)nbr_sol,
Expand All @@ -1045,7 +1045,17 @@ static void _handle_nbr_sol(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
break;
}
}
reply_aro = _copy_and_handle_aro(netif, ipv6, nbr_sol, aro, sl2ao);
if (aro && sl2ao) {
/* If no SLLAO is included, then any included ARO is ignored. */
if (!(reply_aro = _copy_and_handle_aro(netif, ipv6, nbr_sol, aro, sl2ao))) {
/* If the Length field is not two, or if the Status field is not zero,
then the NS is silently ignored.*/
return;
}
}
else if (sl2ao) {
_handle_sl2ao(netif, ipv6, (const icmpv6_hdr_t *)nbr_sol, sl2ao);
}
/* check if target address is anycast */
if (netif->ipv6.addrs_flags[tgt_idx] & GNRC_NETIF_IPV6_ADDRS_FLAGS_ANYCAST) {
_send_delayed_nbr_adv(netif, &nbr_sol->tgt, ipv6, reply_aro);
Expand Down

0 comments on commit 475e081

Please sign in to comment.