TritonDataCenter / smartos-live

For more information, please see http://smartos.org/ For any questions that aren't answered there, please join the SmartOS discussion list: https://smartos.topicbox.com/groups/smartos-discuss
1.57k stars 246 forks source link

Perl won't listen on IPv6 with newer platform #853

Closed wiedi closed 4 years ago

wiedi commented 5 years ago

After updating to release joyent_20191009T235451Z our perl services won't listen on IPv6 anymore. It works fine on joyent_20190815T002608Z. I have not yet tested releases inbetween.

A small reproducer is: perl -e 'use base qw(Net::Server); main->run(host => "*")'

Good output on joyent_20190815T002608Z:

# perl -e 'use base qw(Net::Server); main->run(host => "*")'
2019/10/16-12:54:27 main (type Net::Server) starting! pid(8970)
Resolved [*]:20203 to [::]:20203, IPv6
Not including resolved host [0.0.0.0] IPv4 because it should be handled by [::] IPv6
Binding to TCP port 20203 on host :: with IPv6
Group Not Defined.  Defaulting to EGID '0 0 1 2 3 4 5 6 7 9 12'
User Not Defined.  Defaulting to EUID '0'
^C2019/10/16-12:54:32 Server closing!

Bad output on joyent_20191009T235451Z:

# perl -e 'use base qw(Net::Server); main->run(host => "*")'
2019/10/16-12:55:01 main (type Net::Server) starting! pid(29216)
Resolved [*]:20203 to [0.0.0.0]:20203, IPv4
Host [*] resolved to IPv6 address [::] but IO::Socket::INET6->new fails: Address family not supported by protocol family at /opt/local/lib/perl5/vendor_perl/5.28.0/Net/Server/Proto.pm line 138.
Binding to TCP port 20203 on host 0.0.0.0 with IPv4
Group Not Defined.  Defaulting to EGID '0 0 1 2 3 4 5 6 7 9 12'
User Not Defined.  Defaulting to EUID '0'
^C2019/10/16-12:55:04 Server closing!

Using truss the relevant difference looks like that:

ok:

...
so_socket(PF_INET6, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP, 0x00000000, SOV_DEFAULT) = 4
fcntl(4, F_GETFD, 0x00000004)           = 1
...
setsockopt(4, SOL_SOCKET, SO_REUSEADDR, 0xFFFFFD7FFFDFF540, 4, SOV_DEFAULT) = 0
listen(4, 1, SOV_DEFAULT)           = 0
...

broken:

...
so_socket(PF_INET6, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP, 0x00000000, SOV_DEFAULT) = 4
fcntl(4, F_GETFD, 0xFFFFFE5984B3B860)       = 1
...
setsockopt(4, SOL_SOCKET, SO_REUSEADDR, 0xFFFFFC7FFFDFF610, 4, SOV_DEFAULT) = 0
listen(4, 1, SOV_DEFAULT)           Err#124 EAFNOSUPPORT
...

In both cases the same perl from pkgsrc is used:

This is perl 5, version 24, subversion 0 (v5.24.0) built for x86_64-solaris-thread-multi-64

As a workaround it is possible to specify a fixed address instead of "*".

danmcd commented 4 years ago

Dumb question: native or LX zone?

wiedi commented 4 years ago

native

danmcd commented 4 years ago

I ask because, AFAICT, the only differences between those two releases don't touch anything there unless you're in LX.

The only major change in TCP/IP that MIGHT affect you is the addition of flexible congestion-control algorithms, which shouldn't touch SO_REUSEADDR at all.

Is it possible for you to try this perl binary on a very-latest OmniOS bloody, or OI Hipster (and for comparison, on OmniOS r151030? I'll be VERY curious if you get the same results. I tried the one-line Perl on my own OmniOS bloody VM, but I got some weird Perl library errors. ("Base class package "Net::Server" is empty.")

sjorge commented 4 years ago

Was’t there some perl 64-bit vs 32-but changes recently? (Atleast upstream)

Only perl change that comes to my mind in recent history

wiedi commented 4 years ago

Installing the missing package with pkgin install p5-Net-Server should fix the is empty error. I think there is also the gcc7 change between those releases.

Things are a bit busy currently, which is why I wanted to file this before I forgot about it. I'll try to find some time to look more closely at it and also test on a non-SmartOS distro.

wiedi commented 4 years ago

Just tested with 20190829T000927Z and it's also broken. So it must have come in with that release.

jlevon commented 4 years ago

I can reproduce this on current-ish OI. I've moved this issue over to https://www.illumos.org/issues/11849