Skip Menu |

This queue is for tickets about the Net-TFTPd CPAN distribution.

Report information
The Basics
Id: 116176
Status: resolved
Worked: 30 min
Priority: 0/
Queue: Net-TFTPd

People
Owner: VINSWORLD [...] cpan.org
Requestors: Vegard.Vesterheim [...] uninett.no
Cc:
AdminCc:

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



Subject: Allow dualstack (IPv4/IPv6) operation on supported platforms without explicitly opening 2 sockets
Date: Fri, 15 Jul 2016 13:21:15 +0200
To: bug-Net-TFTPd [...] rt.cpan.org
From: Vegard Vesterheim <vegard.vesterheim [...] uninett.no>
This issue is somewhat related to #100285 I use Net::TFTPd to implement a simple TFTP server. Originally I wanted to enable IPv6-only operation. Now I would now like to support *both* IPv4 and IPv6, without explicitly opening two sockets, since this is natively supported in Linux. In Linux, this flag defaults to 0 (false): $ cat /proc/sys/net/ipv6/bindv6only 0 The code in Net::TFTPd explicitly disables this possibility: if ($^O ne 'MSWin32') { $params{'V6Only'} = 1; } Basically, I would like to allow the option 'V6Only' to be a parameter. (Which could default to 1 (true) on Windows). From the IO::Socket::IP man-page: ----- snip - snip ------------------------------------------------- V6Only => BOOL If defined, set the "IPV6_V6ONLY" sockopt when creating "PF_INET6" sockets to the given value. If true, a listening-mode socket will only listen on the "AF_INET6" addresses; if false it will also accept connections from "AF_INET" addresses. If not defined, the socket option will not be changed, and default value set by the operating system will apply. For repeatable behaviour across platforms it is recommended this value always be defined for listening- mode sockets. Note that not all platforms support disabling this option. Some, at least OpenBSD and MirBSD, will fail with "EINVAL" if you attempt to disable it. To determine whether it is possible to disable, you may use the class method if( IO::Socket::IP->CAN_DISABLE_V6ONLY ) { ... } else { ... } If your platform does not support disabling this option but you still want to listen for both "AF_INET" and "AF_INET6" connections you will have to create two listening sockets, one bound to each protocol. ----- snip - snip ------------------------------------------------- -- - Vegard V -
The issue on Windows is that this flag cannot be set at all. Simply including the flag 'V6Only' regardless of how it is set (0 | 1) will result in error on Windows: Your vendor has not defined Socket macro IPV6_V6ONLY, used at C:/strawberry/perl /site/lib/IO/Socket/IP.pm line 613 My thinking is to include it as an option to the constructor: my $tftpd = Net::TFTPd->new( RootDir => '.', Family => 'ipv6', V6Only => 0 ); This way if you want to include it you can, but it must be explicitly enabled / disabled. By default, specifying 'ipv6' family should open only an IPv6 socket. If you want both, and your OS supports it, you'll be able to use the 'V6Only => 0' option to the constructor. This works as tested on Windows and won't break current backward compatible operation. Look for fix in Version 0.10. Cheers.
Uploaded version 0.10 to CPAN.