Bug #6692

TestSocket::test_udp_server always fails on OS X with Back to my Mac enabled

Added by Eric Hodel about 3 years ago. Updated almost 3 years ago.

[ruby-core:46159]
Status:Closed
Priority:Normal
Assignee:Eric Hodel
ruby -v:- Backport:

Description

=begin
OS X ships with a feature to create a VPN between all your Mac computers.

This creates an extra utun interface for the tunnel and a unique local IPv6 unicast addresses on the loopback interface:

lo0: flags=8049 mtu 16384
options=3
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fd92:5aed:a1b2:7539:129a:ddff:fe49:be28 prefixlen 128

(I have invalidated this address)

test_udp_server discovers the addresses for the local machine and attempts to send a UDP message to them. Unfortunately the Back to my Mac address does not respond to any communication:

$ ping6 -c 10 fd92:5aed:a1b2:7539:129a:ddff:fe49:be28
PING6(56=40+8+8 bytes) fd92:5aed:a1b2:7539:129a:ddff:fe49:be28 --> fd92:5aed:a1b2:7539:129a:ddff:fe49:be28

--- fd92:5aed:a1b2:7539:129a:ddff:fe49:be28 ping6 statistics ---
10 packets transmitted, 0 packets received, 100.0% packet loss

So the test always fails:

$ make test-all TESTS='socket -n test_udp_server'
[…]
# Running tests:

[1/1] TestSocket#test_udp_server = 10.01 s
1) Error:
test_udp_server(TestSocket):
RuntimeError: no response from #
/Users/drbrain/Work/svn/ruby/trunk/test/socket/test_socket.rb:375:in block (3 levels) in test_udp_server'
/Users/drbrain/Work/svn/ruby/trunk/.ext/common/socket.rb:68:in
connect_internal'
/Users/drbrain/Work/svn/ruby/trunk/.ext/common/socket.rb:135:in connect'
/Users/drbrain/Work/svn/ruby/trunk/test/socket/test_socket.rb:371:in
block (2 levels) in test_udp_server'
/Users/drbrain/Work/svn/ruby/trunk/test/socket/test_socket.rb:370:in each'
/Users/drbrain/Work/svn/ruby/trunk/test/socket/test_socket.rb:370:in
block in test_udp_server'
/Users/drbrain/Work/svn/ruby/trunk/.ext/common/socket.rb:628:in udp_server_sockets'
/Users/drbrain/Work/svn/ruby/trunk/test/socket/test_socket.rb:309:in
test_udp_server'

Finished tests in 10.021782s, 0.0998 tests/s, 0.3991 assertions/s.
1 tests, 4 assertions, 0 failures, 1 errors, 0 skips

ruby -v: ruby 2.0.0dev (2012-07-04 trunk 36295) [x86_64-darwin11.4.0]

I'm unsure how to filter the Back to my Mac address to allow this test to pass.

To reproduce this test failure, get a Mac and enable Back to my Mac in the iCloud (10.7) or MobileMe (10.6 and earlier) preference pane, then run:

make test-all TESTS='socket -n test_udp_server'

=end

socket.ipv6_unique_local_address.bug_6692.patch Magnifier (2.5 KB) Eric Hodel, 07/10/2012 05:46 AM


Related issues

Related to Ruby trunk - Bug #5151: test/socket/test_socket.rb fail when udp connection failed Closed 08/03/2011

Associated revisions

Revision 36474
Added by Eric Hodel about 3 years ago

  • ext/socket/raddrinfo.c (addrinfo_ipv6_unique_local_p): Added Addrinfo#ipv6_unique_local? to detect RFC 4193 unique local addresses. Part of #6692
  • ext/socket/rubysocket.h: Add IN6_IS_ADDR_UNIQUE_LOCAL macro if missing.
  • test/socket/test_addrinfo.rb: Test for ipv6_unqiue_local?

Revision 36474
Added by Eric Hodel about 3 years ago

  • ext/socket/raddrinfo.c (addrinfo_ipv6_unique_local_p): Added Addrinfo#ipv6_unique_local? to detect RFC 4193 unique local addresses. Part of #6692
  • ext/socket/rubysocket.h: Add IN6_IS_ADDR_UNIQUE_LOCAL macro if missing.
  • test/socket/test_addrinfo.rb: Test for ipv6_unqiue_local?

Revision 36475
Added by Eric Hodel about 3 years ago

  • test/socket/test_socket.rb: Ignore IPv6 unique local addresses on OS X (iCloud Back to my Mac addresses) for test_udp_socket since they do not act as loopback addresses. [Bug #6692]

Revision 36475
Added by Eric Hodel about 3 years ago

  • test/socket/test_socket.rb: Ignore IPv6 unique local addresses on OS X (iCloud Back to my Mac addresses) for test_udp_socket since they do not act as loopback addresses. [Bug #6692]

Revision 37033
Added by Yui NARUSE almost 3 years ago

Darwin 12 (OS X Mountain Lion) also has Bug #6692

Revision 37033
Added by Yui NARUSE almost 3 years ago

Darwin 12 (OS X Mountain Lion) also has Bug #6692

Revision 37035
Added by Yui NARUSE almost 3 years ago

Revert "Darwin 12 (OS X Mountain Lion) also has Bug #6692"

This reverts commit r37033.
darwin12 seems to use an address started with fe80.

Revision 37035
Added by Yui NARUSE almost 3 years ago

Revert "Darwin 12 (OS X Mountain Lion) also has Bug #6692"

This reverts commit r37033.
darwin12 seems to use an address started with fe80.

History

#1 Updated by Yui NARUSE about 3 years ago

I notice the existence of this issue for year but can't understand how to reproduce and fix.

Now your info, enabling iCloud, reproduces this, thanks!
But I still cannot understand the reason why ruby can't communicate with the address
though we can avoid this with a workaround: skip IPv6 addresses begin with fdXX on Mac OS X.

#2 Updated by Eric Hodel about 3 years ago

netstat says this about the iCloud route:

fd92::[…] link#1 UHL lo0

So there's no reason it shouldn't work that I can see.

I think skipping IPv6 addresses for fc00::/7 is the best solution.

The attached patch adds Addrinfo#ipv6_unique_local? and uses it in test_udp_server

Since the C macro has an underscore before local (unlike LINKLOCAL) I placed it in the ruby method as well.

#3 Updated by Yui NARUSE about 3 years ago

drbrain (Eric Hodel) wrote:

netstat says this about the iCloud route:

fd92::[…] link#1 UHL lo0

So there's no reason it shouldn't work that I can see.

I think skipping IPv6 addresses for fc00::/7 is the best solution.

The attached patch adds Addrinfo#ipv6_unique_local? and uses it in test_udp_server

Since the C macro has an underscore before local (unlike LINKLOCAL) I placed it in the ruby method as well.

It's ok if you separate changes to socket and test_udp_server,
and see version of darwin in the test.

#4 Updated by Yui NARUSE about 3 years ago

  • Status changed from Open to Assigned
  • Assignee set to Eric Hodel

#5 Updated by Eric Hodel about 3 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r36475.
Eric, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • test/socket/test_socket.rb: Ignore IPv6 unique local addresses on OS X (iCloud Back to my Mac addresses) for test_udp_socket since they do not act as loopback addresses. [Bug #6692]

Also available in: Atom PDF