Skip Menu |

This queue is for tickets about the IO-Socket-INET6 CPAN distribution.

Report information
The Basics
Id: 97874
Status: open
Priority: 0/
Queue: IO-Socket-INET6

People
Owner: Nobody in particular
Requestors: Torsten.Werner [...] assyst.de
Cc: oleg [...] cpan.org
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Problem with local IPv6 and remote IPv4 address
Date: Fri, 8 Aug 2014 14:04:35 +0200
To: bug-IO-Socket-INET6 [...] rt.cpan.org
From: torsten.werner [...] assyst.de
Hi, I'm watching problems with activated IPv6 in my LAN and IPv4 connection to remote side. I use Windows7 with active IPv6. When I install IO::Socket::IPv6 I've no chance to connect CPAN by "perl -MCPAN -e shell", to use "Email::Sender" to connect external mail servers and I've lots of other restrictions. What happens is the following: IO::Socket::INET6::configure is called with LocalAddr => undef inside the args argument. $arg->{Domain} is not existent The remote host has an IPv4 address only. In the following code the local address is set to '::': if ($^O eq 'MSWin32') { if ((!$laddr) && (!$lport)) { $laddr = ($family == AF_INET) ? '0.0.0.0' : '::'; $lport = ''; } elsif (!$lport) { $lport = ''; } } This is not so nice, because later on is the local address used for getaddrinfo, and this will return an array with IPv6 family only. The loop to find local and remote pairs with the same family will never get a matching pair. The configure function returns a object which is not connected. Unfortunately there is no error/warning message when we have no getaddrinfo results with the same family. I made a small fix for me in version 2.72; 1) delete lines 187 and 188 with content: my @lres = getaddrinfo($laddr,$lport,$family,$type,$proto,AI_PASSIVE); return _error($sock, $EINVAL, "getaddrinfo: $lres[0]") if @lres<5; 2) replace lines 164 until 174 with content: if ($^O eq 'MSWin32') { if ((!$laddr) && (!$lport)) { $laddr = ($family == AF_INET) ? '0.0.0.0' : '::'; $lport = ''; } elsif (!$lport) { $lport = ''; } } my $type = $arg->{Type} || $socket_type{(getprotobynumber($proto))[0]}; by the following code: if ($^O eq 'MSWin32') { if ((!$laddr) && (!$lport)) { $lport = ''; if ($family == AF_INET) { $laddr="0.0.0.0"; @lres = getaddrinfo($laddr,$lport,$family,$type,$proto,AI_PASSIVE); return _error($sock, $EINVAL, "getaddrinfo: @lres[0]") if @lres<5; } elsif ($family == AF_INET6) { $laddr="::"; @lres = getaddrinfo($laddr,$lport,$family,$type,$proto,AI_PASSIVE); return _error($sock, $EINVAL, "getaddrinfo: @lres[0]") if @lres<5; } else { my @lres_v4 = getaddrinfo("0.0.0.0",$lport,$family,$type,$proto,AI_PASSIVE); my @lres_v6 = getaddrinfo("::",$lport,$family,$type,$proto,AI_PASSIVE); push @lres, @lres_v4 if @lres_v4 > 4; push @lres, @lres_v6 if @lres_v6 > 4; return _error($sock, $EINVAL, "getaddrinfo: @lres_v4[0], @lres_v6[0]") if @lres<5; } } elsif (!$lport) { $lport = ''; } } else { @lres = getaddrinfo($laddr,$lport,$family,$type,$proto,AI_PASSIVE); return _error($sock, $EINVAL, "getaddrinfo: @lres[0]") if @lres<5; } Bye Torsten
This was great, but there were a number of errors. Everywhere you see something like @var_name[0], change the @ sigil to $. For example change @lres_v6[0] in the solution to $lres_v6[0]. Thanks. This was killing Net::NTP. Probably other things that rely on INET6.
Subject: [rt.cpan.org #97874]
Date: Mon, 11 Aug 2014 13:12:56 +0200
To: bug-IO-Socket-INET6 [...] rt.cpan.org
From: torsten.werner [...] assyst.de
Hi, I think I was a little bit too fast with my small fix. When you use the example, have a look to call getaddrinfo when: - we have Win32 and a local address but no local port - we have Win32, a local address and a local port Bye Torsten
Hi, I think this issue is growing like a snowball affecting other modules :-( See for example this https://rt.cpan.org/Ticket/Display.html?id=93122 or this http://www.nntp.perl.org/group/perl.par/2014/12/msg5886.html In both examples, the workaround is to avoid the usage of INET6 assuming the loss of its features. I hope someone has time to take a look... Thanks, Peco On Mon Aug 11 07:13:03 2014, Torsten.Werner@assyst.de wrote: Show quoted text
> Hi, > I think I was a little bit too fast with my small fix. > When you use the example, have a look to call getaddrinfo when: > - we have Win32 and a local address but no local port > - we have Win32, a local address and a local port > Bye > Torsten
On Mon Aug 11 07:13:03 2014, Torsten.Werner@assyst.de wrote: Show quoted text
> Hi, > I think I was a little bit too fast with my small fix. > When you use the example, have a look to call getaddrinfo when: > - we have Win32 and a local address but no local port > - we have Win32, a local address and a local port > Bye > Torsten
Can you provide a patch or a pull request against https://bitbucket.org/shlomif/perl-io-socket-inet6 ? I should also note that in general using https://metacpan.org/release/IO-Socket-IP is preferable over I-S-INET6. Regards, -- Shlomi Fish
On Tue Dec 16 08:01:12 2014, SHLOMIF wrote: Show quoted text
> On Mon Aug 11 07:13:03 2014, Torsten.Werner@assyst.de wrote:
> > Hi, > > I think I was a little bit too fast with my small fix. > > When you use the example, have a look to call getaddrinfo when: > > - we have Win32 and a local address but no local port > > - we have Win32, a local address and a local port > > Bye > > Torsten
> > Can you provide a patch or a pull request against > https://bitbucket.org/shlomif/perl-io-socket-inet6 ? I should also > note that in general using https://metacpan.org/release/IO-Socket-IP > is preferable over I-S-INET6. > > Regards, > > -- Shlomi Fish
Don't know why this check for win32 was added. But without it all works as expected. I tested it on windows XP and windows 7 with this test script: use strict; use lib 'IO-Socket-INET6-2.72/lib/'; use IO::Socket::INET6; my $sock = IO::Socket::INET6->new(PeerAddr => 'cpan.org', PeerPort => 80) or die $@; $sock->syswrite("GET / HTTP/1.1\r\n") or die $!; warn "connected successfully"; __END__ Before patch: windows XP: getaddrinfo: Unknown host at t.pl line 5. windows 7: Bad file descriptor at t.pl line 8. After patch: windows XP: connected successfully at t.pl line 9. windows 7: connected successfully at t.pl line 9. I also added @flr check in this patch, so it will return error when no appropriate address found
Subject: no-laddr-check-win32.patch
--- lib/IO/Socket/INET6.pm.orig 2015-01-07 22:47:55.889962846 +0600 +++ lib/IO/Socket/INET6.pm 2015-01-07 22:56:03.484346578 +0600 @@ -158,18 +158,6 @@ $lport ||= 0; $proto ||= (getprotobyname('tcp'))[2]; - - # MSWin32 expects at least one of $laddr or $lport to be specified - # and does not accept 0 for $lport if $laddr is specified. - if ($^O eq 'MSWin32') { - if ((!$laddr) && (!$lport)) { - $laddr = ($family == AF_INET) ? '0.0.0.0' : '::'; - $lport = ''; - } elsif (!$lport) { - $lport = ''; - } - } - my $type = $arg->{Type} || $socket_type{(getprotobynumber($proto))[0]}; # parse Peer* @@ -212,6 +200,10 @@ push @flr,[ $fam_listen,$lsockaddr ]; } } + + if (@rres && !@flr) { + return _error($sock, $EINVAL, "no addresses for appropriate IP protocol found"); + } # try to bind and maybe connect # if multihomed try all combinations until success
Dear Oleg, On Wed Jan 07 12:09:10 2015, OLEG wrote: Show quoted text
> On Tue Dec 16 08:01:12 2014, SHLOMIF wrote:
> > On Mon Aug 11 07:13:03 2014, Torsten.Werner@assyst.de wrote:
> > > Hi, > > > I think I was a little bit too fast with my small fix. > > > When you use the example, have a look to call getaddrinfo when: > > > - we have Win32 and a local address but no local port > > > - we have Win32, a local address and a local port > > > Bye > > > Torsten
> > > > Can you provide a patch or a pull request against > > https://bitbucket.org/shlomif/perl-io-socket-inet6 ? I should also > > note that in general using https://metacpan.org/release/IO-Socket-IP > > is preferable over I-S-INET6. > > > > Regards, > > > > -- Shlomi Fish
> > Don't know why this check for win32 was added. But without it all > works as expected. I tested it on windows XP and windows 7 with this > test script:
After consulting Paul Evans ( https://metacpan.org/author/PEVANS ; a.k.a "LeoNerd" - maintainer of https://metacpan.org/pod/IO::Socket::IP ), I decided to quit maintaining IO-Socket-INET6, because: 1. IO-Socket-IP is now more recommended. 2. I lack the necessary knowledge and expertise to maintain IO-Socket-INET6. If you or anyone else wish to maintain it, please write to modules@perl.org with a COMAINT request. Regards, -- Shlomi Fish
On Fri Jan 09 09:29:08 2015, SHLOMIF wrote: Show quoted text
> Dear Oleg, > > On Wed Jan 07 12:09:10 2015, OLEG wrote:
> > On Tue Dec 16 08:01:12 2014, SHLOMIF wrote:
> > > On Mon Aug 11 07:13:03 2014, Torsten.Werner@assyst.de wrote:
> > > > Hi, > > > > I think I was a little bit too fast with my small fix. > > > > When you use the example, have a look to call getaddrinfo when: > > > > - we have Win32 and a local address but no local port > > > > - we have Win32, a local address and a local port > > > > Bye > > > > Torsten
> > > > > > Can you provide a patch or a pull request against > > > https://bitbucket.org/shlomif/perl-io-socket-inet6 ? I should also > > > note that in general using https://metacpan.org/release/IO-Socket- > > > IP > > > is preferable over I-S-INET6. > > > > > > Regards, > > > > > > -- Shlomi Fish
> > > > Don't know why this check for win32 was added. But without it all > > works as expected. I tested it on windows XP and windows 7 with this > > test script:
> > After consulting Paul Evans ( https://metacpan.org/author/PEVANS ; > a.k.a "LeoNerd" - maintainer of > https://metacpan.org/pod/IO::Socket::IP ), I decided to quit > maintaining IO-Socket-INET6, because: > > 1. IO-Socket-IP is now more recommended. > > 2. I lack the necessary knowledge and expertise to maintain IO-Socket- > INET6. > > If you or anyone else wish to maintain it, please write to > modules@perl.org with a COMAINT request. > > Regards, > > -- Shlomi Fish
Not a good news, because many modules on CPAN now uses IO::Socket::INET6 for ipv6 support including libnet and LWP. Can you merge my pull request (https://bitbucket.org/shlomif/perl-io-socket-inet6/pull-request/1/several-fixes-for-bugs-from-rt-queue) and make new release for a last time?
On Fri Jan 09 10:24:29 2015, OLEG wrote: Show quoted text
> On Fri Jan 09 09:29:08 2015, SHLOMIF wrote:
> > Dear Oleg, > > > > On Wed Jan 07 12:09:10 2015, OLEG wrote:
> > > On Tue Dec 16 08:01:12 2014, SHLOMIF wrote:
> > > > On Mon Aug 11 07:13:03 2014, Torsten.Werner@assyst.de wrote:
> > > > > Hi, > > > > > I think I was a little bit too fast with my small fix. > > > > > When you use the example, have a look to call getaddrinfo when: > > > > > - we have Win32 and a local address but no local port > > > > > - we have Win32, a local address and a local port > > > > > Bye > > > > > Torsten
> > > > > > > > Can you provide a patch or a pull request against > > > > https://bitbucket.org/shlomif/perl-io-socket-inet6 ? I should > > > > also > > > > note that in general using https://metacpan.org/release/IO- > > > > Socket- > > > > IP > > > > is preferable over I-S-INET6. > > > > > > > > Regards, > > > > > > > > -- Shlomi Fish
> > > > > > Don't know why this check for win32 was added. But without it all > > > works as expected. I tested it on windows XP and windows 7 with > > > this > > > test script:
> > > > After consulting Paul Evans ( https://metacpan.org/author/PEVANS ; > > a.k.a "LeoNerd" - maintainer of > > https://metacpan.org/pod/IO::Socket::IP ), I decided to quit > > maintaining IO-Socket-INET6, because: > > > > 1. IO-Socket-IP is now more recommended. > > > > 2. I lack the necessary knowledge and expertise to maintain IO- > > Socket- > > INET6. > > > > If you or anyone else wish to maintain it, please write to > > modules@perl.org with a COMAINT request. > > > > Regards, > > > > -- Shlomi Fish
> > > Not a good news, because many modules on CPAN now uses > IO::Socket::INET6 for ipv6 support including libnet and LWP. Can you > merge my pull request (https://bitbucket.org/shlomif/perl-io-socket- > inet6/pull-request/1/several-fixes-for-bugs-from-rt-queue) and make > new release for a last time?
I cannot because I already gave up the COMAINT status on IO-Socket-INET6. The modules that use it should really be converted to IO-Socket-IP. Regards, -- Shlomi Fish
On Fri Jan 09 10:42:29 2015, SHLOMIF wrote: Show quoted text
> On Fri Jan 09 10:24:29 2015, OLEG wrote:
> > On Fri Jan 09 09:29:08 2015, SHLOMIF wrote:
> > > Dear Oleg, > > > > > > On Wed Jan 07 12:09:10 2015, OLEG wrote:
> > > > On Tue Dec 16 08:01:12 2014, SHLOMIF wrote:
> > > > > On Mon Aug 11 07:13:03 2014, Torsten.Werner@assyst.de wrote:
> > > > > > Hi, > > > > > > I think I was a little bit too fast with my small fix. > > > > > > When you use the example, have a look to call getaddrinfo > > > > > > when: > > > > > > - we have Win32 and a local address but no local port > > > > > > - we have Win32, a local address and a local port > > > > > > Bye > > > > > > Torsten
> > > > > > > > > > Can you provide a patch or a pull request against > > > > > https://bitbucket.org/shlomif/perl-io-socket-inet6 ? I should > > > > > also > > > > > note that in general using https://metacpan.org/release/IO- > > > > > Socket- > > > > > IP > > > > > is preferable over I-S-INET6. > > > > > > > > > > Regards, > > > > > > > > > > -- Shlomi Fish
> > > > > > > > Don't know why this check for win32 was added. But without it all > > > > works as expected. I tested it on windows XP and windows 7 with > > > > this > > > > test script:
> > > > > > After consulting Paul Evans ( https://metacpan.org/author/PEVANS ; > > > a.k.a "LeoNerd" - maintainer of > > > https://metacpan.org/pod/IO::Socket::IP ), I decided to quit > > > maintaining IO-Socket-INET6, because: > > > > > > 1. IO-Socket-IP is now more recommended. > > > > > > 2. I lack the necessary knowledge and expertise to maintain IO- > > > Socket- > > > INET6. > > > > > > If you or anyone else wish to maintain it, please write to > > > modules@perl.org with a COMAINT request. > > > > > > Regards, > > > > > > -- Shlomi Fish
> > > > > > Not a good news, because many modules on CPAN now uses > > IO::Socket::INET6 for ipv6 support including libnet and LWP. Can you > > merge my pull request (https://bitbucket.org/shlomif/perl-io-socket- > > inet6/pull-request/1/several-fixes-for-bugs-from-rt-queue) and make > > new release for a last time?
> > I cannot because I already gave up the COMAINT status on IO-Socket- > INET6. The modules that use it should really be converted to IO- > Socket-IP. > > Regards, > > -- Shlomi Fish
Ok, I sent request to modules@perl.org