]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Add "v6only" Listen option to enable IPV6_V6ONLY in v4mapped builds
authorJoe Orton <jorton@apache.org>
Tue, 23 Jun 2020 08:45:07 +0000 (08:45 +0000)
committerJoe Orton <jorton@apache.org>
Tue, 23 Jun 2020 08:45:07 +0000 (08:45 +0000)
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

CHANGES
docs/manual/mod/mpm_common.xml
include/ap_listen.h
server/listen.c

diff --git a/CHANGES b/CHANGES
index f24e24c8f2e49ce48ac00773502e3e59a02c7716..0ae7ba816f24159fda1658965343adaf99d6fcea 100644 (file)
--- 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 <luhliari redhat.com>, Joe Orton]
 
   *) config: Allow for environment variable substitution with default value,
index be8a2ff5b2fc1c971f9b7abb3e07ecb5098c1706..bd6840c5a85c20afa440467c1ef3a041c6d828d2 100644 (file)
@@ -270,6 +270,14 @@ Listen 192.170.2.5:8000
       <li><code>reuseport</code>: The <code>SO_REUSEPORT</code> socket
       option is enabled, allowing a Listen directive to bind to a port
       which may already be in use by another process.</li>
+
+      <li><code>v6only</code>: The <code>IPV6_V6ONLY</code> 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 <em>disabled</em>, this is the default behaviour and
+      this option has no effect.)</li>
     </ul>
        
     <note><title>Error condition</title>
index 2329cae70cbd8f338296f8287f4cf3da4edbab93..1f151f98a48aaac8319b81b7f6e5242ab2eb2dc6 100644 (file)
@@ -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.
index 991a3f2c30d47779c8f9e60598e6e0d9e02678b9..445d1202c9301442da67fd061e17855ff612f408 100644 (file)
@@ -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);