From 1f71b30bc2289925616272637af6a40b8a58565f Mon Sep 17 00:00:00 2001 From: Martine Lenders <m.lenders@fu-berlin.de> Date: Mon, 7 Jan 2019 16:39:05 +0100 Subject: [PATCH] gnrc_ipv6_nib: fix RA reception for non-6LN interfaces When having a non-6LN interface and a 6LN interface (e.g. on a border router) the assertion can hit when a Router Advertisement is received. This makes the check an `if` statement rather than an assertion, to account for that case. Co-authored-by: Gunar Schorcht <gunar@schorcht.net> --- sys/net/gnrc/network_layer/ipv6/nib/nib.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/sys/net/gnrc/network_layer/ipv6/nib/nib.c b/sys/net/gnrc/network_layer/ipv6/nib/nib.c index 17bb9b91ae..a749f9a87c 100644 --- a/sys/net/gnrc/network_layer/ipv6/nib/nib.c +++ b/sys/net/gnrc/network_layer/ipv6/nib/nib.c @@ -1382,6 +1382,16 @@ static void _remove_prefix(const ipv6_addr_t *pfx, unsigned pfx_len) return; } +#if GNRC_IPV6_NIB_CONF_MULTIHOP_P6C +static inline bool _multihop_p6c(gnrc_netif_t *netif, _nib_abr_entry_t *abr) +{ + (void)netif; /* gnrc_netif_is_6lr() might resolve to a NOP */ + return (gnrc_netif_is_6lr(netif) && (abr != NULL)); +} +#else /* GNRC_IPV6_NIB_CONF_MULTIHOP_P6C */ +#define _multihop_p6c(netif, abr) (false) +#endif /* GNRC_IPV6_NIB_CONF_MULTIHOP_P6C */ + #if GNRC_IPV6_NIB_CONF_MULTIHOP_P6C static uint32_t _handle_pio(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6, const ndp_opt_pi_t *pio, _nib_abr_entry_t *abr) @@ -1415,7 +1425,7 @@ static uint32_t _handle_pio(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6, if (pio->flags & NDP_OPT_PI_FLAGS_A) { _auto_configure_addr(netif, &pio->prefix, pio->prefix_len); } - if ((pio->flags & NDP_OPT_PI_FLAGS_L) || gnrc_netif_is_6lr(netif)) { + if ((pio->flags & NDP_OPT_PI_FLAGS_L) || _multihop_p6c(netif, abr)) { _nib_offl_entry_t *pfx; if (pio->valid_ltime.u32 == 0) { @@ -1442,8 +1452,9 @@ static uint32_t _handle_pio(gnrc_netif_t *netif, const icmpv6_hdr_t *icmpv6, if ((pfx = _nib_pl_add(netif->pid, &pio->prefix, pio->prefix_len, valid_ltime, pref_ltime))) { #if GNRC_IPV6_NIB_CONF_MULTIHOP_P6C - assert(abr != NULL); /* should have been set in _handle_abro() */ - _nib_abr_add_pfx(abr, pfx); + if (abr != NULL) { + _nib_abr_add_pfx(abr, pfx); + } #endif /* GNRC_IPV6_NIB_CONF_MULTIHOP_P6C */ if (pio->flags & NDP_OPT_PI_FLAGS_L) { pfx->flags |= _PFX_ON_LINK; -- GitLab