From 159accff37c4023967554f68ab0e713f08577b90 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Thu, 5 Dec 2019 23:38:53 +0100 Subject: [PATCH] gnrc_ipv6: fix source check for loopback address When the destination address is the loopback address (`::1`) in GNRC the selected network interface typically is `NULL`, as with GNRC no loopback interface de facto exists. So the assertion when checking if the source address is valid if `netif != NULL` fails on that check. This change fixes that issue by checking if the destination address is the loopback address, before checking the validity of the source address. --- sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c b/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c index 9edb473d82..c3c526868f 100644 --- a/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c +++ b/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c @@ -382,7 +382,8 @@ static int _fill_ipv6_hdr(gnrc_netif_t *netif, gnrc_pktsnip_t *ipv6) int idx; gnrc_netif_acquire(netif); - invalid_src = ((idx = gnrc_netif_ipv6_addr_idx(netif, &hdr->src)) >= 0) && + invalid_src = ((!ipv6_addr_is_loopback(&hdr->dst)) && + (idx = gnrc_netif_ipv6_addr_idx(netif, &hdr->src)) >= 0) && (gnrc_netif_ipv6_addr_get_state(netif, idx) != GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_VALID); gnrc_netif_release(netif); if (invalid_src) {