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 -