From: Joe Orton Date: Tue, 23 Jun 2020 08:45:07 +0000 (+0000) Subject: Add "v6only" Listen option to enable IPV6_V6ONLY in v4mapped builds X-Git-Tag: 2.5.0-alpha2-ci-test-only~1352 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f9cba2ad01a6dda48d19da475fea72ca3637104;p=thirdparty%2Fapache%2Fhttpd.git Add "v6only" Listen option to enable IPV6_V6ONLY in v4mapped builds where it is otherwise always disabled. * include/ap_listen.h: Define AP_LISTEN_V6ONLY. * server/listen.c (make_sock): Set v6only_setting to 1 if AP_LISTEN_V6ONLY flag is set for the listener. (parse_listen_flags): Parse "v6only" flag. PR: 54878 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1879106 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index f24e24c8f2e..0ae7ba816f2 100644 --- a/CHANGES +++ b/CHANGES @@ -38,7 +38,7 @@ Changes with Apache 2.5.1 the connection inside mod_ssl. [Joe Orton] *) core: Add optional "options=" argument to Listen. Supported - keywords are "freebind" and "reuseport". PR 61865. + keywords are "freebind", "reuseport" and "v6only". PR 61865. [Jan Kaluza, Lubos Uhliarik , Joe Orton] *) config: Allow for environment variable substitution with default value, diff --git a/docs/manual/mod/mpm_common.xml b/docs/manual/mod/mpm_common.xml index be8a2ff5b2f..bd6840c5a85 100644 --- a/docs/manual/mod/mpm_common.xml +++ b/docs/manual/mod/mpm_common.xml @@ -270,6 +270,14 @@ Listen 192.170.2.5:8000
  • reuseport: The SO_REUSEPORT socket option is enabled, allowing a Listen directive to bind to a port which may already be in use by another process.
  • + +
  • v6only: The IPV6_V6ONLY socket + option is enabled, allowing a Listen directive to bind to an + IPv6 address without also accepting connections via IPv4, or + conflicting with a Listen directive using an IPv4 address bound + to the same port. (If the server is built with IPv4-mapped + addresses disabled, this is the default behaviour and + this option has no effect.)
  • Error condition diff --git a/include/ap_listen.h b/include/ap_listen.h index 2329cae70cb..1f151f98a48 100644 --- a/include/ap_listen.h +++ b/include/ap_listen.h @@ -42,6 +42,7 @@ typedef apr_status_t (*accept_function)(void **csd, ap_listen_rec *lr, apr_pool_ #define AP_LISTEN_SPECIFIC_ERRORS (0x0001) #define AP_LISTEN_FREEBIND (0x0002) #define AP_LISTEN_REUSEPORT (0x0004) +#define AP_LISTEN_V6ONLY (0x0008) /** * @brief Apache's listeners record. diff --git a/server/listen.c b/server/listen.c index 991a3f2c30d..445d1202c93 100644 --- a/server/listen.c +++ b/server/listen.c @@ -78,7 +78,7 @@ static apr_status_t make_sock(apr_pool_t *p, ap_listen_rec *server, int do_bind_ int one = 1; #if APR_HAVE_IPV6 #ifdef AP_ENABLE_V4_MAPPED - int v6only_setting = 0; + int v6only_setting = (server->flags & AP_LISTEN_V6ONLY) ? 1 : 0; #else int v6only_setting = 1; #endif @@ -1048,6 +1048,8 @@ static const char *parse_listen_flags(apr_pool_t *temp_pool, const char *arg, flags |= AP_LISTEN_FREEBIND; else if (ap_cstr_casecmp(token, "reuseport") == 0) flags |= AP_LISTEN_REUSEPORT; + else if (ap_cstr_casecmp(token, "v6only") == 0) + flags |= AP_LISTEN_V6ONLY; else return apr_psprintf(temp_pool, "Unknown Listen option '%s' in '%s'", token, arg);