Bug #77482 [Com]: Wont bind to IPv4 if IPv6 enabled

From: Date: Fri, 25 Jan 2019 05:56:11 +0000
Subject: Bug #77482 [Com]: Wont bind to IPv4 if IPv6 enabled
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219187@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77482&edit=1 ID: 77482 Comment by: ard_1 at mail dot ru Reported by: php at darkain dot com Summary: Wont bind to IPv4 if IPv6 enabled Status: Open Type: Bug Package: FPM related Operating System: FreeBSD PHP Version: 7.2 Block user comment: N Private report: N New Comment: Looking at the fpm_socket.c code and the comments in it I can see that some incorrect assumptions are being made. The current code is performing the following steps to bind to the TCP socket: ------- /* Bind ANYADDR * * Try "::" first as that covers IPv6 ANYADDR and mapped IPv4 ANYADDR * silencing warnings since failure is an option * * If that fails (because AF_INET6 is unsupported) retry with 0.0.0.0 */ ------- As far is I know IPv4 mapped addresses are disabled by default in FreeBSD, also if IPv6 support is enabled in the kernel (which is enabled by default in GENERIC kernel) than there always be at least one IPv6 interface - it is lo0 (localhost). That leads to the AF_INET6 is reported as being supported and the code will not fail to bind to IPv6 ANYADDR. So there would be no attempt to bind to IPv4 ANYADDR. Previous Comments: ------------------------------------------------------------------------ [2019-01-25 04:32:27] ard_1 at mail dot ru This bug affects PHP version 7.2.14 as well. The jail is not required to reproduce this problem - PHP installations without a jail are also affected. The corresponding FreeBSD bug on this issue: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=235141 ------------------------------------------------------------------------ [2019-01-22 17:37:10] requinix@php.net Related To: Bug #77501 ------------------------------------------------------------------------ [2019-01-22 17:27:01] laszlo at karolyi dot hu +1, Same as #77501. Adding the information here that listening on both interfaces is only available with specifying two separate fpm configurations, with the respective listen directives. ------------------------------------------------------------------------ [2019-01-17 19:44:52] php at darkain dot com Changing listen to "0.0.0.0:9000" will properly listen on IPv4 without IPv6 as expected. Manually specifying an IP address (either v4 or v6) works as expected as well. It is only when specifying port ONLY that it is broken according to the docs. ------------------------------------------------------------------------ [2019-01-17 19:34:39] php at darkain dot com Description: ------------ 1) Create a bare FreeBSD jail 2) Inside of jail, run "pkg install php73" 3) Change /usr/local/etc/php-fpm.d/www.conf to "listen = 9000" 4) Run "service php-fpm onestart" to start the PHP FPM daemon PHP service is now running, but only listening on IPv6:9000, not IPv4:9000. Expected result: ---------------- Listening on both IPv4 and IPv6 Actual result: -------------- root@php-test:~ # sockstat -l USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS www php-fpm 37643 5 tcp6 *:9000 *:* www php-fpm 37642 5 tcp6 *:9000 *:* root php-fpm 37641 7 tcp6 *:9000 *:* (note the pack of tcp4 in PROTO) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77482&edit=1

« previous php.bugs (#219187) next »