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

    The ListenFree directive is

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

    576df0
    +
    576df0
    +
    576df0
    +
    576df0
     
    top
    576df0
     
    576df0
     
    576df0