Accepting request 290122 from home:Andreas_Schwab:Factory
- resolv-nameserver-handling.patch: Replace with simpler version with more compatibility OBS-URL: https://build.opensuse.org/request/show/290122 OBS-URL: https://build.opensuse.org/package/show/Base:System/glibc?expand=0&rev=396
This commit is contained in:
parent
bdc7240bd7
commit
680876d9c6
@ -1,3 +1,9 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Mar 9 13:05:32 UTC 2015 - schwab@suse.de
|
||||||
|
|
||||||
|
- resolv-nameserver-handling.patch: Replace with simpler version with more
|
||||||
|
compatibility
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Mon Mar 2 14:27:02 UTC 2015 - schwab@suse.de
|
Mon Mar 2 14:27:02 UTC 2015 - schwab@suse.de
|
||||||
|
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Mar 9 13:05:32 UTC 2015 - schwab@suse.de
|
||||||
|
|
||||||
|
- resolv-nameserver-handling.patch: Replace with simpler version with more
|
||||||
|
compatibility
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Mon Mar 2 14:27:02 UTC 2015 - schwab@suse.de
|
Mon Mar 2 14:27:02 UTC 2015 - schwab@suse.de
|
||||||
|
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Mar 9 13:05:32 UTC 2015 - schwab@suse.de
|
||||||
|
|
||||||
|
- resolv-nameserver-handling.patch: Replace with simpler version with more
|
||||||
|
compatibility
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Mon Mar 2 14:27:02 UTC 2015 - schwab@suse.de
|
Mon Mar 2 14:27:02 UTC 2015 - schwab@suse.de
|
||||||
|
|
||||||
|
@ -1,43 +1,25 @@
|
|||||||
From 0872db85cda0f4d3d1772f365732731f2c0a3c3c Mon Sep 17 00:00:00 2001
|
From 6c07233f12e00b9cf66fb5d4a9b7ddb897590912 Mon Sep 17 00:00:00 2001
|
||||||
From: Andreas Schwab <schwab@suse.de>
|
From: Andreas Schwab <schwab@suse.de>
|
||||||
Date: Thu, 19 Feb 2015 15:52:08 +0100
|
Date: Thu, 19 Feb 2015 15:52:08 +0100
|
||||||
Subject: [PATCH] Rewrite handling of nameserver configuration in resolver
|
Subject: [PATCH] Simplify handling of nameserver configuration in resolver
|
||||||
|
|
||||||
[BZ #13028]
|
[BZ #13028]
|
||||||
[BZ #17053]
|
[BZ #17053]
|
||||||
* resolv/res_private.h: New file.
|
* resolv/res_init.c (__res_vinit): Remove use of ext.nsmap.
|
||||||
* resolv/resolv.h (struct __res_state): Add pointer to struct
|
* resolv/res_send.c (__libc_res_nsend): Likewise.
|
||||||
__res_state_ext member, rename ext.nsmap, ext.nscount6,
|
|
||||||
ext.nsinit, ext.nsaddrs members to __glibc_reserved*.
|
|
||||||
* resolv/res_init.c (__res_vinit): Rewrite handling of nameserver
|
|
||||||
addresses.
|
|
||||||
(__res_iclose): Deallocate __res_state_ext memory if free_addr.
|
|
||||||
* resolv/res_send.c (__libc_res_nsend): Rewrite nameserver setup.
|
|
||||||
(get_nsaddr): New function.
|
(get_nsaddr): New function.
|
||||||
(res_ourserver_p, send_vc, reopen): Use it instead of accessing
|
(res_ourserver_p, send_vc, reopen): Use it instead of accessing
|
||||||
statp directly.
|
statp directly.
|
||||||
---
|
---
|
||||||
resolv/res_init.c | 125 +++++++++++++++---------------------
|
resolv/res_init.c | 47 +++++-----------
|
||||||
resolv/res_private.h | 29 +++++++++
|
resolv/res_send.c | 164 +++++++++++++++++++++++-------------------------------
|
||||||
resolv/res_send.c | 176 ++++++++++++++++++++++-----------------------------
|
2 files changed, 84 insertions(+), 127 deletions(-)
|
||||||
resolv/resolv.h | 9 +--
|
|
||||||
4 files changed, 160 insertions(+), 179 deletions(-)
|
|
||||||
create mode 100644 resolv/res_private.h
|
|
||||||
|
|
||||||
diff --git a/resolv/res_init.c b/resolv/res_init.c
|
diff --git a/resolv/res_init.c b/resolv/res_init.c
|
||||||
index 553ba12..567afaa 100644
|
index 553ba12..66561ff 100644
|
||||||
--- a/resolv/res_init.c
|
--- a/resolv/res_init.c
|
||||||
+++ b/resolv/res_init.c
|
+++ b/resolv/res_init.c
|
||||||
@@ -89,6 +89,8 @@ static const char rcsid[] = "$BINDId: res_init.c,v 8.16 2000/05/09 07:10:12 vixi
|
@@ -153,10 +153,8 @@ __res_vinit(res_state statp, int preinit) {
|
||||||
|
|
||||||
#include <not-cancel.h>
|
|
||||||
|
|
||||||
+#include "res_private.h"
|
|
||||||
+
|
|
||||||
/* Options. Should all be left alone. */
|
|
||||||
#define RESOLVSORT
|
|
||||||
#define RFC1535
|
|
||||||
@@ -153,10 +155,8 @@ __res_vinit(res_state statp, int preinit) {
|
|
||||||
char *cp, **pp;
|
char *cp, **pp;
|
||||||
int n;
|
int n;
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
@ -50,7 +32,7 @@ index 553ba12..567afaa 100644
|
|||||||
int haveenv = 0;
|
int haveenv = 0;
|
||||||
int havesearch = 0;
|
int havesearch = 0;
|
||||||
#ifdef RESOLVSORT
|
#ifdef RESOLVSORT
|
||||||
@@ -184,15 +184,12 @@ __res_vinit(res_state statp, int preinit) {
|
@@ -184,15 +182,9 @@ __res_vinit(res_state statp, int preinit) {
|
||||||
statp->_flags = 0;
|
statp->_flags = 0;
|
||||||
statp->qhook = NULL;
|
statp->qhook = NULL;
|
||||||
statp->rhook = NULL;
|
statp->rhook = NULL;
|
||||||
@ -61,16 +43,14 @@ index 553ba12..567afaa 100644
|
|||||||
- for (n = 0; n < MAXNS; n++) {
|
- for (n = 0; n < MAXNS; n++) {
|
||||||
- statp->_u._ext.nsaddrs[n] = NULL;
|
- statp->_u._ext.nsaddrs[n] = NULL;
|
||||||
- statp->_u._ext.nsmap[n] = MAXNS;
|
- statp->_u._ext.nsmap[n] = MAXNS;
|
||||||
+ if (statp->_u._ext.ext == NULL) {
|
- }
|
||||||
+ statp->_u._ext.ext = malloc (sizeof (*statp->_u._ext.ext));
|
|
||||||
+ if (statp->_u._ext.ext != NULL)
|
|
||||||
+ memset (statp->_u._ext.ext, 0, sizeof (*statp->_u._ext.ext));
|
|
||||||
}
|
|
||||||
-#endif
|
-#endif
|
||||||
|
+ for (n = 0; n < MAXNS; n++)
|
||||||
|
+ statp->_u._ext.nsaddrs[n] = NULL;
|
||||||
|
|
||||||
/* Allow user to override the local domain definition */
|
/* Allow user to override the local domain definition */
|
||||||
if ((cp = getenv("LOCALDOMAIN")) != NULL) {
|
if ((cp = getenv("LOCALDOMAIN")) != NULL) {
|
||||||
@@ -296,11 +293,7 @@ __res_vinit(res_state statp, int preinit) {
|
@@ -296,11 +288,7 @@ __res_vinit(res_state statp, int preinit) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* read nameservers to query */
|
/* read nameservers to query */
|
||||||
@ -82,7 +62,7 @@ index 553ba12..567afaa 100644
|
|||||||
struct in_addr a;
|
struct in_addr a;
|
||||||
|
|
||||||
cp = buf + sizeof("nameserver") - 1;
|
cp = buf + sizeof("nameserver") - 1;
|
||||||
@@ -308,13 +301,11 @@ __res_vinit(res_state statp, int preinit) {
|
@@ -308,13 +296,12 @@ __res_vinit(res_state statp, int preinit) {
|
||||||
cp++;
|
cp++;
|
||||||
if ((*cp != '\0') && (*cp != '\n')
|
if ((*cp != '\0') && (*cp != '\n')
|
||||||
&& __inet_aton(cp, &a)) {
|
&& __inet_aton(cp, &a)) {
|
||||||
@ -94,88 +74,28 @@ index 553ba12..567afaa 100644
|
|||||||
+ statp->nsaddr_list[nserv].sin_port =
|
+ statp->nsaddr_list[nserv].sin_port =
|
||||||
htons(NAMESERVER_PORT);
|
htons(NAMESERVER_PORT);
|
||||||
nserv++;
|
nserv++;
|
||||||
-#ifdef _LIBC
|
#ifdef _LIBC
|
||||||
- nservall++;
|
- nservall++;
|
||||||
} else {
|
} else {
|
||||||
struct in6_addr a6;
|
struct in6_addr a6;
|
||||||
char *el;
|
char *el;
|
||||||
@@ -324,45 +315,40 @@ __res_vinit(res_state statp, int preinit) {
|
@@ -356,10 +343,11 @@ __res_vinit(res_state statp, int preinit) {
|
||||||
if ((el = strchr(cp, SCOPE_DELIMITER)) != NULL)
|
}
|
||||||
*el = '\0';
|
|
||||||
if ((*cp != '\0') &&
|
|
||||||
- (__inet_pton(AF_INET6, cp, &a6) > 0)) {
|
|
||||||
- struct sockaddr_in6 *sa6;
|
|
||||||
-
|
|
||||||
- sa6 = malloc(sizeof(*sa6));
|
|
||||||
- if (sa6 != NULL) {
|
|
||||||
- sa6->sin6_family = AF_INET6;
|
|
||||||
- sa6->sin6_port = htons(NAMESERVER_PORT);
|
|
||||||
- sa6->sin6_flowinfo = 0;
|
|
||||||
- sa6->sin6_addr = a6;
|
|
||||||
-
|
|
||||||
- if (__glibc_likely (el == NULL))
|
|
||||||
- sa6->sin6_scope_id = 0;
|
|
||||||
- else {
|
|
||||||
- int try_numericscope = 1;
|
|
||||||
- if (IN6_IS_ADDR_LINKLOCAL (&a6)
|
|
||||||
- || IN6_IS_ADDR_MC_LINKLOCAL (&a6)) {
|
|
||||||
- sa6->sin6_scope_id
|
|
||||||
- = __if_nametoindex (el + 1);
|
|
||||||
- if (sa6->sin6_scope_id != 0)
|
|
||||||
- try_numericscope = 0;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if (try_numericscope) {
|
|
||||||
- char *end;
|
|
||||||
- sa6->sin6_scope_id
|
|
||||||
- = (uint32_t) strtoul (el + 1, &end,
|
|
||||||
- 10);
|
|
||||||
- if (*end != '\0')
|
|
||||||
- sa6->sin6_scope_id = 0;
|
|
||||||
- }
|
|
||||||
+ (__inet_pton(AF_INET6, cp, &a6) > 0)
|
|
||||||
+ && statp->_u._ext.ext != NULL) {
|
|
||||||
+ struct sockaddr_in6 *sa6
|
|
||||||
+ = &statp->_u._ext.ext->nsaddrs[nserv].sin6;
|
|
||||||
+
|
|
||||||
+ sa6->sin6_family = AF_INET6;
|
|
||||||
+ sa6->sin6_port = htons(NAMESERVER_PORT);
|
|
||||||
+ sa6->sin6_flowinfo = 0;
|
|
||||||
+ sa6->sin6_addr = a6;
|
|
||||||
+
|
|
||||||
+ if (__glibc_likely (el == NULL))
|
|
||||||
+ sa6->sin6_scope_id = 0;
|
|
||||||
+ else {
|
|
||||||
+ int try_numericscope = 1;
|
|
||||||
+ if (IN6_IS_ADDR_LINKLOCAL (&a6)
|
|
||||||
+ || IN6_IS_ADDR_MC_LINKLOCAL (&a6)) {
|
|
||||||
+ sa6->sin6_scope_id
|
|
||||||
+ = __if_nametoindex (el + 1);
|
|
||||||
+ if (sa6->sin6_scope_id != 0)
|
|
||||||
+ try_numericscope = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- statp->_u._ext.nsaddrs[nservall] = sa6;
|
- statp->_u._ext.nsaddrs[nservall] = sa6;
|
||||||
- statp->_u._ext.nssocks[nservall] = -1;
|
- statp->_u._ext.nssocks[nservall] = -1;
|
||||||
- statp->_u._ext.nsmap[nservall] = MAXNS + 1;
|
- statp->_u._ext.nsmap[nservall] = MAXNS + 1;
|
||||||
- nservall++;
|
- nservall++;
|
||||||
+ if (try_numericscope) {
|
|
||||||
+ char *end;
|
|
||||||
+ sa6->sin6_scope_id
|
|
||||||
+ = (uint32_t) strtoul (el + 1, &end, 10);
|
|
||||||
+ if (*end != '\0')
|
|
||||||
+ sa6->sin6_scope_id = 0;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
+ statp->nsaddr_list[nserv].sin_family = 0;
|
+ statp->nsaddr_list[nserv].sin_family = 0;
|
||||||
|
+ statp->_u._ext.nsaddrs[nserv] = sa6;
|
||||||
|
+ statp->_u._ext.nssocks[nserv] = -1;
|
||||||
+ have_serv6 = 1;
|
+ have_serv6 = 1;
|
||||||
+ nserv++;
|
+ nserv++;
|
||||||
}
|
}
|
||||||
-#endif
|
|
||||||
}
|
}
|
||||||
continue;
|
#endif
|
||||||
}
|
@@ -414,10 +402,9 @@ __res_vinit(res_state statp, int preinit) {
|
||||||
@@ -414,10 +400,9 @@ __res_vinit(res_state statp, int preinit) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -188,84 +108,32 @@ index 553ba12..567afaa 100644
|
|||||||
/* We try IPv6 servers again. */
|
/* We try IPv6 servers again. */
|
||||||
statp->ipv6_unavail = false;
|
statp->ipv6_unavail = false;
|
||||||
}
|
}
|
||||||
@@ -606,23 +591,15 @@ __res_iclose(res_state statp, bool free_addr) {
|
@@ -606,11 +593,7 @@ __res_iclose(res_state statp, bool free_addr) {
|
||||||
statp->_vcsock = -1;
|
statp->_vcsock = -1;
|
||||||
statp->_flags &= ~(RES_F_VC | RES_F_CONN);
|
statp->_flags &= ~(RES_F_VC | RES_F_CONN);
|
||||||
}
|
}
|
||||||
-#ifdef _LIBC
|
-#ifdef _LIBC
|
||||||
- for (ns = 0; ns < MAXNS; ns++)
|
- for (ns = 0; ns < MAXNS; ns++)
|
||||||
-#else
|
-#else
|
||||||
- for (ns = 0; ns < statp->_u._ext.nscount; ns++)
|
for (ns = 0; ns < statp->_u._ext.nscount; ns++)
|
||||||
-#endif
|
-#endif
|
||||||
- if (statp->_u._ext.nsaddrs[ns]) {
|
if (statp->_u._ext.nsaddrs[ns]) {
|
||||||
- if (statp->_u._ext.nssocks[ns] != -1) {
|
if (statp->_u._ext.nssocks[ns] != -1) {
|
||||||
- close_not_cancel_no_status(statp->_u._ext.nssocks[ns]);
|
close_not_cancel_no_status(statp->_u._ext.nssocks[ns]);
|
||||||
- statp->_u._ext.nssocks[ns] = -1;
|
@@ -621,8 +604,6 @@ __res_iclose(res_state statp, bool free_addr) {
|
||||||
- }
|
statp->_u._ext.nsaddrs[ns] = NULL;
|
||||||
- if (free_addr) {
|
}
|
||||||
- free (statp->_u._ext.nsaddrs[ns]);
|
|
||||||
- statp->_u._ext.nsaddrs[ns] = NULL;
|
|
||||||
- }
|
|
||||||
+ for (ns = 0; ns < statp->nscount; ns++)
|
|
||||||
+ if (statp->_u._ext.nssocks[ns] != -1) {
|
|
||||||
+ close_not_cancel_no_status(statp->_u._ext.nssocks[ns]);
|
|
||||||
+ statp->_u._ext.nssocks[ns] = -1;
|
|
||||||
}
|
}
|
||||||
- if (free_addr)
|
- if (free_addr)
|
||||||
- statp->_u._ext.nsinit = 0;
|
- statp->_u._ext.nsinit = 0;
|
||||||
+ if (free_addr) {
|
|
||||||
+ free (statp->_u._ext.ext);
|
|
||||||
+ statp->_u._ext.ext = NULL;
|
|
||||||
+ }
|
|
||||||
}
|
}
|
||||||
libc_hidden_def (__res_iclose)
|
libc_hidden_def (__res_iclose)
|
||||||
|
|
||||||
diff --git a/resolv/res_private.h b/resolv/res_private.h
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..deb495b
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/resolv/res_private.h
|
|
||||||
@@ -0,0 +1,29 @@
|
|
||||||
+/* Private definitions for the stub resolver.
|
|
||||||
+ Copyright (C) 2015 Free Software Foundation, Inc.
|
|
||||||
+ This file is part of the GNU C Library.
|
|
||||||
+
|
|
||||||
+ The GNU C Library is free software; you can redistribute it and/or
|
|
||||||
+ modify it under the terms of the GNU Lesser General Public
|
|
||||||
+ License as published by the Free Software Foundation; either
|
|
||||||
+ version 2.1 of the License, or (at your option) any later version.
|
|
||||||
+
|
|
||||||
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
||||||
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
+ Lesser General Public License for more details.
|
|
||||||
+
|
|
||||||
+ You should have received a copy of the GNU Lesser General Public
|
|
||||||
+ License along with the GNU C Library; if not, see
|
|
||||||
+ <http://www.gnu.org/licenses/>. */
|
|
||||||
+
|
|
||||||
+union res_sockaddr_union
|
|
||||||
+{
|
|
||||||
+ struct sockaddr s;
|
|
||||||
+ struct sockaddr_in sin;
|
|
||||||
+ struct sockaddr_in6 sin6;
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+struct __res_state_ext
|
|
||||||
+{
|
|
||||||
+ union res_sockaddr_union nsaddrs[MAXNS];
|
|
||||||
+};
|
|
||||||
diff --git a/resolv/res_send.c b/resolv/res_send.c
|
diff --git a/resolv/res_send.c b/resolv/res_send.c
|
||||||
index c35fb66..1e6d217 100644
|
index c35fb66..5e53cc2 100644
|
||||||
--- a/resolv/res_send.c
|
--- a/resolv/res_send.c
|
||||||
+++ b/resolv/res_send.c
|
+++ b/resolv/res_send.c
|
||||||
@@ -179,11 +179,13 @@ evNowTime(struct timespec *res) {
|
@@ -184,6 +184,7 @@ evNowTime(struct timespec *res) {
|
||||||
/* Options. Leave them on. */
|
|
||||||
/* #undef DEBUG */
|
|
||||||
#include "res_debug.h"
|
|
||||||
+#include "res_private.h"
|
|
||||||
|
|
||||||
#define EXT(res) ((res)->_u._ext)
|
|
||||||
|
|
||||||
/* Forward. */
|
/* Forward. */
|
||||||
|
|
||||||
@ -273,7 +141,7 @@ index c35fb66..1e6d217 100644
|
|||||||
static int send_vc(res_state, const u_char *, int,
|
static int send_vc(res_state, const u_char *, int,
|
||||||
const u_char *, int,
|
const u_char *, int,
|
||||||
u_char **, int *, int *, int, u_char **,
|
u_char **, int *, int *, int, u_char **,
|
||||||
@@ -221,20 +223,21 @@ res_ourserver_p(const res_state statp, const struct sockaddr_in6 *inp)
|
@@ -221,20 +222,21 @@ res_ourserver_p(const res_state statp, const struct sockaddr_in6 *inp)
|
||||||
in_port_t port = in4p->sin_port;
|
in_port_t port = in4p->sin_port;
|
||||||
in_addr_t addr = in4p->sin_addr.s_addr;
|
in_addr_t addr = in4p->sin_addr.s_addr;
|
||||||
|
|
||||||
@ -301,7 +169,7 @@ index c35fb66..1e6d217 100644
|
|||||||
(srv->sin6_port == inp->sin6_port) &&
|
(srv->sin6_port == inp->sin6_port) &&
|
||||||
!(memcmp(&srv->sin6_addr, &in6addr_any,
|
!(memcmp(&srv->sin6_addr, &in6addr_any,
|
||||||
sizeof (struct in6_addr)) &&
|
sizeof (struct in6_addr)) &&
|
||||||
@@ -384,80 +387,40 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen,
|
@@ -384,80 +386,48 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen,
|
||||||
* If the ns_addr_list in the resolver context has changed, then
|
* If the ns_addr_list in the resolver context has changed, then
|
||||||
* invalidate our cached copy and the associated timing data.
|
* invalidate our cached copy and the associated timing data.
|
||||||
*/
|
*/
|
||||||
@ -319,9 +187,8 @@ index c35fb66..1e6d217 100644
|
|||||||
+ if (statp->nsaddr_list[ns].sin_family != 0
|
+ if (statp->nsaddr_list[ns].sin_family != 0
|
||||||
&& !sock_eq((struct sockaddr_in6 *)
|
&& !sock_eq((struct sockaddr_in6 *)
|
||||||
- &statp->nsaddr_list[map],
|
- &statp->nsaddr_list[map],
|
||||||
- EXT(statp).nsaddrs[ns]))
|
|
||||||
+ &statp->nsaddr_list[ns],
|
+ &statp->nsaddr_list[ns],
|
||||||
+ &EXT(statp).ext->nsaddrs[ns].sin6))
|
EXT(statp).nsaddrs[ns]))
|
||||||
{
|
{
|
||||||
needclose++;
|
needclose++;
|
||||||
break;
|
break;
|
||||||
@ -350,14 +217,7 @@ index c35fb66..1e6d217 100644
|
|||||||
- EXT(statp).nsaddrs[n] = NULL;
|
- EXT(statp).nsaddrs[n] = NULL;
|
||||||
- EXT(statp).nsmap[n] = MAXNS;
|
- EXT(statp).nsmap[n] = MAXNS;
|
||||||
- }
|
- }
|
||||||
+ if (EXT(statp).nscount == 0) {
|
- }
|
||||||
+ for (ns = 0; ns < statp->nscount; ns++) {
|
|
||||||
+ EXT(statp).nssocks[ns] = -1;
|
|
||||||
+ if (statp->nsaddr_list[ns].sin_family != 0
|
|
||||||
+ && EXT(statp).ext != NULL)
|
|
||||||
+ EXT(statp).ext->nsaddrs[ns].sin
|
|
||||||
+ = statp->nsaddr_list[ns];
|
|
||||||
}
|
|
||||||
- n = statp->nscount;
|
- n = statp->nscount;
|
||||||
- if (statp->nscount > EXT(statp).nscount)
|
- if (statp->nscount > EXT(statp).nscount)
|
||||||
- for (n = EXT(statp).nscount, ns = 0;
|
- for (n = EXT(statp).nscount, ns = 0;
|
||||||
@ -381,24 +241,33 @@ index c35fb66..1e6d217 100644
|
|||||||
- n = map[ns];
|
- n = map[ns];
|
||||||
- if (EXT(statp).nsaddrs[n] == NULL)
|
- if (EXT(statp).nsaddrs[n] == NULL)
|
||||||
- EXT(statp).nsaddrs[n] =
|
- EXT(statp).nsaddrs[n] =
|
||||||
- malloc(sizeof (struct sockaddr_in6));
|
+ if (EXT(statp).nscount == 0) {
|
||||||
|
+ for (ns = 0; ns < statp->nscount; ns++) {
|
||||||
|
+ EXT(statp).nssocks[ns] = -1;
|
||||||
|
+ if (statp->nsaddr_list[ns].sin_family == 0)
|
||||||
|
+ continue;
|
||||||
|
+ if (EXT(statp).nsaddrs[ns] == NULL)
|
||||||
|
+ EXT(statp).nsaddrs[ns] =
|
||||||
|
malloc(sizeof (struct sockaddr_in6));
|
||||||
- if (EXT(statp).nsaddrs[n] != NULL) {
|
- if (EXT(statp).nsaddrs[n] != NULL) {
|
||||||
- memset (mempcpy(EXT(statp).nsaddrs[n],
|
- memset (mempcpy(EXT(statp).nsaddrs[n],
|
||||||
- &statp->nsaddr_list[ns],
|
+ if (EXT(statp).nsaddrs[ns] != NULL)
|
||||||
- sizeof (struct sockaddr_in)),
|
+ memset (mempcpy(EXT(statp).nsaddrs[ns],
|
||||||
- '\0',
|
&statp->nsaddr_list[ns],
|
||||||
- sizeof (struct sockaddr_in6)
|
sizeof (struct sockaddr_in)),
|
||||||
- - sizeof (struct sockaddr_in));
|
'\0',
|
||||||
|
sizeof (struct sockaddr_in6)
|
||||||
|
- sizeof (struct sockaddr_in));
|
||||||
- EXT(statp).nssocks[n] = -1;
|
- EXT(statp).nssocks[n] = -1;
|
||||||
- n++;
|
- n++;
|
||||||
- }
|
- }
|
||||||
- }
|
}
|
||||||
- EXT(statp).nsinit = 1;
|
- EXT(statp).nsinit = 1;
|
||||||
+ EXT(statp).nscount = statp->nscount;
|
+ EXT(statp).nscount = statp->nscount;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -466,44 +429,41 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen,
|
@@ -466,44 +436,37 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen,
|
||||||
*/
|
*/
|
||||||
if (__builtin_expect ((statp->options & RES_ROTATE) != 0, 0) &&
|
if (__builtin_expect ((statp->options & RES_ROTATE) != 0, 0) &&
|
||||||
(statp->options & RES_BLAST) == 0) {
|
(statp->options & RES_BLAST) == 0) {
|
||||||
@ -424,24 +293,20 @@ index c35fb66..1e6d217 100644
|
|||||||
- }
|
- }
|
||||||
- EXT(statp).nsaddrs[n] = ina;
|
- EXT(statp).nsaddrs[n] = ina;
|
||||||
- EXT(statp).nsmap[n] = map;
|
- EXT(statp).nsmap[n] = map;
|
||||||
+ union res_sockaddr_union inu;
|
|
||||||
+ struct sockaddr_in ina;
|
+ struct sockaddr_in ina;
|
||||||
|
+ struct sockaddr_in6 *inp;
|
||||||
+ int lastns = statp->nscount - 1;
|
+ int lastns = statp->nscount - 1;
|
||||||
+ int fd;
|
+ int fd;
|
||||||
+
|
+
|
||||||
+ if (EXT(statp).ext != NULL)
|
+ inp = EXT(statp).nsaddrs[0];
|
||||||
+ inu = EXT(statp).ext->nsaddrs[0];
|
|
||||||
+ ina = statp->nsaddr_list[0];
|
+ ina = statp->nsaddr_list[0];
|
||||||
+ fd = EXT(statp).nssocks[0];
|
+ fd = EXT(statp).nssocks[0];
|
||||||
+ for (ns = 0; ns < lastns; ns++) {
|
+ for (ns = 0; ns < lastns; ns++) {
|
||||||
+ if (EXT(statp).ext != NULL)
|
+ EXT(statp).nsaddrs[ns] = EXT(statp).nsaddrs[ns + 1];
|
||||||
+ EXT(statp).ext->nsaddrs[ns]
|
|
||||||
+ = EXT(statp).ext->nsaddrs[ns + 1];
|
|
||||||
+ statp->nsaddr_list[ns] = statp->nsaddr_list[ns + 1];
|
+ statp->nsaddr_list[ns] = statp->nsaddr_list[ns + 1];
|
||||||
+ EXT(statp).nssocks[ns] = EXT(statp).nssocks[ns + 1];
|
+ EXT(statp).nssocks[ns] = EXT(statp).nssocks[ns + 1];
|
||||||
}
|
}
|
||||||
+ if (EXT(statp).ext != NULL)
|
+ EXT(statp).nsaddrs[lastns] = inp;
|
||||||
+ EXT(statp).ext->nsaddrs[lastns] = inu;
|
|
||||||
+ statp->nsaddr_list[lastns] = ina;
|
+ statp->nsaddr_list[lastns] = ina;
|
||||||
+ EXT(statp).nssocks[lastns] = fd;
|
+ EXT(statp).nssocks[lastns] = fd;
|
||||||
}
|
}
|
||||||
@ -466,7 +331,7 @@ index c35fb66..1e6d217 100644
|
|||||||
same_ns:
|
same_ns:
|
||||||
#ifdef USE_HOOKS
|
#ifdef USE_HOOKS
|
||||||
if (__glibc_unlikely (statp->qhook != NULL)) {
|
if (__glibc_unlikely (statp->qhook != NULL)) {
|
||||||
@@ -542,9 +502,9 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen,
|
@@ -542,9 +505,9 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen,
|
||||||
|
|
||||||
Dprint(statp->options & RES_DEBUG,
|
Dprint(statp->options & RES_DEBUG,
|
||||||
(stdout, ";; Querying server (# %d) address = %s\n",
|
(stdout, ";; Querying server (# %d) address = %s\n",
|
||||||
@ -479,7 +344,7 @@ index c35fb66..1e6d217 100644
|
|||||||
: &((struct sockaddr_in *) nsap)->sin_addr),
|
: &((struct sockaddr_in *) nsap)->sin_addr),
|
||||||
tmpbuf, sizeof (tmpbuf))));
|
tmpbuf, sizeof (tmpbuf))));
|
||||||
|
|
||||||
@@ -660,6 +620,22 @@ libresolv_hidden_def (res_nsend)
|
@@ -660,6 +623,21 @@ libresolv_hidden_def (res_nsend)
|
||||||
|
|
||||||
/* Private */
|
/* Private */
|
||||||
|
|
||||||
@ -487,22 +352,21 @@ index c35fb66..1e6d217 100644
|
|||||||
+get_nsaddr (res_state statp, int n)
|
+get_nsaddr (res_state statp, int n)
|
||||||
+{
|
+{
|
||||||
+
|
+
|
||||||
+ if (!statp->nsaddr_list[n].sin_family && EXT(statp).ext)
|
+ if (statp->nsaddr_list[n].sin_family == 0 && EXT(statp).nsaddrs[n] != NULL)
|
||||||
+ /* - EXT(statp).ext->nsaddrs[n] holds an address that is larger
|
+ /* EXT(statp).nsaddrs[n] holds an address that is larger than
|
||||||
+ than struct sockaddr, and
|
+ struct sockaddr, and user code did not update
|
||||||
+ - user code did not update statp->nsaddr_list[n]. */
|
+ statp->nsaddr_list[n]. */
|
||||||
+ return &EXT(statp).ext->nsaddrs[n].s;
|
+ return (struct sockaddr *) EXT(statp).nsaddrs[n];
|
||||||
+ else
|
+ else
|
||||||
+ /* - user code updated statp->nsaddr_list[n], or
|
+ /* User code updated statp->nsaddr_list[n], or statp->nsaddr_list[n]
|
||||||
+ - statp->nsaddr_list[n] has the same content as
|
+ has the same content as EXT(statp).nsaddrs[n]. */
|
||||||
+ EXT(statp).ext->nsaddrs[n]. */
|
|
||||||
+ return (struct sockaddr *) (void *) &statp->nsaddr_list[n];
|
+ return (struct sockaddr *) (void *) &statp->nsaddr_list[n];
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
static int
|
static int
|
||||||
send_vc(res_state statp,
|
send_vc(res_state statp,
|
||||||
const u_char *buf, int buflen, const u_char *buf2, int buflen2,
|
const u_char *buf, int buflen, const u_char *buf2, int buflen2,
|
||||||
@@ -674,7 +650,7 @@ send_vc(res_state statp,
|
@@ -674,7 +652,7 @@ send_vc(res_state statp,
|
||||||
// XXX REMOVE
|
// XXX REMOVE
|
||||||
// int anssiz = *anssizp;
|
// int anssiz = *anssizp;
|
||||||
HEADER *anhp = (HEADER *) ans;
|
HEADER *anhp = (HEADER *) ans;
|
||||||
@ -511,7 +375,7 @@ index c35fb66..1e6d217 100644
|
|||||||
int truncating, connreset, n;
|
int truncating, connreset, n;
|
||||||
/* On some architectures compiler might emit a warning indicating
|
/* On some architectures compiler might emit a warning indicating
|
||||||
'resplen' may be used uninitialized. However if buf2 == NULL
|
'resplen' may be used uninitialized. However if buf2 == NULL
|
||||||
@@ -711,8 +687,8 @@ send_vc(res_state statp,
|
@@ -711,8 +689,8 @@ send_vc(res_state statp,
|
||||||
|
|
||||||
if (getpeername(statp->_vcsock,
|
if (getpeername(statp->_vcsock,
|
||||||
(struct sockaddr *)&peer, &size) < 0 ||
|
(struct sockaddr *)&peer, &size) < 0 ||
|
||||||
@ -522,7 +386,7 @@ index c35fb66..1e6d217 100644
|
|||||||
statp->_flags &= ~RES_F_VC;
|
statp->_flags &= ~RES_F_VC;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -721,20 +697,19 @@ send_vc(res_state statp,
|
@@ -721,20 +699,19 @@ send_vc(res_state statp,
|
||||||
if (statp->_vcsock >= 0)
|
if (statp->_vcsock >= 0)
|
||||||
__res_iclose(statp, false);
|
__res_iclose(statp, false);
|
||||||
|
|
||||||
@ -547,7 +411,7 @@ index c35fb66..1e6d217 100644
|
|||||||
__res_iclose(statp, false);
|
__res_iclose(statp, false);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -945,8 +920,7 @@ static int
|
@@ -945,8 +922,7 @@ static int
|
||||||
reopen (res_state statp, int *terrno, int ns)
|
reopen (res_state statp, int *terrno, int ns)
|
||||||
{
|
{
|
||||||
if (EXT(statp).nssocks[ns] == -1) {
|
if (EXT(statp).nssocks[ns] == -1) {
|
||||||
@ -557,34 +421,6 @@ index c35fb66..1e6d217 100644
|
|||||||
socklen_t slen;
|
socklen_t slen;
|
||||||
|
|
||||||
/* only try IPv6 if IPv6 NS and if not failed before */
|
/* only try IPv6 if IPv6 NS and if not failed before */
|
||||||
diff --git a/resolv/resolv.h b/resolv/resolv.h
|
|
||||||
index 53c3bba..dffd1db 100644
|
|
||||||
--- a/resolv/resolv.h
|
|
||||||
+++ b/resolv/resolv.h
|
|
||||||
@@ -100,6 +100,7 @@ typedef res_sendhookact (*res_send_rhook) (const struct sockaddr_in *__ns,
|
|
||||||
# define RES_MAXRETRY 5 /* only for resolv.conf/RES_OPTIONS */
|
|
||||||
# define RES_DFLRETRY 2 /* Default #/tries. */
|
|
||||||
# define RES_MAXTIME 65535 /* Infinity, in milliseconds. */
|
|
||||||
+struct __res_state_ext;
|
|
||||||
|
|
||||||
struct __res_state {
|
|
||||||
int retrans; /* retransmition time interval */
|
|
||||||
@@ -133,11 +134,11 @@ struct __res_state {
|
|
||||||
char pad[52]; /* On an i386 this means 512b total. */
|
|
||||||
struct {
|
|
||||||
u_int16_t nscount;
|
|
||||||
- u_int16_t nsmap[MAXNS];
|
|
||||||
+ u_int16_t __glibc_reserved1[MAXNS];
|
|
||||||
int nssocks[MAXNS];
|
|
||||||
- u_int16_t nscount6;
|
|
||||||
- u_int16_t nsinit;
|
|
||||||
- struct sockaddr_in6 *nsaddrs[MAXNS];
|
|
||||||
+ u_int16_t __glibc_reserved2[2];
|
|
||||||
+ struct __res_state_ext *ext; /* extension for IPv6 */
|
|
||||||
+ void *__glibc_reserved3[MAXNS-1];
|
|
||||||
#ifdef _LIBC
|
|
||||||
unsigned long long int initstamp
|
|
||||||
__attribute__((packed));
|
|
||||||
--
|
--
|
||||||
2.3.0
|
2.3.2
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user