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

From: Date: Wed, 21 Jun 2023 16:12:39 +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-244772@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: laszlo at karolyi dot hu 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: 4 years later, this bug still exists in PHP 8.2. Previous Comments: ------------------------------------------------------------------------ [2023-06-13 08:26:05] worldtalkn at gmail dot com World Talk News are sharing latest news about home improvement, auto, tech, business, travel, health, entertainment, real estate etc. More info to visit: (https://worldtalknews.com)github.com ------------------------------------------------------------------------ [2019-01-25 08:11:26] ard_1 at mail dot ru This non-portable socket binding behavior was brought with the attempt to fix bug https://bugs.php.net/bug.php?id=74166 and a corresponding commit. As far as I know, the portable way to fix this bug is possible by creating two independent sockets. PHP-FPM should bind to IPv6 socket with setsockopt() to turn on the IPV6_V6ONLY option. And then it should try to bind an IPv4 socket to the same port on 0.0.0.0 ------------------------------------------------------------------------ [2019-01-25 07:31:51] ard_1 at mail dot ru This bug should also hit OpenBSD users since as far as I know there is no support for IPv4 mapped addresses exist in OpenBSD at all. Also if I'm getting the root cause of this problem right, setting sysctl net.ipv6.bindv6only=1 in Linux should perform a similar effect and PHP-FPM would not bind to IPv4 ANYADDR too. ------------------------------------------------------------------------ [2019-01-25 05:56:11] ard_1 at mail dot ru 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. ------------------------------------------------------------------------ [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 ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=77482 -- Edit this bug report at https://bugs.php.net/bug.php?id=77482&edit=1

« previous php.bugs (#244772) next »