diff --git a/sys/net/gnrc/network_layer/ipv6/static_addr/gnrc_ipv6_static_addr.c b/sys/net/gnrc/network_layer/ipv6/static_addr/gnrc_ipv6_static_addr.c index 49ce13f96b40..71c9b1b73800 100644 --- a/sys/net/gnrc/network_layer/ipv6/static_addr/gnrc_ipv6_static_addr.c +++ b/sys/net/gnrc/network_layer/ipv6/static_addr/gnrc_ipv6_static_addr.c @@ -113,25 +113,34 @@ static void _config_downstream(gnrc_netif_t *downstream) void auto_init_gnrc_ipv6_static_addr(void) { - gnrc_netif_t *netif = NULL; gnrc_netif_t *upstream = NULL; gnrc_netif_t *downstream = NULL; - if (IS_ACTIVE(CONFIG_GNRC_IPV6_STATIC_ADDR_UPSTREAM)) { - upstream = gnrc_netif_get_by_pid(CONFIG_GNRC_IPV6_STATIC_ADDR_UPSTREAM); - } + if (gnrc_netif_highlander() || gnrc_netif_numof() == 1) { + upstream = gnrc_netif_iter(NULL); - if (IS_ACTIVE(CONFIG_GNRC_IPV6_STATIC_ADDR_DOWNSTREAM)) { - downstream = gnrc_netif_get_by_pid(CONFIG_GNRC_IPV6_STATIC_ADDR_DOWNSTREAM); - } + if (IS_ACTIVE(CONFIG_GNRC_IPV6_STATIC_ADDR_UPSTREAM)) { + assert(upstream->pid == CONFIG_GNRC_IPV6_STATIC_ADDR_UPSTREAM); + } + } else { + + if (IS_ACTIVE(CONFIG_GNRC_IPV6_STATIC_ADDR_UPSTREAM)) { + upstream = gnrc_netif_get_by_pid(CONFIG_GNRC_IPV6_STATIC_ADDR_UPSTREAM); + } + + if (IS_ACTIVE(CONFIG_GNRC_IPV6_STATIC_ADDR_DOWNSTREAM)) { + downstream = gnrc_netif_get_by_pid(CONFIG_GNRC_IPV6_STATIC_ADDR_DOWNSTREAM); + } - while ((netif = gnrc_netif_iter(netif))) { - bool is_wired = gnrc_netapi_get(netif->pid, NETOPT_IS_WIRED, 0, NULL, 0) == 1; + gnrc_netif_t *netif = NULL; + while ((netif = gnrc_netif_iter(netif))) { + bool is_wired = gnrc_netapi_get(netif->pid, NETOPT_IS_WIRED, 0, NULL, 0) == 1; - if (!upstream && is_wired) { - upstream = netif; - } else if (!downstream && !is_wired) { - downstream = netif; + if (!upstream && is_wired) { + upstream = netif; + } else if (!downstream && !is_wired) { + downstream = netif; + } } }