From 983b60dbd49a3b9bca7e43de299f4bf84741116b Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Tue, 29 Jan 2019 17:56:58 +0100 Subject: [PATCH 1/2] gnrc_rpl: do not assert netif on auto-init `gnrc_networking` is unusable when compiled for boards that do not have any network devices on-board due to an assertion in RPL's auto-init. I think this is pretty harsh. A friendly info message is enough, as it might not even be an error. Also, if one expects RPL to work without network interfaces they are a fool ;-). --- sys/net/gnrc/routing/rpl/gnrc_rpl_auto_init.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/net/gnrc/routing/rpl/gnrc_rpl_auto_init.c b/sys/net/gnrc/routing/rpl/gnrc_rpl_auto_init.c index d5e0ba3ee3..f6424d5856 100644 --- a/sys/net/gnrc/routing/rpl/gnrc_rpl_auto_init.c +++ b/sys/net/gnrc/routing/rpl/gnrc_rpl_auto_init.c @@ -19,6 +19,7 @@ #ifdef MODULE_AUTO_INIT_GNRC_RPL +#include "log.h" #include "net/gnrc.h" #include "net/gnrc/rpl.h" @@ -29,7 +30,10 @@ void auto_init_gnrc_rpl(void) { #if (GNRC_NETIF_NUMOF == 1) gnrc_netif_t *netif = gnrc_netif_iter(NULL); - assert(netif != NULL); + if (netif == NULL) { + LOG_INFO("Unable to auto-initialize RPL. No interfaces found.\n"); + return; + } DEBUG("auto_init_gnrc_rpl: initializing RPL on interface %" PRIkernel_pid "\n", netif->pid); gnrc_rpl_init(netif->pid); From bef475e450de4c42343f95d31ba29f6b38ef0aff Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Tue, 26 Feb 2019 20:33:07 +0100 Subject: [PATCH 2/2] gnrc_rpl_auto_init: add workaround comments --- sys/net/gnrc/routing/rpl/gnrc_rpl_auto_init.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/net/gnrc/routing/rpl/gnrc_rpl_auto_init.c b/sys/net/gnrc/routing/rpl/gnrc_rpl_auto_init.c index f6424d5856..0f36971ea9 100644 --- a/sys/net/gnrc/routing/rpl/gnrc_rpl_auto_init.c +++ b/sys/net/gnrc/routing/rpl/gnrc_rpl_auto_init.c @@ -31,6 +31,8 @@ void auto_init_gnrc_rpl(void) #if (GNRC_NETIF_NUMOF == 1) gnrc_netif_t *netif = gnrc_netif_iter(NULL); if (netif == NULL) { + /* XXX this is just a work-around ideally this would happen with + * an `up` event of the interface */ LOG_INFO("Unable to auto-initialize RPL. No interfaces found.\n"); return; } @@ -45,10 +47,14 @@ void auto_init_gnrc_rpl(void) gnrc_rpl_init(GNRC_RPL_DEFAULT_NETIF); return; } + /* XXX this is just a work-around ideally this would happen with + * an `up` event of the GNRC_RPL_DEFAULT_NETIF */ DEBUG("auto_init_gnrc_rpl: could not initialize RPL on interface %" PRIkernel_pid" - " "interface does not exist\n", GNRC_RPL_DEFAULT_NETIF); return; #else + /* XXX this is just a work-around ideally this should be defined in some + * run-time interface configuration */ DEBUG("auto_init_gnrc_rpl: please specify an interface by setting GNRC_RPL_DEFAULT_NETIF\n"); #endif }