1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

gnrc/ipv6_auto_subnets: add CONFIG_GNRC_IPV6_AUTO_SUBNETS_STATIC option

In situations with high packet loss, if all sync packets are lost, conflicting
subnets will be configured.

If the network is static, this can be prevented by always using the highest number
of subnets that has been observed.

This assumes no nodes are physically added / removed from the network.
This commit is contained in:
Benjamin Valentin 2021-12-21 00:14:28 +01:00
parent e0e0c4002b
commit b068bd31c2

View File

@ -153,6 +153,18 @@
#define CONFIG_GNRC_IPV6_AUTO_SUBNETS_NUMOF (1) #define CONFIG_GNRC_IPV6_AUTO_SUBNETS_NUMOF (1)
#endif #endif
/**
* @brief Enable this if you have a static network that might experience
* high packet loss under certain conditions.
* If enabled, this option causes the module to always assume the highest
* number of subnets it has ever seen.
* This prevents different/conflicting subnets from being configured if
* multiple sync packets got lost.
*/
#ifndef CONFIG_GNRC_IPV6_AUTO_SUBNETS_STATIC
#define CONFIG_GNRC_IPV6_AUTO_SUBNETS_STATIC (0)
#endif
/* Code below should not be included by Doxygen */ /* Code below should not be included by Doxygen */
#ifndef DOXYGEN #ifndef DOXYGEN
@ -623,6 +635,10 @@ static void *_eventloop(void *arg)
uint8_t subnets = local_subnets; uint8_t subnets = local_subnets;
uint8_t tx_period = CONFIG_GNRC_IPV6_AUTO_SUBNETS_TX_PER_PERIOD; uint8_t tx_period = CONFIG_GNRC_IPV6_AUTO_SUBNETS_TX_PER_PERIOD;
/* only used with CONFIG_GNRC_IPV6_AUTO_SUBNETS_STATIC set */
uint8_t idx_old = 0;
uint8_t subnets_old = 0;
DEBUG("auto_subnets: %u local subnets\n", subnets); DEBUG("auto_subnets: %u local subnets\n", subnets);
if (subnets == 0) { if (subnets == 0) {
@ -648,6 +664,21 @@ static void *_eventloop(void *arg)
/* send subnet announcement */ /* send subnet announcement */
_send_announce(local_subnets, &timeout_timer, &timeout_msg); _send_announce(local_subnets, &timeout_timer, &timeout_msg);
} else { } else {
/* don't re-enumerate subnets of a downstream router goes down */
if (CONFIG_GNRC_IPV6_AUTO_SUBNETS_STATIC) {
/* If we got less subnets than before, use the old value */
if (subnets < subnets_old) {
subnets = subnets_old;
idx_start = idx_old;
}
/* Store subnet high water mark for later use */
else {
subnets_old = subnets;
idx_old = idx_start;
}
}
/* config round done, configure subnets */ /* config round done, configure subnets */
_process_pio_cache(subnets, idx_start, _upstream); _process_pio_cache(subnets, idx_start, _upstream);