svn rev #24978: trunk/src/ appl/sample/sclient/ kadmin/dbutil/ lib/kadm5/ lib/kadm5/clnt/ ...
ghudson@MIT.EDU
ghudson at MIT.EDU
Thu Jun 23 00:13:45 EDT 2011
http://src.mit.edu/fisheye/changelog/krb5/?cs=24978
Commit By: ghudson
Log Message:
ticket: 6923
subject: Use AI_ADDRCONFIG for more efficient getaddrinfo
Add AI_ADDRCONFIG to the hint flags for every invocation of
getaddrinfo which wasn't already using it. This is often the default
behavior when no hints are specified, but we tend to specify hints a
lot, so we have to say it ourselves. AI_ADDRCONFIG causes AAAA
lookups to be skipped if the system has no public IPv6 interface
addresses, usually saving a couple of DNS queries per getaddrinfo
call and allowing DNS caching to be much more effective without the
need for negative caching.
Changed Files:
U trunk/src/appl/sample/sclient/sclient.c
U trunk/src/kadmin/dbutil/kadm5_create.c
U trunk/src/lib/kadm5/alt_prof.c
U trunk/src/lib/kadm5/clnt/client_init.c
U trunk/src/lib/krb5/os/hostaddr.c
U trunk/src/lib/krb5/os/hst_realm.c
U trunk/src/lib/krb5/os/sendto_kdc.c
U trunk/src/plugins/locate/python/py-locate.c
U trunk/src/slave/kprop.c
Modified: trunk/src/appl/sample/sclient/sclient.c
===================================================================
--- trunk/src/appl/sample/sclient/sclient.c 2011-06-23 04:13:38 UTC (rev 24977)
+++ trunk/src/appl/sample/sclient/sclient.c 2011-06-23 04:13:45 UTC (rev 24978)
@@ -125,6 +125,7 @@
memset(&aihints, 0, sizeof(aihints));
aihints.ai_socktype = SOCK_STREAM;
+ aihints.ai_flags = AI_ADDRCONFIG;
aierr = getaddrinfo(argv[1], portstr, &aihints, &ap);
if (aierr) {
fprintf(stderr, "%s: error looking up host '%s' port '%s'/tcp: %s\n",
Modified: trunk/src/kadmin/dbutil/kadm5_create.c
===================================================================
--- trunk/src/kadmin/dbutil/kadm5_create.c 2011-06-23 04:13:38 UTC (rev 24977)
+++ trunk/src/kadmin/dbutil/kadm5_create.c 2011-06-23 04:13:45 UTC (rev 24978)
@@ -184,7 +184,7 @@
goto clean_and_exit;
}
memset(&ai_hints, 0, sizeof(ai_hints));
- ai_hints.ai_flags = AI_CANONNAME;
+ ai_hints.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
gai_error = getaddrinfo(localname, (char *)NULL, &ai_hints, &ai);
if (gai_error) {
ret = EINVAL;
Modified: trunk/src/lib/kadm5/alt_prof.c
===================================================================
--- trunk/src/lib/kadm5/alt_prof.c 2011-06-23 04:13:38 UTC (rev 24977)
+++ trunk/src/lib/kadm5/alt_prof.c 2011-06-23 04:13:45 UTC (rev 24978)
@@ -897,7 +897,7 @@
}
memset(&hint, 0, sizeof(hint));
- hint.ai_flags = AI_CANONNAME;
+ hint.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
err = getaddrinfo(params_out.admin_server, NULL, &hint, &ai);
if (err != 0) {
ret = KADM5_CANT_RESOLVE;
Modified: trunk/src/lib/kadm5/clnt/client_init.c
===================================================================
--- trunk/src/lib/kadm5/clnt/client_init.c 2011-06-23 04:13:38 UTC (rev 24977)
+++ trunk/src/lib/kadm5/clnt/client_init.c 2011-06-23 04:13:45 UTC (rev 24978)
@@ -563,8 +563,9 @@
(void) snprintf(portbuf, sizeof(portbuf), "%d", port);
memset(&hint, 0, sizeof(hint));
hint.ai_socktype = SOCK_STREAM;
+ hint.ai_flags = AI_ADDRCONFIG;
#ifdef AI_NUMERICSERV
- hint.ai_flags = AI_NUMERICSERV;
+ hint.ai_flags |= AI_NUMERICSERV;
#endif
err = getaddrinfo(hostname, portbuf, &hint, &addrs);
if (err != 0)
Modified: trunk/src/lib/krb5/os/hostaddr.c
===================================================================
--- trunk/src/lib/krb5/os/hostaddr.c 2011-06-23 04:13:38 UTC (rev 24977)
+++ trunk/src/lib/krb5/os/hostaddr.c 2011-06-23 04:13:45 UTC (rev 24978)
@@ -41,7 +41,7 @@
return KRB5_ERR_BAD_HOSTNAME;
memset (&hints, 0, sizeof (hints));
- hints.ai_flags = AI_NUMERICHOST;
+ hints.ai_flags = AI_NUMERICHOST | AI_ADDRCONFIG;
/* We don't care what kind at this point, really, but without
this, we can get back multiple sockaddrs per address, for
SOCK_DGRAM, SOCK_STREAM, and SOCK_RAW. I haven't checked if
Modified: trunk/src/lib/krb5/os/hst_realm.c
===================================================================
--- trunk/src/lib/krb5/os/hst_realm.c 2011-06-23 04:13:38 UTC (rev 24977)
+++ trunk/src/lib/krb5/os/hst_realm.c 2011-06-23 04:13:45 UTC (rev 24978)
@@ -107,7 +107,7 @@
int err;
memset (&hints, 0, sizeof (hints));
- hints.ai_flags = AI_CANONNAME;
+ hints.ai_flags = AI_CANONNAME | AI_ADDRCONFIG;
err = getaddrinfo (name, 0, &hints, &ai);
if (err)
return krb5int_translate_gai_error (err);
Modified: trunk/src/lib/krb5/os/sendto_kdc.c
===================================================================
--- trunk/src/lib/krb5/os/sendto_kdc.c 2011-06-23 04:13:38 UTC (rev 24977)
+++ trunk/src/lib/krb5/os/sendto_kdc.c 2011-06-23 04:13:45 UTC (rev 24978)
@@ -725,8 +725,9 @@
memset(&hint, 0, sizeof(hint));
hint.ai_family = entry->family;
hint.ai_socktype = (entry->socktype != 0) ? entry->socktype : socktype1;
+ hint.ai_flags = AI_ADDRCONFIG;
#ifdef AI_NUMERICSERV
- hint.ai_flags = AI_NUMERICSERV;
+ hint.ai_flags |= AI_NUMERICSERV;
#endif
result = snprintf(portbuf, sizeof(portbuf), "%d", ntohs(entry->port));
if (SNPRINTF_OVERFLOW(result, sizeof(portbuf)))
Modified: trunk/src/plugins/locate/python/py-locate.c
===================================================================
--- trunk/src/plugins/locate/python/py-locate.c 2011-06-23 04:13:38 UTC (rev 24977)
+++ trunk/src/plugins/locate/python/py-locate.c 2011-06-23 04:13:45 UTC (rev 24978)
@@ -302,6 +302,7 @@
return -1;
}
aihints.ai_socktype = thissocktype;
+ aihints.ai_flags = AI_ADDRCONFIG;
x = getaddrinfo (hoststr, portstr, &aihints, &airesult);
if (x != 0)
continue;
Modified: trunk/src/slave/kprop.c
===================================================================
--- trunk/src/slave/kprop.c 2011-06-23 04:13:38 UTC (rev 24977)
+++ trunk/src/slave/kprop.c 2011-06-23 04:13:45 UTC (rev 24978)
@@ -322,6 +322,7 @@
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
+ hints.ai_flags = AI_ADDRCONFIG;
error = getaddrinfo(host, port, &hints, &answers);
if (error != 0) {
com_err(progname, 0, "%s: %s", host, gai_strerror(error));
More information about the cvs-krb5
mailing list