From b5b52c74e8eb62bf20146116cae058fcdf7688b0 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Mon, 14 Oct 2019 11:52:33 +0200 Subject: [PATCH] gnrc_ipv6: only discard invalid source when assigned to interface While it is correct to not use an invalid address as a source address, it is incorrect to assume that addresses not assigned to the interface (`idx == -1` in the respective piece of code) are invalid: Other than classic forwarding via a FIB, forwarded packets utilizing a IPv6 routing header will pass this check, like any other packet sent by this node. The source address for these is not on the given node, so e.g. source routing is not possible at the moment. --- sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c | 2 +- 1 file changed, 1 insertion(+), 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 575d603cdf..9e1bd1b159 100644 --- a/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c +++ b/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c @@ -382,7 +382,7 @@ 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)) == -1) || + invalid_src = ((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) {