From cbc9121ad4a1015b0f89851f165a79d622e60bd6 Mon Sep 17 00:00:00 2001 From: Daniel Krebs Date: Thu, 8 Feb 2018 13:46:46 +0100 Subject: [PATCH] gnrc/netif: fix source address selection for non-matching prefixes According to RFC 6724 ch. 5 rule 8, the source address candidate with the longest matching prefix has to be selected. The current implementation discards source addresses that have no matching prefix (`match = 0`) which is perfectly fine for any global address. --- sys/net/gnrc/netif/gnrc_netif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/net/gnrc/netif/gnrc_netif.c b/sys/net/gnrc/netif/gnrc_netif.c index 7068d3b7f0..6f0d0a0a78 100644 --- a/sys/net/gnrc/netif/gnrc_netif.c +++ b/sys/net/gnrc/netif/gnrc_netif.c @@ -874,7 +874,7 @@ static unsigned _match(const gnrc_netif_t *netif, const ipv6_addr_t *addr, } match = ipv6_addr_match_prefix(&(netif->ipv6.addrs[i]), addr); if (((match > 64U) || !ipv6_addr_is_link_local(&(netif->ipv6.addrs[i]))) && - (match > best_match)) { + (match >= best_match)) { if (idx != NULL) { *idx = i; }