From df16332bd09f112441b9500d1ac3ec4ae5d3290c Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Fri, 18 Jan 2019 18:49:03 +0100 Subject: [PATCH] fixup! gnrc_netif: check all required options on initialization --- sys/net/gnrc/netif/gnrc_netif.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/sys/net/gnrc/netif/gnrc_netif.c b/sys/net/gnrc/netif/gnrc_netif.c index 54477896d028..af17b4904f4c 100644 --- a/sys/net/gnrc/netif/gnrc_netif.c +++ b/sys/net/gnrc/netif/gnrc_netif.c @@ -1171,7 +1171,9 @@ static void _test_options(gnrc_netif_t *netif) /* check if address was set in _update_l2addr_from_dev() * (NETOPT_DEVICE_TYPE already tested in _configure_netdev()) and * if MTU and max. fragment size was set properly by - * gnrc_netif_ipv6_init_mtu() */ + * gnrc_netif_ipv6_init_mtu() + * all checked types below have link-layer addresses so we don't need to + * check `GNRC_NETIF_FLAGS_HAS_L2ADDR` */ switch (netif->device_type) { case NETDEV_TYPE_BLE: case NETDEV_TYPE_ETHERNET: @@ -1237,15 +1239,19 @@ static void _test_options(gnrc_netif_t *netif) * porting new device type */ assert(false); } -#endif /* (GNRC_NETIF_L2ADDR_MAXLEN > 0) */ + /* These functions only apply to network devices having link-layers */ + if (netif->flags & GNRC_NETIF_FLAGS_HAS_L2ADDR) { #ifdef MODULE_GNRC_IPV6 - assert(-ENOTSUP != gnrc_netif_ipv6_get_iid(netif, (eui64_t *)&tmp64)); - assert(-ENOTSUP != gnrc_netif_ndp_addr_len_from_l2ao(netif, &dummy_opt)); + assert(-ENOTSUP != gnrc_netif_ipv6_get_iid(netif, (eui64_t *)&tmp64)); + assert(-ENOTSUP != gnrc_netif_ndp_addr_len_from_l2ao(netif, + &dummy_opt)); #endif /* MODULE_GNRC_IPV6 */ -#if GNRC_IPV6_NIB_CONF_6LN && (GNRC_NETIF_L2ADDR_MAXLEN > 0) - assert(-ENOTSUP != gnrc_netif_ipv6_iid_to_addr(netif, (eui64_t *)&tmp64, - dummy_addr)); +#if GNRC_IPV6_NIB_CONF_6LN + assert(-ENOTSUP != gnrc_netif_ipv6_iid_to_addr(netif, (eui64_t *)&tmp64, + dummy_addr)); #endif /* GNRC_IPV6_NIB_CONF_6LN */ + } +#endif /* (GNRC_NETIF_L2ADDR_MAXLEN > 0) */ } #endif /* DEVELHELP */