Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Simplify handling of nameserver configuration in resolver
Remove use of ext.nsmap member of struct __res_state and always use
an identity mapping betwen the nsaddr_list array and the ext.nsaddrs
array.  The fact that a nameserver has an IPv6 address is signalled by
setting nsaddr_list[].sin_family to zero.
  • Loading branch information
Andreas Schwab committed May 21, 2015
1 parent f585737 commit 2212c14
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 137 deletions.
11 changes: 11 additions & 0 deletions ChangeLog
@@ -1,3 +1,14 @@
2015-05-21 Andreas Schwab <schwab@suse.de>

[BZ #13028]
[BZ #17053]
* resolv/res_init.c (__res_vinit): Remove use of ext.nsmap member
of struct __res_state.
* resolv/res_send.c (__libc_res_nsend): Likewise.
(get_nsaddr): New function.
(res_ourserver_p, send_vc, reopen): Use it instead of accessing
statp directly.

2015-05-20 Joseph Myers <joseph@codesourcery.com>

* conform/GlibcConform.pm ($CFLAGS{"POSIX"}): Use
Expand Down
20 changes: 10 additions & 10 deletions NEWS
Expand Up @@ -9,16 +9,16 @@ Version 2.22

* The following bugs are resolved with this release:

4719, 6792, 13064, 14094, 14841, 14906, 15319, 15467, 15790, 15969, 16159,
16339, 16351, 16352, 16512, 16560, 16704, 16783, 16850, 17090, 17195,
17269, 17523, 17542, 17569, 17581, 17588, 17596, 17620, 17621, 17628,
17631, 17692, 17711, 17715, 17776, 17779, 17792, 17836, 17912, 17916,
17930, 17932, 17944, 17949, 17964, 17965, 17967, 17969, 17978, 17987,
17991, 17996, 17998, 17999, 18007, 18019, 18020, 18029, 18030, 18032,
18036, 18038, 18039, 18042, 18043, 18046, 18047, 18049, 18068, 18080,
18093, 18100, 18104, 18110, 18111, 18125, 18128, 18138, 18185, 18196,
18197, 18206, 18210, 18211, 18217, 18220, 18221, 18244, 18247, 18287,
18319, 18333, 18346, 18397, 18409, 18418, 18434.
4719, 6792, 13028, 13064, 14094, 14841, 14906, 15319, 15467, 15790, 15969,
16159, 16339, 16351, 16352, 16512, 16560, 16704, 16783, 16850, 17053,
17090, 17195, 17269, 17523, 17542, 17569, 17581, 17588, 17596, 17620,
17621, 17628, 17631, 17692, 17711, 17715, 17776, 17779, 17792, 17836,
17912, 17916, 17930, 17932, 17944, 17949, 17964, 17965, 17967, 17969,
17978, 17987, 17991, 17996, 17998, 17999, 18007, 18019, 18020, 18029,
18030, 18032, 18036, 18038, 18039, 18042, 18043, 18046, 18047, 18049,
18068, 18080, 18093, 18100, 18104, 18110, 18111, 18125, 18128, 18138,
18185, 18196, 18197, 18206, 18210, 18211, 18217, 18220, 18221, 18244,
18247, 18287, 18319, 18333, 18346, 18397, 18409, 18418, 18434.

* Cache information can be queried via sysconf() function on s390 e.g. with
_SC_LEVEL1_ICACHE_SIZE as argument.
Expand Down
47 changes: 14 additions & 33 deletions resolv/res_init.c
Expand Up @@ -153,10 +153,8 @@ __res_vinit(res_state statp, int preinit) {
char *cp, **pp;
int n;
char buf[BUFSIZ];
int nserv = 0; /* number of IPv4 nameservers read from file */
#ifdef _LIBC
int nservall = 0; /* number of (IPv4 + IPV6) nameservers read from file */
#endif
int nserv = 0; /* number of nameservers read from file */
int have_serv6 = 0;
int haveenv = 0;
int havesearch = 0;
#ifdef RESOLVSORT
Expand Down Expand Up @@ -184,15 +182,9 @@ __res_vinit(res_state statp, int preinit) {
statp->_flags = 0;
statp->qhook = NULL;
statp->rhook = NULL;
statp->_u._ext.nsinit = 0;
statp->_u._ext.nscount = 0;
#ifdef _LIBC
statp->_u._ext.nscount6 = 0;
for (n = 0; n < MAXNS; n++) {
statp->_u._ext.nsaddrs[n] = NULL;
statp->_u._ext.nsmap[n] = MAXNS;
}
#endif
for (n = 0; n < MAXNS; n++)
statp->_u._ext.nsaddrs[n] = NULL;

/* Allow user to override the local domain definition */
if ((cp = getenv("LOCALDOMAIN")) != NULL) {
Expand Down Expand Up @@ -296,25 +288,20 @@ __res_vinit(res_state statp, int preinit) {
continue;
}
/* read nameservers to query */
#ifdef _LIBC
if (MATCH(buf, "nameserver") && nservall < MAXNS) {
#else
if (MATCH(buf, "nameserver") && nserv < MAXNS) {
#endif
struct in_addr a;

cp = buf + sizeof("nameserver") - 1;
while (*cp == ' ' || *cp == '\t')
cp++;
if ((*cp != '\0') && (*cp != '\n')
&& __inet_aton(cp, &a)) {
statp->nsaddr_list[nservall].sin_addr = a;
statp->nsaddr_list[nservall].sin_family = AF_INET;
statp->nsaddr_list[nservall].sin_port =
statp->nsaddr_list[nserv].sin_addr = a;
statp->nsaddr_list[nserv].sin_family = AF_INET;
statp->nsaddr_list[nserv].sin_port =
htons(NAMESERVER_PORT);
nserv++;
#ifdef _LIBC
nservall++;
} else {
struct in6_addr a6;
char *el;
Expand Down Expand Up @@ -356,10 +343,11 @@ __res_vinit(res_state statp, int preinit) {
}
}

statp->_u._ext.nsaddrs[nservall] = sa6;
statp->_u._ext.nssocks[nservall] = -1;
statp->_u._ext.nsmap[nservall] = MAXNS + 1;
nservall++;
statp->nsaddr_list[nserv].sin_family = 0;
statp->_u._ext.nsaddrs[nserv] = sa6;
statp->_u._ext.nssocks[nserv] = -1;
have_serv6 = 1;
nserv++;
}
}
#endif
Expand Down Expand Up @@ -414,10 +402,9 @@ __res_vinit(res_state statp, int preinit) {
continue;
}
}
statp->nscount = nservall;
statp->nscount = nserv;
#ifdef _LIBC
if (nservall - nserv > 0) {
statp->_u._ext.nscount6 = nservall - nserv;
if (have_serv6) {
/* We try IPv6 servers again. */
statp->ipv6_unavail = false;
}
Expand Down Expand Up @@ -606,11 +593,7 @@ __res_iclose(res_state statp, bool free_addr) {
statp->_vcsock = -1;
statp->_flags &= ~(RES_F_VC | RES_F_CONN);
}
#ifdef _LIBC
for (ns = 0; ns < MAXNS; ns++)
#else
for (ns = 0; ns < statp->_u._ext.nscount; ns++)
#endif
if (statp->_u._ext.nsaddrs[ns]) {
if (statp->_u._ext.nssocks[ns] != -1) {
close_not_cancel_no_status(statp->_u._ext.nssocks[ns]);
Expand All @@ -621,8 +604,6 @@ __res_iclose(res_state statp, bool free_addr) {
statp->_u._ext.nsaddrs[ns] = NULL;
}
}
if (free_addr)
statp->_u._ext.nsinit = 0;
}
libc_hidden_def (__res_iclose)

Expand Down

0 comments on commit 2212c14

Please sign in to comment.