Skip to content

Commit

Permalink
Merge pull request #18661 from fabian18/nib-6ln_correct_abr_timeout
Browse files Browse the repository at this point in the history
nib/_nib-6ln: correct ABR timeout in ABRO
  • Loading branch information
benpicco authored Sep 29, 2022
2 parents 433b2a9 + 23fa337 commit 6257e32
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
14 changes: 14 additions & 0 deletions sys/include/net/sixlowpan/nd.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,20 @@ static inline void sixlowpan_nd_opt_abr_set_version(sixlowpan_nd_opt_abr_t *abr_
abr_opt->vhigh = byteorder_htons((uint16_t)(version >> 16));
}

/**
* @brief Get the lifetime of an Authoritative Border Router from an ABR option
*
* @param[in] abr_opt An Authoritative Border Router option (ABRO).
*
* @return The lifetime of @p abr_opt in minutes. If the lifetime is 0,
* @ref SIXLOWPAN_ND_OPT_ABR_LTIME_DEFAULT is returned.
*/
static inline uint16_t gnrc_sixlowpan_nd_opt_get_ltime(const sixlowpan_nd_opt_abr_t *abr_opt)
{
uint16_t ltime = byteorder_ntohs(abr_opt->ltime);
return (ltime == 0) ? SIXLOWPAN_ND_OPT_ABR_LTIME_DEFAULT : ltime;
}

#ifdef __cplusplus
}
#endif
Expand Down
6 changes: 2 additions & 4 deletions sys/net/gnrc/network_layer/ipv6/nib/_nib-6ln.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,9 @@ _nib_abr_entry_t *_handle_abro(const sixlowpan_nd_opt_abr_t *abro)
abr = _nib_abr_add(&abro->braddr);
if (abr != NULL) {
uint32_t abro_version = sixlowpan_nd_opt_abr_get_version(abro);
uint16_t ltime = byteorder_ntohs(abro->ltime);
/* correct for default value */
ltime = (ltime == 0) ? SIXLOWPAN_ND_OPT_ABR_LTIME_DEFAULT : ltime;

uint32_t ltime_ms = MS_PER_SEC * SEC_PER_MIN * ltime;
uint32_t ltime_ms = MS_PER_SEC * SEC_PER_MIN *
gnrc_sixlowpan_nd_opt_get_ltime(abro);

if (abr->version >= abro_version) {
abr->version = abro_version;
Expand Down
4 changes: 2 additions & 2 deletions sys/net/gnrc/network_layer/ipv6/nib/nib.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,8 +701,8 @@ static void _handle_rtr_adv(gnrc_netif_t *netif, const ipv6_hdr_t *ipv6,
}
/* UINT16_MAX * 60 * 1000 < UINT32_MAX so there are no overflows */
next_timeout = _min(next_timeout,
byteorder_ntohs(abro->ltime) * SEC_PER_MIN *
MS_PER_SEC);
MS_PER_SEC * SEC_PER_MIN *
gnrc_sixlowpan_nd_opt_get_ltime(abro));
}
#if !IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LBR)
else if (gnrc_netif_is_6lr(netif)) {
Expand Down

0 comments on commit 6257e32

Please sign in to comment.