diff options
author | Igor Sysoev <igor@sysoev.ru> | 2009-03-13 14:20:34 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2009-03-13 14:20:34 +0000 |
commit | 6d94b51f0bda79fba3a9d122537f0cfac412bb34 (patch) | |
tree | cb97419433f565c89dcc7a4d1f93a322fea9d2a0 /src/core | |
parent | 648b0dcf282a3f1b75acfb9775c7fb00821454b9 (diff) | |
download | nginx-6d94b51f0bda79fba3a9d122537f0cfac412bb34.tar.gz nginx-6d94b51f0bda79fba3a9d122537f0cfac412bb34.zip |
ipv6only
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/ngx_connection.c | 17 | ||||
-rw-r--r-- | src/core/ngx_connection.h | 4 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/core/ngx_connection.c b/src/core/ngx_connection.c index 804ab0916..f413ffbe8 100644 --- a/src/core/ngx_connection.c +++ b/src/core/ngx_connection.c @@ -282,6 +282,23 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle) return NGX_ERROR; } +#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) + + if (ls[i].sockaddr->sa_family == AF_INET6 && ls[i].ipv6only) { + int ipv6only; + + ipv6only = (ls[i].ipv6only == 1); + + if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, + (const void *) &ipv6only, sizeof(int)) + == -1) + { + ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno, + "setsockopt(IPV6_V6ONLY) %V failed, ignored", + &ls[i].addr_text); + } + } +#endif /* TODO: close on exit */ if (!(ngx_event_flags & NGX_USE_AIO_EVENT)) { diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h index 171078b23..cc6a92989 100644 --- a/src/core/ngx_connection.h +++ b/src/core/ngx_connection.h @@ -56,6 +56,10 @@ struct ngx_listening_s { unsigned shared:1; /* shared between threads or processes */ unsigned addr_ntop:1; +#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) + unsigned ipv6only:2; +#endif + #if (NGX_HAVE_DEFERRED_ACCEPT) unsigned deferred_accept:1; unsigned delete_deferred:1; |