Subject: [patch] ipv6 source address selection in addrconf.c (2.6.17)

From: Lukasz Stelmach <[email-masked]>
Date: Wed, 21 Jun 2006 15:42:11 +0200

Lukasz Stelmach wrote:

> I found it when I was trying to figure out why when trying to connect to
> 
> 2001:200:0:8002:203:47ff:fea5:3085 (www.kame.net)
> 
> with two global addresses assigned to the ethernet card
> 
> fd24:6f44:46bd:face::254
> 2002:531f:d667:face::254
> 
> rule 8 does not work and the first address is chosen.

The answer is that fc00::/7 matches 2001:: better because it gets the same
label (ipv6_saddr_label()). Although fc00::/7 addresses are defined as global
unicast IMHO they should be treated *slightly* different. This is the patch.
Since 6to4 has its own label I have decided to assign one to Teredo too.

However, I still haven't found any clue in referneces to unassigned value of
hiscore.addr_type.

-- 
Było mi bardzo miło.                    Czwarta pospolita klęska, [...]
>Łukasz<                      Już nie katolicka lecz złodziejska.  (c)PP

----------------------------------------------------------------------
Zobacz nowosci salonu moto w Madrycie >>> http://link.interia.pl/f1961
--- /usr/src/linux/net/ipv6/addrconf.c~	2006-06-21 11:41:22.000000000 +0200
+++ /usr/src/linux/net/ipv6/addrconf.c	2006-06-21 15:33:26.000000000 +0200
@@ -862,6 +862,8 @@
   * 	2002::/16		2
   * 	::/96			3
   * 	::ffff:0:0/96		4
+  *	fc00::/7		5
+  * 	2001::/32		6
   */
 	if (type & IPV6_ADDR_LOOPBACK)
 		return 0;
@@ -871,6 +873,10 @@
 		return 4;
 	else if (addr->s6_addr16[0] == htons(0x2002))
 		return 2;
+	else if ((addr->s6_addr[0] & 0xfe) == 0xfc)
+		return 5;
+	else if (addr->s6_addr32[0] == htonl(0x20010000))
+		return 6;
 	return 1;
 }