You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jo...@apache.org on 2020/06/23 08:45:08 UTC

svn commit: r1879106 - in /httpd/httpd/trunk: CHANGES docs/manual/mod/mpm_common.xml include/ap_listen.h server/listen.c

Author: jorton
Date: Tue Jun 23 08:45:07 2020
New Revision: 1879106

URL: http://svn.apache.org/viewvc?rev=1879106&view=rev
Log:
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

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/docs/manual/mod/mpm_common.xml
    httpd/httpd/trunk/include/ap_listen.h
    httpd/httpd/trunk/server/listen.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1879106&r1=1879105&r2=1879106&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Tue Jun 23 08:45:07 2020
@@ -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,

Modified: httpd/httpd/trunk/docs/manual/mod/mpm_common.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mpm_common.xml?rev=1879106&r1=1879105&r2=1879106&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/mpm_common.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/mpm_common.xml Tue Jun 23 08:45:07 2020
@@ -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>

Modified: httpd/httpd/trunk/include/ap_listen.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_listen.h?rev=1879106&r1=1879105&r2=1879106&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_listen.h (original)
+++ httpd/httpd/trunk/include/ap_listen.h Tue Jun 23 08:45:07 2020
@@ -42,6 +42,7 @@ typedef apr_status_t (*accept_function)(
 #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.

Modified: httpd/httpd/trunk/server/listen.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/listen.c?rev=1879106&r1=1879105&r2=1879106&view=diff
==============================================================================
--- httpd/httpd/trunk/server/listen.c (original)
+++ httpd/httpd/trunk/server/listen.c Tue Jun 23 08:45:07 2020
@@ -78,7 +78,7 @@ static apr_status_t make_sock(apr_pool_t
     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(ap
             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);