From: Tanaka Akira Date: 2011-07-28T12:38:48+09:00 Subject: [ruby-core:38573] Re: [Ruby 1.9 - Feature #5097] Supported platforms of Ruby 1.9.3 2011/7/28 Jeremy Evans : >> > * ext/socket/lib/socket.rb: Don't check ipv6_recvpktinfo. This fixes a failure in one of the socket tests: >> >> Why this fixes the problem? >> We can't merge this without understanding. > > I think this is a general bug in the code. If ipv6_recvpktinfo is true (which it is on OpenBSD since OpenBSD supports IPV6_PKTINFO), the Addrinfo for IPV6 address "::" is not added as a socket to use. The code looks like this: > > 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 } > > 527 sockets = ip_sockets_port0(ip_list, false) > > 544 pktinfo_sockets = {} > 545 sockets.each {|s| > 546 ai = s.local_address > 547 if ipv6_recvpktinfo && ai.ipv6? && ai.ip_address == "::" > 548 s.setsockopt(:IPV6, ipv6_recvpktinfo, 1) > 549 pktinfo_sockets[s] = true > 550 end > 551 } > > 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. 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.) -- Tanaka Akira