Skip IPv6 addresses whose interface is set as IFDISABLED.

FreeBSD 9.0 with default setting (ipv6_activate_all_interfaces
is not YES) sets IFDISABLED to interfaces which don't have
global IPv6 address.
Link-local IPv6 addresses on those interfaces don't work.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2012-05-10 03:47:10 +00:00
Родитель 989f5a1e6f
Коммит 08b3a446e5
1 изменённых файлов: 26 добавлений и 8 удалений

Просмотреть файл

@ -307,8 +307,32 @@ class TestSocket < Test::Unit::TestCase
Socket.udp_server_sockets(0) {|sockets|
famlies = {}
sockets.each {|s| famlies[s.local_address.afamily] = true }
ip_addrs.reject! {|ai| !famlies[ai.afamily] }
sockets.each {|s| famlies[s.local_address.afamily] = s }
ip_addrs.reject! {|ai|
s = famlies[ai.afamily]
next true unless s
case RUBY_PLATFORM
when /linux/
if ai.ip_address.include?('%') and
(`uname -r`[/[0-9.]+/].split('.').map(&:to_i) <=> [2,6,18]) <= 0
# Cent OS 5.6 (2.6.18-238.19.1.el5xen) doesn't correctly work
# sendmsg with pktinfo for link-local ipv6 addresses
next true
end
when /freebsd/
if ifr_name = ai.ip_address[/%(.*)/, 1]
# FreeBSD 9.0 with default setting (ipv6_activate_all_interfaces
# is not YES) sets IFDISABLED to interfaces which don't have
# global IPv6 address.
# Link-local IPv6 addresses on those interfaces don't work.
ulSIOCGIFINFO_IN6 = 3225971052
bIFDISABLED = 4
in6_ifreq = ifr_name
s.ioctl(ulSIOCGIFINFO_IN6, in6_ifreq)
next true if in6_ifreq.unpack('A16L6').last[bIFDISABLED-1] == 1
end
end
}
skipped = false
begin
port = sockets.first.local_address.ip_port
@ -322,12 +346,6 @@ class TestSocket < Test::Unit::TestCase
}
ip_addrs.each {|ai|
if /linux/ =~ RUBY_PLATFORM && ai.ip_address.include?('%') &&
(`uname -r`[/[0-9.]+/].split('.').map(&:to_i) <=> [2,6,18]) <= 0
# Cent OS 5.6 (2.6.18-238.19.1.el5xen) doesn't correctly work
# sendmsg with pktinfo for link-local ipv6 addresses
next
end
Addrinfo.udp(ai.ip_address, port).connect {|s|
msg1 = "<<<#{ai.inspect}>>>"
s.sendmsg msg1