summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-10 03:47:10 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-10 03:47:10 +0000
commit08b3a446e59aad15a30b7ee5246572c8eb7c84a5 (patch)
tree4e392e8e4e5f0ff17dae6f3dcaa80da0559921b0
parent989f5a1e6fc2074158456e70529002cb5e4d29d0 (diff)
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
-rw-r--r--test/socket/test_socket.rb34
1 files changed, 26 insertions, 8 deletions
diff --git a/test/socket/test_socket.rb b/test/socket/test_socket.rb
index 2dfc08a34c4..f46f4df206d 100644
--- a/test/socket/test_socket.rb
+++ b/test/socket/test_socket.rb
@@ -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