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.
This commit is contained in:
Martine Lenders 2019-10-14 11:52:33 +02:00
parent 0e0b6f8231
commit b5b52c74e8

View File

@ -382,7 +382,7 @@ static int _fill_ipv6_hdr(gnrc_netif_t *netif, gnrc_pktsnip_t *ipv6)
int idx; int idx;
gnrc_netif_acquire(netif); 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_ipv6_addr_get_state(netif, idx) != GNRC_NETIF_IPV6_ADDRS_FLAGS_STATE_VALID);
gnrc_netif_release(netif); gnrc_netif_release(netif);
if (invalid_src) { if (invalid_src) {