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

    The ListenFree directive is

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

    52592b
    +
    52592b
    +
    52592b
    +
    52592b
     
    top
    52592b
     
    52592b
     
    52592b