ipv6 source address selection in addrconf.c (2.6.17)
Subsystems (3)
Greetings.
net/ipv6/addrconf.c:971 is
/* Rule 2: Prefer appropriate scope */
if (hiscore.rule < 2) {
hiscore.scope = __ipv6_addr_src_scope(hiscore.addr_type);
hiscore.rule++;
}I am afraid, that it does not make any sense for I find no place where a value is assigned to hiscore.addr_type. There are some more references to hiscore.addr_type below but the only assignment is when the whole structure is cleaned with memset(3)
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.
Please CC answers.
Signature · 1 line
Było mi bardzo miło. Czwarta pospolita klęska, [...]
Quoted 1 line
Łukasz< Już nie katolicka lecz złodziejska. (c)PP
PATCH 1/1 ipv6 source address selection in addrconf.c (2.6.17)
Quoted 10 lines · Lukasz Stelmach
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::254rule 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.
Signature · 1 line
Było mi bardzo miło. Czwarta pospolita klęska, [...]
Quoted 1 line
Ł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 renamed from usr/src/linux/net/ipv6/addrconf.c~ +6 -0
@@ -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 ; }
In article <[email protected]> (at Tue, 20 Jun 2006 23:38:46 +0200), Lukasz Stelmach <[email protected]> says:
Quoted 9 lines
Greetings.
net/ipv6/addrconf.c:971is
/* Rule 2: Prefer appropriate scope */if (hiscore.rule < 2) { hiscore.scope = __ipv6_addr_src_scope(hiscore.addr_type); hiscore.rule++; }
Quoted 4 lines
I am afraid, that it does not make any sense for I find no place where a value is assigned to hiscore.addr_type. There are some more references to hiscore.addr_type below but the only assignment is when the whole structure is cleaned with memset(3)
hiscore is copied from score.
--yoshfuji
In article <[email protected]> (at Wed, 21 Jun 2006 15:42:11 +0200), Lukasz Stelmach <[email protected]> says:
Quoted 12 lines
usr/src/linux/net/ipv6/addrconf.c renamed from usr/src/linux/net/ipv6/addrconf.c~ +2
-0@@ -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 ;
usr/src/linux/net/ipv6/addrconf.c line 882
Quoted 10 lines
usr/src/linux/net/ipv6/addrconf.c renamed from usr/src/linux/net/ipv6/addrconf.c~ +4
-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 ; }
Please put the comparison for 2001::/32 before 2002::/16. Otherwise, I'm fine with it.
In addition, give us your sign-off, please.
Regards,
Signature · 2 lines
YOSHIFUJI Hideaki @ USAGI Project <[email protected]> GPG-FP : 9022 65EB 1ECF 3AD1 0BDF 80D8 4807 F894 E062 0EEA
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
- --- linux/net/ipv6/addrconf.c.orig 2006-06-21 11:41:22.000000000 +0200
+++ linux/net/ipv6/addrconf.c 2006-06-21 17:18:56.000000000 +0200
@@ -862,6 +862,8 @@ static int inline ipv6_saddr_label(const
* 2002::/16 2
* ::/96 3
* ::ffff:0:0/96 4
+ * fc00::/7 5
+ * 2001::/32 6
*/
if (type & IPV6_ADDR_LOOPBACK)
return 0;
@@ -869,8 +871,12 @@ static int inline ipv6_saddr_label(const
return 3;
else if (type & IPV6_ADDR_MAPPED)
return 4;
+ else if (addr->s6_addr32[0] == htonl(0x20010000))
+ return 6;
else if (addr->s6_addr16[0] == htons(0x2002))
return 2;
+ else if ((addr->s6_addr[0] & 0xfe) == 0xfc)
+ return 5;
return 1;
}
Two additional labels (RFC 3484, sec. 10.3) for IPv6 addreses are defined to make a distinction between global unicast addresses and Unique Local Addresses (fc00::/7, RFC 4193) and Teredo (2001::/32, RFC 4380). It is necessary to avoid attempts of connection that would either fail (eg. fec0:: to 2001:feed::) or be sub-optimal (2001:0:: to 2001:feed::).
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)
iD4DBQFEmW0LNdzY8sm9K9wRAjVGAKCOS1MVIro3bJ6szHzuAzaXXNaq/gCY4jfO timfJc6SmrygMer36Tdqzg==
=Qzch
-----END PGP SIGNATURE-----
Signature · 1 line
Było mi bardzo miło. Czwarta pospolita klęska, [...]
Quoted 1 line
Łukasz< Już nie katolicka lecz złodziejska. (c)PP
----------------------------------------------------------------------
Zobacz nowosci salonu moto w Madrycie >>> http://link.interia.pl/f1961
Quoted 11 lines · Lukasz Stelmach
Quoted 9 lines · Lukasz Stelmach
[...] 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
Quoted 6 lines
Quoted 1 line
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.
There still, however, remains one issue. Aditional labels prevent kernel from selecting fc00::/7 prematurly. But there is no way to stop it from selecting it in rule 7. A wrong assumption has been taken that there is only one "private" address per interface and it is always the best choice. If there are four addresses on the interface:
fd24:6f44:46bd:face:EUI64 fd24:6f44:46bd:face:RANDOM and
2002:531f:d667:face:EUI64 2002:531f:d667:face::RANDOM
there seem to be no way to prefere 2002:: over fc00:: in rule 7 and it will be selected as long as it is before 2002:: on the list. I can see here that an implicit assumption has been made that an interface either is multihomed or "private". The seventh rule should not IMHO break the whole process of selection but rather mark as selectable all "private" (random) addresses. And it should rather be done before rule 6.
Yet another issue with privacy enhancement is how not to choose "private" address (let's even forget for a moment about fc00::/7) when connecting to certain hosts or networks. For example I would like to hide MAC adresses of my client machines when connecting to some foreign servers but I want to see permanent addresses in the logfiles of my servers. Maybe even use them to create som ACLs. This is an interesting case.
Kind regards,
Signature · 1 line
Było mi bardzo miło. Czwarta pospolita klęska, [...]
Quoted 1 line
Łukasz< Już nie katolicka lecz złodziejska. (c)PP
In article <[email protected]> (at Thu, 22 Jun 2006 00:57:56 +0200), Lukasz Stelmach <[email protected]> says:
Quoted 29 lines
Quoted 11 lines · Lukasz Stelmach
Quoted 9 lines · Lukasz Stelmach
[...] 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::254Quoted 6 lines
Quoted 1 line
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.There still, however, remains one issue. Aditional labels prevent kernel from selecting fc00::/7 prematurly. But there is no way to stop it from selecting it in rule 7. A wrong assumption has been taken that there is only one "private" address per interface and it is always the best choice. If there are four addresses on the interface:
fd24:6f44:46bd:face:EUI64 fd24:6f44:46bd:face:RANDOM and
2002:531f:d667:face:EUI64 2002:531f:d667:face::RANDOM
Quoted 6 lines
there seem to be no way to prefere 2002:: over fc00:: in rule 7 and it will be selected as long as it is before 2002:: on the list. I can see here that an implicit assumption has been made that an interface either is multihomed or "private". The seventh rule should not IMHO break the whole process of selection but rather mark as selectable all "private" (random) addresses. And it should rather be done before rule 6.
Hmm? We do not have such intention.
In above case, when you connect to 2001:200:0:8002:203:47ff:fea5:3085, either 2002:531f:d667:face:EUI64 or 2002:531f:d667:face::RANDOM should be selected (depending on if use_tempaddr >= 2),
by the longest matching rule (Rule 8).
--yoshfuji
Quoted 4 lines · YOSHIFUJI Hideaki / 吉藤英明
In article <[email protected]> (at Thu, 22 Jun 2006 00:57:56 +0200), Lukasz Stelmach <[email protected]> says:
Quoted 2 lines
Quoted 1 line · Lukasz Stelmach
Lukasz Stelmach wrote:
[....]
Quoted 12 lines
Quoted 11 lines
fd24:6f44:46bd:face:EUI64 fd24:6f44:46bd:face:RANDOM and
2002:531f:d667:face:EUI64 2002:531f:d667:face::RANDOMthere seem to be no way to prefere 2002:: over fc00:: in rule 7 and it will be selected as long as it is before 2002:: on the list. I can see here that an implicit assumption has been made that an interface either is multihomed or "private". The seventh rule should not IMHO break the whole process of selection but rather mark as selectable all "private" (random) addresses. And it should rather be done before rule 6.
Quoted 5 lines
Hmm? We do not have such intention.
In above case, when you connect to 2001:200:0:8002:203:47ff:fea5:3085, either 2002:531f:d667:face:EUI64 or 2002:531f:d667:face::RANDOM should be selected (depending on ifuse_tempaddr>= 2),
by the longest matching rule (Rule 8).
I've chewd the code line by line and it tastes like it should work the way you say... OK I see the problem. I've used ifconfig which doesn't show "deprecated" flag and "valid"/"prefered" times which, combined with "privacy", *seem* to cause some problems . I don't know yet if it is a problem of proper intervals in radvd.conf or is there still a bug in kernel. I'll let you know when I learn it.
OK. That's enough for now. Let me get back to the real work ;-)
Best regards.
Signature · 1 line
Było mi bardzo miło. Czwarta pospolita klęska, [...]
Quoted 1 line
Łukasz< Już nie katolicka lecz złodziejska. (c)PP