2011/7/28 Jeremy Evans <merch-redmine / jeremyevans.net>:

>  The issue is that Socket.ip_address_list and Addrinfo.foreach return dif=
ferent things.
>
>    $ ruby19 -rsocket -e 'p Socket.ip_address_list'
>    [#<Addrinfo: ::1>, #<Addrinfo: fe80::1%lo0>, #<Addrinfo: 127.0.0.1>, #=
<Addrinfo: 192.168.1.4>, #<Addrinfo: fe80::92fb:a6ff:feed:afa1%re0>]
>    $ ruby19 -rsocket -e 'Addrinfo.foreach(nil, 0, nil, :DGRAM, nil, Socke=
t::AI_PASSIVE) {|ai| p ai}'
>    #<Addrinfo: :: UDP>
>    #<Addrinfo: 0.0.0.0 UDP>

It is not a problem.  GNU/Linux also behaves as so.

GNU/Linux%  ./ruby -rsocket -e 'p Socket.ip_address_list'
[#<Addrinfo: 127.0.0.1>, #<Addrinfo: 221.186.184.67>, #<Addrinfo:
::1>, #<Addrinfo: fe80::216:3eff:fe95:88bb%eth1>]
GNU/Linux% ./ruby -rsocket -e 'Addrinfo.foreach(nil, 0, nil, :DGRAM,
nil, Socket::AI_PASSIVE) {|ai| p ai}'
#<Addrinfo: :: UDP>
#<Addrinfo: 0.0.0.0 UDP>

>  I can see where it wouldn't support dynamic IP address change.  But it a=
lso doesn't listen on all local addresses (#<Addrinfo: fe80::92fb:a6ff:feed=
:afa1%re0> in this case), and that fails one of the tests.  So either the t=
est needs to be changed to not require that behavior or the code needs to b=
e change to listen on all local addresses in addition to listening on '::' =
in the ipv6_recvpktinfo case.

If IPV6_PKTINFO is usable, we don't need to listen all addresses
because we can detect the destination address of a incoming packet
using pktinfo.
(The address is used later to reply from the address.)

My intent is follows.

* If IPV6_PKTINFO is usable, listen only "::" (for IPv6).
  The destination address is detected by pktinfo.
  This way can handle dynamic IP change.
* If IPV6_PKTINFO is not usable, listen all local IPv6 addresses.
  The destination address is detected by the socket.
  This way doesn't support dynamic IP change, though.

I can't understand why OpenBSD fails the test.
--=20
Tanaka Akira