Welcome! Log In Create A New Profile

Advanced

[nginx] Core: only resolve address families configured on the lo...

Ruslan Ermilov
August 05, 2013 02:58AM
details: http://hg.nginx.org/nginx/rev/ec8594b9bf11
branches:
changeset: 5312:ec8594b9bf11
user: Ruslan Ermilov <ru@nginx.com>
date: Mon Aug 05 10:55:59 2013 +0400
description:
Core: only resolve address families configured on the local system.

This is done by passing AI_ADDRCONFIG to getaddrinfo().

On Linux, setting net.ipv6.conf.all.disable_ipv6 to 1 will now be
respected.

On FreeBSD, AI_ADDRCONFIG filtering is currently implemented by
attempting to create a datagram socket for the corresponding family,
which succeeds even if the system doesn't in fact have any addresses
of that family configured. That is, if the system with IPv6 support
in the kernel doesn't have IPv6 addresses configured, AI_ADDRCONFIG
will filter out IPv6 only inside a jail without IPv6 addresses or
with IPv6 disabled.

diffstat:

auto/unix | 8 ++++++--
src/core/ngx_inet.c | 1 +
2 files changed, 7 insertions(+), 2 deletions(-)

diffs (28 lines):

diff -r ae3fd1ca62e0 -r ec8594b9bf11 auto/unix
--- a/auto/unix Wed Jul 31 23:40:46 2013 +0400
+++ b/auto/unix Mon Aug 05 10:55:59 2013 +0400
@@ -788,7 +788,11 @@ ngx_feature_incs="#include <sys/types.h>
#include <netdb.h>"
ngx_feature_path=
ngx_feature_libs=
-ngx_feature_test='struct addrinfo *res;
- if (getaddrinfo("localhost", NULL, NULL, &res) != 0) return 1;
+ngx_feature_test='struct addrinfo hints, *res;
+ hints.ai_family = AF_UNSPEC;
+ hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_ADDRCONFIG;
+ if (getaddrinfo("localhost", NULL, &hints, &res) != 0)
+ return 1;
freeaddrinfo(res)'
. auto/feature
diff -r ae3fd1ca62e0 -r ec8594b9bf11 src/core/ngx_inet.c
--- a/src/core/ngx_inet.c Wed Jul 31 23:40:46 2013 +0400
+++ b/src/core/ngx_inet.c Mon Aug 05 10:55:59 2013 +0400
@@ -963,6 +963,7 @@ ngx_inet_resolve_host(ngx_pool_t *pool,
ngx_memzero(&hints, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_ADDRCONFIG;

if (getaddrinfo((char *) host, NULL, &hints, &res) != 0) {
u->err = "host not found";

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Core: only resolve address families configured on the lo...

Ruslan Ermilov 850 August 05, 2013 02:58AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 171
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready