ipv6: Compare addresses only bits up to the prefix length (RFC6724).
authorYOSHIFUJI Hideaki / 吉藤英明 <yoshfuji@linux-ipv6.org>
Mon, 10 Sep 2012 18:41:07 +0000 (18:41 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 13 Sep 2012 20:34:03 +0000 (16:34 -0400)
Compare bits up to the source address's prefix length only to
allows DNS load balancing to continue to be used as a tie breaker.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv6/addrconf.c

index 1237d5d037d82750b9aad892446f3f6be620abdf..5fd8ec895c8b71980c2a79cfc48cfc0d672907ac 100644 (file)
@@ -1070,8 +1070,10 @@ static int ipv6_get_saddr_eval(struct net *net,
                break;
        case IPV6_SADDR_RULE_PREFIX:
                /* Rule 8: Use longest matching prefix */
-               score->matchlen = ret = ipv6_addr_diff(&score->ifa->addr,
-                                                      dst->addr);
+               ret = ipv6_addr_diff(&score->ifa->addr, dst->addr);
+               if (ret > score->ifa->prefix_len)
+                       ret = score->ifa->prefix_len;
+               score->matchlen = ret;
                break;
        default:
                ret = 0;