Blame SOURCES/httpd-2.4.35-freebind.patch

e71654
diff --git a/include/ap_listen.h b/include/ap_listen.h
e71654
index 58c2574..1a53292 100644
e71654
--- a/include/ap_listen.h
e71654
+++ b/include/ap_listen.h
e71654
@@ -137,6 +137,9 @@ AP_DECLARE_NONSTD(const char *) ap_set_listenbacklog(cmd_parms *cmd, void *dummy
e71654
 AP_DECLARE_NONSTD(const char *) ap_set_listencbratio(cmd_parms *cmd, void *dummy, const char *arg);
e71654
 AP_DECLARE_NONSTD(const char *) ap_set_listener(cmd_parms *cmd, void *dummy,
e71654
                                                 int argc, char *const argv[]);
e71654
+AP_DECLARE_NONSTD(const char *) ap_set_freelistener(cmd_parms *cmd, void *dummy,
e71654
+                                                    int argc, char *const argv[]);
e71654
+
e71654
 AP_DECLARE_NONSTD(const char *) ap_set_send_buffer_size(cmd_parms *cmd, void *dummy,
e71654
                                                         const char *arg);
e71654
 AP_DECLARE_NONSTD(const char *) ap_set_receive_buffer_size(cmd_parms *cmd,
e71654
@@ -150,6 +153,8 @@ AP_INIT_TAKE1("ListenCoresBucketsRatio", ap_set_listencbratio, NULL, RSRC_CONF,
e71654
   "Ratio between the number of CPU cores (online) and the number of listeners buckets"), \
e71654
 AP_INIT_TAKE_ARGV("Listen", ap_set_listener, NULL, RSRC_CONF, \
e71654
   "A port number or a numeric IP address and a port number, and an optional protocol"), \
e71654
+AP_INIT_TAKE_ARGV("ListenFree", ap_set_freelistener, NULL, RSRC_CONF, \
e71654
+  "A port number or a numeric IP address and a port number, and an optional protocol"), \
e71654
 AP_INIT_TAKE1("SendBufferSize", ap_set_send_buffer_size, NULL, RSRC_CONF, \
e71654
   "Send buffer size in bytes"), \
e71654
 AP_INIT_TAKE1("ReceiveBufferSize", ap_set_receive_buffer_size, NULL, \
e71654
diff --git a/server/listen.c b/server/listen.c
e71654
index 1a6c1d3..d375fee 100644
e71654
--- a/server/listen.c
e71654
+++ b/server/listen.c
e71654
@@ -63,6 +63,7 @@ static int ap_listenbacklog;
e71654
 static int ap_listencbratio;
e71654
 static int send_buffer_size;
e71654
 static int receive_buffer_size;
e71654
+static int ap_listenfreebind;
e71654
 #ifdef HAVE_SYSTEMD
e71654
 static int use_systemd = -1;
e71654
 #endif
e71654
@@ -162,6 +163,21 @@ static apr_status_t make_sock(apr_pool_t *p, ap_listen_rec *server, int do_bind_
e71654
     }
e71654
 #endif
e71654
 
e71654
+
e71654
+#if defined(APR_SO_FREEBIND)
e71654
+    if (ap_listenfreebind) {
e71654
+        if (apr_socket_opt_set(s, APR_SO_FREEBIND, one) < 0) {
e71654
+            stat = apr_get_netos_error();
e71654
+            ap_log_perror(APLOG_MARK, APLOG_CRIT, stat, p, APLOGNO(02182)
e71654
+                          "make_sock: apr_socket_opt_set: "
e71654
+                          "error setting APR_SO_FREEBIND");
e71654
+            apr_socket_close(s);
e71654
+            return stat;
e71654
+       }
e71654
+   }
e71654
+#endif
e71654
+
e71654
+
e71654
     if (do_bind_listen) {
e71654
 #if APR_HAVE_IPV6
e71654
         if (server->bind_addr->family == APR_INET6) {
e71654
@@ -956,6 +972,7 @@ AP_DECLARE(void) ap_listen_pre_config(void)
e71654
     }
e71654
 }
e71654
 
e71654
+
e71654
 AP_DECLARE_NONSTD(const char *) ap_set_listener(cmd_parms *cmd, void *dummy,
e71654
                                                 int argc, char *const argv[])
e71654
 {
e71654
@@ -1016,6 +1033,14 @@ AP_DECLARE_NONSTD(const char *) ap_set_listener(cmd_parms *cmd, void *dummy,
e71654
     return alloc_listener(cmd->server->process, host, port, proto, NULL);
e71654
 }
e71654
 
e71654
+AP_DECLARE_NONSTD(const char *) ap_set_freelistener(cmd_parms *cmd, void *dummy,
e71654
+                                                    int argc,
e71654
+                                                    char *const argv[])
e71654
+{
e71654
+    ap_listenfreebind = 1;
e71654
+    return ap_set_listener(cmd, dummy, argc, argv);
e71654
+}
e71654
+
e71654
 AP_DECLARE_NONSTD(const char *) ap_set_listenbacklog(cmd_parms *cmd,
e71654
                                                      void *dummy,
e71654
                                                      const char *arg)
e71654
diff --git a/docs/manual/mod/mpm_common.html.en b/docs/manual/mod/mpm_common.html.en
e71654
index 5d688e4..eb66c19 100644
e71654
--- a/docs/manual/mod/mpm_common.html.en
e71654
+++ b/docs/manual/mod/mpm_common.html.en
e71654
@@ -42,6 +42,7 @@ more than one multi-processing module (MPM)
e71654
 
  • EnableExceptionHook
  • e71654
     
  • GracefulShutdownTimeout
  • e71654
     
  • Listen
  • e71654
    +
  • ListenFree
  • e71654
     
  • ListenBackLog
  • e71654
     
  • ListenCoresBucketsRatio
  • e71654
     
  • MaxConnectionsPerChild
  • e71654
    @@ -233,6 +234,31 @@ discussion of the Address already in use error message,
    e71654
     including other causes.
    e71654
     
    e71654
     
    e71654
    +
    e71654
    +
    top
    e71654
    +
    e71654
    +
    e71654
    +Description:IP addresses and ports that the server
    e71654
    +listens to. Doesn't require IP address to be up
    e71654
    +Syntax:ListenFree [IP-address:]portnumber [protocol]
    e71654
    +Context:server config
    e71654
    +Status:MPM
    e71654
    +Module:event, worker, prefork, mpm_winnt, mpm_netware, mpmt_os2
    e71654
    +Compatibility:This directive is currently available only in Red Hat Enterprise Linux
    e71654
    +
    e71654
    +    

    The ListenFree directive is

    e71654
    +    identical to the Listen directive. 
    e71654
    +    The only difference is in the usage of the IP_FREEBIND socket 
    e71654
    +    option, which is enabled by default with ListenFree. 
    e71654
    +    If IP_FREEBIND is enabled, it allows httpd to bind to an IP
    e71654
    +    address that is nonlocal or does not (yet) exist. This allows httpd to 
    e71654
    +    listen on a socket without requiring the underlying network interface
    e71654
    +    or the specified dynamic IP address to be up at the time when httpd
    e71654
    +    is trying to bind to it.
    e71654
    +    

    e71654
    +
    e71654
    +
    e71654
    +
    e71654
     
    top
    e71654
     
    e71654
     
    e71654