From 4657289e87e18bb8967d5a8b0163c772d410e2b8 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 17 Nov 2014 06:53:38 +0100 Subject: [PATCH 1/2] Improve fix bug #68421 access.format='%R' doesn't log ipv6 address Log IPv4-Mapped-Ipv6 address as IPv4 (not as IPv6) --- sapi/fpm/fpm/fastcgi.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/sapi/fpm/fpm/fastcgi.c b/sapi/fpm/fpm/fastcgi.c index 86fca17c5f7..d1db0ec293e 100644 --- a/sapi/fpm/fpm/fastcgi.c +++ b/sapi/fpm/fpm/fastcgi.c @@ -1099,13 +1099,23 @@ const char *fcgi_get_last_client_ip() /* {{{ */ { static char str[INET6_ADDRSTRLEN]; - if (client_sa.sa.sa_family == AF_UNIX) { - return NULL; - } + /* Ipv4 */ if (client_sa.sa.sa_family == AF_INET) { return inet_ntop(client_sa.sa.sa_family, &client_sa.sa_inet.sin_addr, str, INET6_ADDRSTRLEN); } - return inet_ntop(client_sa.sa.sa_family, &client_sa.sa_inet6.sin6_addr, str, INET6_ADDRSTRLEN); +#ifdef IN6_IS_ADDR_V4MAPPED + /* Ipv4-Mapped-Ipv6 */ + if (client_sa.sa.sa_family == AF_INET6 + && IN6_IS_ADDR_V4MAPPED(&client_sa.sa_inet6.sin6_addr)) { + return inet_ntop(AF_INET, ((char *)&client_sa.sa_inet6.sin6_addr)+12, str, INET6_ADDRSTRLEN); + } +#endif + /* Ipv6 */ + if (client_sa.sa.sa_family == AF_INET6) { + return inet_ntop(client_sa.sa.sa_family, &client_sa.sa_inet6.sin6_addr, str, INET6_ADDRSTRLEN); + } + /* Unix socket */ + return NULL; } /* }}} */ /* From 4475cbdc8577ec704bf7d6a6c753e5e4066fec19 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 17 Nov 2014 06:57:59 +0100 Subject: [PATCH 2/2] comment about ipv4-mapped in fpm conf --- sapi/fpm/php-fpm.conf.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sapi/fpm/php-fpm.conf.in b/sapi/fpm/php-fpm.conf.in index f22c2ff8b72..9d752956604 100644 --- a/sapi/fpm/php-fpm.conf.in +++ b/sapi/fpm/php-fpm.conf.in @@ -156,8 +156,8 @@ group = @php_fpm_group@ ; a specific port; ; 'port' - to listen on a TCP socket to all IPv4 addresses on a ; specific port; -; '[::]:port' - to listen on a TCP socket to all addresses on a -; specific port; +; '[::]:port' - to listen on a TCP socket to all addresses +; (IPv6 and IPv4-mapped) on a specific port; ; '/path/to/unix/socket' - to listen on a unix socket. ; Note: This value is mandatory. listen = 127.0.0.1:9000