From 5d5b8c64b3663d776cf6016f3bca3150fd5f23bf Mon Sep 17 00:00:00 2001 From: xnumad <34810600+xnumad@users.noreply.github.com> Date: Tue, 18 Jun 2024 20:03:15 +0200 Subject: [PATCH] fix: Regen for 6LN --- sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.c b/sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.c index c5c5fe64a129f..cf340a2d3b846 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.c +++ b/sys/net/gnrc/network_layer/ipv6/nib/_nib-slaac.c @@ -187,8 +187,17 @@ int32_t _generate_temporary_addr(gnrc_netif_t *netif, const ipv6_addr_t *pfx, int _regen_temp_addr(gnrc_netif_t *netif, const ipv6_addr_t *addr, uint8_t retries, const char *caller_description) { - //find associated prefix + uint32_t pfx_pref_ltime; +#if IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LN) && !IS_ACTIVE(CONFIG_GNRC_IPV6_NIB_6LR) + if (gnrc_netif_is_6ln(netif)) { + /* does not store SLAAC prefix -> no lifetime + * -> its addresses never expire -> regenerate temp addr unconditionally */ + pfx_pref_ltime = UINT32_MAX; + } else +#endif + { uint32_t slaac_prefix_pref_until; + //find associated prefix if (!_get_slaac_prefix_pref_until(netif, addr, &slaac_prefix_pref_until)) { // at least one match is expected, LOG_WARNING("nib: The temporary address smh outlived the SLAAC prefix valid lft."); @@ -200,8 +209,11 @@ int _regen_temp_addr(gnrc_netif_t *netif, const ipv6_addr_t *addr, uint8_t retri assert(now < slaac_prefix_pref_until); // else the temporary address smh outlived the SLAAC prefix preferred lft + pfx_pref_ltime = slaac_prefix_pref_until - now; + } + if (_generate_temporary_addr(netif, addr, - slaac_prefix_pref_until - now, + pfx_pref_ltime, retries, NULL) < 0) { LOG_WARNING("nib: Temporary address regeneration failed%s.\n", caller_description);