Feature #5097
Supported platforms of Ruby 1.9.3
| Status: | Closed | Start date: | 07/26/2011 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 0% |
||
| Category: | - | |||
| Target version: | 1.9.3 |
Description
Related issues
Associated revisions
History
Updated by normalperson (Eric Wong) 10 months ago
Updated by jeremyevans0 (Jeremy Evans) 10 months ago
Updated by wyhaines (Kirk Haines) 10 months ago
Updated by kosaki (Motohiro KOSAKI) 10 months ago
Updated by kosaki (Motohiro KOSAKI) 10 months ago
Updated by steveklabnik (Steve Klabnik) 10 months ago
Updated by lucas (Lucas Nussbaum) 10 months ago
Updated by luislavena (Luis Lavena) 10 months ago
Updated by jeremyevans0 (Jeremy Evans) 10 months ago
- File ruby193.log added
- File ruby193.diff added
Updated by naruse (Yui NARUSE) 10 months ago
Updated by jeremyevans0 (Jeremy Evans) 10 months ago
- File ruby193.log added
- File ruby193.diff added
Updated by akr (Akira Tanaka) 10 months ago
Updated by jeremyevans0 (Jeremy Evans) 10 months ago
> > The pktinfo_sockets hash here is never used. And even if it was, because you are not adding the '::' address to ip_addrs if ipv6_recvpktinfo, no socket is being created for it, so you will +never hit lines 548-549. The attached patch removes the "&& !ipv6_recvpktinfo" from 516 and the pktinfo_sockets hash handling.
>
> Thank you for notifying pktinfo_sockets is not used.
>
> However I don't understand why ip_list doesn't contain '::' address on OpenBSD.
>
> 516 elsif ai.ipv6? && ai.ip_address == "::" && !ipv6_recvpktinfo
> 517 local_addrs.each {|a|
> 518 next if !a.ipv6?
> 519 ip_list << Addrinfo.new(a.to_sockaddr, :INET6, :DGRAM, 0);
> 520 }
> 521 else
> 522 ip_list << ai
> 523 end
>
> The line 522 should add '::' address to ip_list on platforms which supports IPV6_PKTINFO.
The issue is that Socket.ip_address_list and Addrinfo.foreach return different 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, Socket::AI_PASSIVE) {|ai| p ai}'
#<Addrinfo: :: UDP>
#<Addrinfo: 0.0.0.0 UDP>
> Your patch, removing "&& !ipv6_recvpktinfo", means we don't use IPV6_PKTINFO. It is not my intent. (and it doesn't supports dynamic IP address change.)
I can see where it wouldn't support dynamic IP address change. But it also 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 test needs to be changed to not require that behavior or the code needs to be change to listen on all local addresses in addition to listening on '::' in the ipv6_recvpktinfo case.
Updated by drbrain (Eric Hodel) 10 months ago
Updated by znz (Kazuhiro NISHIYAMA) 10 months ago
Updated by nobu (Nobuyoshi Nakada) 10 months ago
Updated by kosaki (Motohiro KOSAKI) 10 months ago
Updated by jeremyevans0 (Jeremy Evans) 10 months ago
Updated by kosaki (Motohiro KOSAKI) 10 months ago
Updated by jeremyevans0 (Jeremy Evans) 10 months ago
Updated by jeremyevans0 (Jeremy Evans) 10 months ago
Updated by jeremyevans0 (Jeremy Evans) 10 months ago
Updated by normalperson (Eric Wong) 10 months ago
Updated by jeremyevans0 (Jeremy Evans) 10 months ago
Updated by naruse (Yui NARUSE) 10 months ago
Updated by akr (Akira Tanaka) 10 months ago
Updated by jeremyevans0 (Jeremy Evans) 10 months ago
- File ruby193.diff added
Updated by jeremyevans0 (Jeremy Evans) 10 months ago
Updated by akr (Akira Tanaka) 10 months ago
Updated by jeremyevans0 (Jeremy Evans) 10 months ago
- File ipv6_recvpktinfo_test.rb added
It appears that OpenBSD has the correct behavior without including the pktinfo argument. I'm attaching a test program. Here's two examples of usage and the output of each.
Without including pktinfo in the server's sendmsg call in response to the recvmsg:
$ ruby19 ipv6_recvpktinfo_test.rb fe80::92fb:a6ff:feed:afa1%re0 [:server_listening_on, #<Addrinfo: [::]:10000 UDP>] [:server_recvmsg_nonblock_output, "foo", #<Addrinfo: [fe80::92fb:a6ff:feed:afa1%re0]:3426 UDP>, [#<Socket::AncillaryData: INET6 IPV6 PKTINFO fe80::92fb:a6ff:feed:afa1 re0>]] [:server_response_sendmsg_args, ["oof", 0, #<Addrinfo: [fe80::92fb:a6ff:feed:afa1%re0]:3426 UDP>]] [:response_from_server, "oof", #<Addrinfo: [fe80::92fb:a6ff:feed:afa1%re0]:10000 UDP>]
Note in the last line of the output how the response received from the server uses the correct IPv6 address (fe80::92fb:a6ff:feed:afa1%re0 even though the server is listening on ::).
When including the pktinfo in the send message call, things break:
$ ruby19 ipv6_recvpktinfo_test.rb fe80::92fb:a6ff:feed:afa1%re0 pktinfo
[:server_listening_on, #<Addrinfo: [::]:10000 UDP>]
[:server_recvmsg_nonblock_output, "foo", #<Addrinfo: [fe80::92fb:a6ff:feed:afa1%re0]:23171 UDP>, [#<Socket::AncillaryData: INET6 IPV6 PKTINFO fe80::92fb:a6ff:feed:afa1 re0>]]
[:server_response_sendmsg_args, ["oof", 0, #<Addrinfo: [fe80::92fb:a6ff:feed:afa1%re0]:23171 UDP>, #<Socket::AncillaryData: INET6 IPV6 PKTINFO fe80::92fb:a6ff:feed:afa1 re0>]]
ipv6_recvpktinfo_test.rb:23:in `block in <main>': no response from #<Addrinfo: [fe80::92fb:a6ff:feed:afa1%re0]:10000 UDP> (RuntimeError)
from /usr/local/lib/ruby/1.9.1/socket.rb:45:in `connect_internal'
from /usr/local/lib/ruby/1.9.1/socket.rb:92:in `connect'
from ipv6_recvpktinfo_test.rb:21:in `<main>'Running tcpdump without the pktinfo argument shows no output, while running tcpdump with the pktinfo argument shows the following output:
16:28:55.962400 fe80::92fb:a6ff:feed:afa1.10000 > fe80::92fb:a6ff:feed:afa1.23171: [udp sum ok] udp 3 (len 11, hlim 64) tcpdump: WARNING: compensating for unaligned libpcap packets 16:28:55.962407 fe80::1 > fe80::92fb:a6ff:feed:afa1: icmp6: fe80::92fb:a6ff:feed:afa1 unreachable address (len 59, hlim 64)
Note how the response is not a UDP packet but an ICMP packet with an fe80::1 source address saying the response is unreachable. This is why the program times out, no UDP response is received.
So maybe there is a bug here, but OpenBSD supports the desired feature without the pktinfo argument in the sendmsg call. If the pktinfo argument is needed on other systems to work correctly, would you support a patch that adds the pktinfo argument to the sendmsg call unless /openbsd/ =~ RUBY_PLATFORM ?
Updated by akr (Akira Tanaka) 10 months ago
Updated by kosaki (Motohiro KOSAKI) 10 months ago
Updated by Anonymous 10 months ago
Updated by naruse (Yui NARUSE) 10 months ago
Updated by naruse (Yui NARUSE) 10 months ago
Updated by steveklabnik (Steve Klabnik) 10 months ago
Updated by jeremyevans0 (Jeremy Evans) 10 months ago
Updated by akr (Akira Tanaka) 10 months ago
Updated by jeremyevans0 (Jeremy Evans) 10 months ago
Updated by naruse (Yui NARUSE) 2 months ago
- Status changed from Assigned to Closed