From 4771bd3fc72fc48522899fa5fc03e1a16c6869e1 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Tue, 29 Mar 2022 15:54:15 +0200 Subject: [PATCH] gnrc/ipv6_auto_subnets: bail out early if adding prefix fails --- .../routing/ipv6_auto_subnets/gnrc_ipv6_auto_subnets.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/net/gnrc/routing/ipv6_auto_subnets/gnrc_ipv6_auto_subnets.c b/sys/net/gnrc/routing/ipv6_auto_subnets/gnrc_ipv6_auto_subnets.c index 53dac0f0cb25..1390c939c10d 100644 --- a/sys/net/gnrc/routing/ipv6_auto_subnets/gnrc_ipv6_auto_subnets.c +++ b/sys/net/gnrc/routing/ipv6_auto_subnets/gnrc_ipv6_auto_subnets.c @@ -306,6 +306,10 @@ static void _configure_subnets(uint8_t subnets, uint8_t start_idx, gnrc_netif_t /* configure subnet on downstream interface */ idx = gnrc_netif_ipv6_add_prefix(downstream, &new_prefix, new_prefix_len, valid_ltime, pref_ltime); + if (idx < 0) { + DEBUG("auto_subnets: adding prefix to %u failed\n", downstream->pid) + continue; + } /* start advertising subnet */ gnrc_ipv6_nib_change_rtr_adv_iface(downstream, true); @@ -320,9 +324,7 @@ static void _configure_subnets(uint8_t subnets, uint8_t start_idx, gnrc_netif_t } /* configure RPL root if applicable */ - if (idx >= 0) { - gnrc_rpl_configure_root(downstream, &downstream->ipv6.addrs[idx]); - } + gnrc_rpl_configure_root(downstream, &downstream->ipv6.addrs[idx]); } /* immediately send an RA with RIO */