瀏覽代碼

[IPV6]: Use ipv6_addr_src_scope for link address sorting.

In the source address selection, the address must be sorted
from global to node-local.

But, ifp->scope is different from the scope for source address
selection.

                                 2001::1  fe80::1     ::1
ifp->scope                             0     0x02    0x01
ipv6_addr_src_scope(&ifp->addr)     0x0e     0x02    0x01

So, we need to use ipv6_addr_src_scope(&ifp->addr) for sorting.

And, for backward compatibility, addresses should be sorted from
new one to old one.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Acked-by: Brian Haley <brian.haley@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
YOSHIFUJI Hideaki 19 年之前
父節點
當前提交
8a6ce0c083
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      net/ipv6/addrconf.c

+ 2 - 1
net/ipv6/addrconf.c

@@ -512,6 +512,7 @@ static void
 ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp)
 ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp)
 {
 {
 	struct inet6_ifaddr *ifa, **ifap;
 	struct inet6_ifaddr *ifa, **ifap;
+	int ifp_scope = ipv6_addr_src_scope(&ifp->addr);
 
 
 	/*
 	/*
 	 * Each device address list is sorted in order of scope -
 	 * Each device address list is sorted in order of scope -
@@ -519,7 +520,7 @@ ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp)
 	 */
 	 */
 	for (ifap = &idev->addr_list; (ifa = *ifap) != NULL;
 	for (ifap = &idev->addr_list; (ifa = *ifap) != NULL;
 	     ifap = &ifa->if_next) {
 	     ifap = &ifa->if_next) {
-		if (ifp->scope > ifa->scope)
+		if (ifp_scope >= ipv6_addr_src_scope(&ifa->addr))
 			break;
 			break;
 	}
 	}