]> git.kaiwu.me - nginx.git/commitdiff
Core: ipv6only is now on by default.
authorRuslan Ermilov <ru@nginx.com>
Mon, 30 Jul 2012 12:27:06 +0000 (12:27 +0000)
committerRuslan Ermilov <ru@nginx.com>
Mon, 30 Jul 2012 12:27:06 +0000 (12:27 +0000)
There is a general consensus that this change results in better
consistency between different operating systems and differently
tuned operating systems.

Note: this changes the width and meaning of the ipv6only field
of the ngx_listening_t structure.  3rd party modules that create
their own listening sockets might need fixing.

src/core/ngx_connection.c
src/core/ngx_connection.h
src/http/ngx_http_core_module.c
src/http/ngx_http_core_module.h
src/mail/ngx_mail.h
src/mail/ngx_mail_core_module.c

index ba1b3f9e2bc4b6d91ce4696f1e839a66b6272a95..660e0af4ad506604797d3f2a9efa42e7ba394f83 100644 (file)
@@ -336,10 +336,10 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
 
 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
 
-            if (ls[i].sockaddr->sa_family == AF_INET6 && ls[i].ipv6only) {
+            if (ls[i].sockaddr->sa_family == AF_INET6) {
                 int  ipv6only;
 
-                ipv6only = (ls[i].ipv6only == 1);
+                ipv6only = ls[i].ipv6only;
 
                 if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY,
                                (const void *) &ipv6only, sizeof(int))
index 34af12e4f347bca054f0b70cf5837e5fc3eef3ad..87fd087238bb37669cfe2fbb3c7069530f4f6341 100644 (file)
@@ -64,7 +64,7 @@ struct ngx_listening_s {
     unsigned            addr_ntop:1;
 
 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
-    unsigned            ipv6only:2;
+    unsigned            ipv6only:1;
 #endif
     unsigned            keepalive:2;
 
index ecc0a2f25778a68a767582c13e1609adc33a99d6..14dc2cef34b7d8194daa6b155ba086592415f7de 100644 (file)
@@ -3912,6 +3912,9 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
     lsopt.setfib = -1;
 #endif
     lsopt.wildcard = u.wildcard;
+#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
+    lsopt.ipv6only = 1;
+#endif
 
     (void) ngx_sock_ntop(&lsopt.u.sockaddr, lsopt.addr,
                          NGX_SOCKADDR_STRLEN, 1);
@@ -4031,7 +4034,7 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
                     lsopt.ipv6only = 1;
 
                 } else if (ngx_strcmp(&value[n].data[10], "ff") == 0) {
-                    lsopt.ipv6only = 2;
+                    lsopt.ipv6only = 0;
 
                 } else {
                     ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
index b11bdcd90560060588d3a896f24a1e0d0c33f950..ff1c2dfa0712c62060169d0aa65d8ba381f5ddc6 100644 (file)
@@ -76,7 +76,7 @@ typedef struct {
     unsigned                   ssl:1;
 #endif
 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
-    unsigned                   ipv6only:2;
+    unsigned                   ipv6only:1;
 #endif
     unsigned                   so_keepalive:2;
 
index 1fceb42856ed23eafab3cc0cf776d867996b0602..ccdfb8c6f1099a777b27878d8f254ed5b58ba224 100644 (file)
@@ -39,7 +39,7 @@ typedef struct {
     unsigned                ssl:1;
 #endif
 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
-    unsigned                ipv6only:2;
+    unsigned                ipv6only:1;
 #endif
     unsigned                so_keepalive:2;
 #if (NGX_HAVE_KEEPALIVE_TUNABLE)
@@ -100,7 +100,7 @@ typedef struct {
     unsigned                ssl:1;
 #endif
 #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
-    unsigned                ipv6only:2;
+    unsigned                ipv6only:1;
 #endif
     unsigned                so_keepalive:2;
 #if (NGX_HAVE_KEEPALIVE_TUNABLE)
index f79913b0a461bd1899477d25ddef4ff87529d056..f0dee7283c634cf97defca0b5fac5a37b5894a1f 100644 (file)
@@ -374,6 +374,10 @@ ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
     ls->wildcard = u.wildcard;
     ls->ctx = cf->ctx;
 
+#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY)
+    ls->ipv6only = 1;
+#endif
+
     for (m = 0; ngx_modules[m]; m++) {
         if (ngx_modules[m]->type != NGX_MAIL_MODULE) {
             continue;
@@ -413,7 +417,7 @@ ngx_mail_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
                     ls->ipv6only = 1;
 
                 } else if (ngx_strcmp(&value[i].data[10], "ff") == 0) {
-                    ls->ipv6only = 2;
+                    ls->ipv6only = 0;
 
                 } else {
                     ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,