diff --git a/sys/net/gnrc/network_layer/ipv6/nib/_nib-router.c b/sys/net/gnrc/network_layer/ipv6/nib/_nib-router.c index 1d417750c6ab..76ee917483ba 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/_nib-router.c +++ b/sys/net/gnrc/network_layer/ipv6/nib/_nib-router.c @@ -111,8 +111,14 @@ static gnrc_pktsnip_t *_offl_to_pio(_nib_offl_entry_t *offl, uint8_t flags = 0; uint32_t valid_ltime = (offl->valid_until == UINT32_MAX) ? UINT32_MAX : ((offl->valid_until - now) / MS_PER_SEC); - uint32_t pref_ltime = (offl->pref_until == UINT32_MAX) ? UINT32_MAX : - ((offl->pref_until - now) / MS_PER_SEC); + uint32_t pref_ltime = offl->pref_until; + if (pref_ltime != UINT32_MAX) { /* reserved for infinite lifetime */ + if (pref_ltime >= now) { /* avoid overflow */ + pref_ltime = (pref_ltime - now) / MS_PER_SEC; + } else { + pref_ltime = 0; /* deprecated */ + } + } DEBUG("nib: Build PIO for %s/%u\n", ipv6_addr_to_str(addr_str, &offl->pfx, sizeof(addr_str)), diff --git a/sys/net/gnrc/network_layer/ipv6/nib/nib_pl.c b/sys/net/gnrc/network_layer/ipv6/nib/nib_pl.c index b7abefa17bd1..0ea9be0620e2 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/nib_pl.c +++ b/sys/net/gnrc/network_layer/ipv6/nib/nib_pl.c @@ -158,7 +158,7 @@ void gnrc_ipv6_nib_pl_print(gnrc_ipv6_nib_pl_t *entry) printf(" expires %lu sec", (entry->valid_until - now) / MS_PER_SEC); } if (entry->pref_until < UINT32_MAX) { - printf(" deprecates %lu sec", (entry->pref_until - now) / MS_PER_SEC); + printf(" deprecates %lu sec", (now >= entry->pref_until ? 0 : entry->pref_until - now) / MS_PER_SEC); } puts(""); }