From 8e80a372cb57f98be366e8ec8bf0794fd4fc83f1 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Tue, 30 Jan 2018 12:28:45 +0100 Subject: [PATCH] gnrc_ipv6_nib: ignore corner case when adding to PL In #8135 the handling of corner cases for the conversion of milliseconds to seconds, but the internal handling was not adapted. --- sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.c b/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.c index 2abccee60b..65d3a32c33 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.c +++ b/sys/net/gnrc/network_layer/ipv6/nib/_nib-internal.c @@ -764,12 +764,17 @@ _nib_offl_entry_t *_nib_pl_add(unsigned iface, if (pref_ltime != UINT32_MAX) { _evtimer_add(dst, GNRC_IPV6_NIB_PFX_TIMEOUT, &dst->pfx_timeout, pref_ltime); - if (((pref_ltime + now) == UINT32_MAX) && (now != 0)) { - pref_ltime++; + /* ignore capped of preferred lifetimes from sec to ms conversion */ + if (pref_ltime < (UINT32_MAX - 1)) { + /* prevent pref_ltime from becoming UINT32_MAX */ + if (((pref_ltime + now) == UINT32_MAX) && (now != 0)) { + pref_ltime++; + } + pref_ltime += now; } - pref_ltime += now; } - if (valid_ltime != UINT32_MAX) { + /* ignore capped of valid lifetimes from sec to ms conversion */ + if (valid_ltime < (UINT32_MAX - 1)) { /* prevent valid_ltime from becoming UINT32_MAX */ if ((valid_ltime + now) == UINT32_MAX) { valid_ltime++;