Blame SOURCES/glibc-rh677316-RES_USE_INET6.patch

fa3bfd
Backport this upstream commit, but without the resolv/resolv.h change
fa3bfd
which introduces the deprecation warning:
fa3bfd
fa3bfd
commit b76e065991ec01299225d9da90a627ebe6c1ac97
fa3bfd
Author: Florian Weimer <fweimer@redhat.com>
fa3bfd
Date:   Tue Oct 4 11:52:10 2016 +0200
fa3bfd
fa3bfd
    resolv: Deprecate the "inet6" option and RES_USE_INET6 [BZ #19582]
fa3bfd
fa3bfd
No Makefile changes are needed here because we have not backported the
fa3bfd
resolver testsuite at this point.  Furthermore, due to the lack of
fa3bfd
actual RES_USE_INET6 deprecation, resolv/gethnamaddr.c is not modified
fa3bfd
in this patch (because it still compiles).
fa3bfd
fa3bfd
diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
fa3bfd
index d79b0bd9c79173c8..fa2d79e7b69da57b 100644
fa3bfd
--- a/nis/nss_nis/nis-hosts.c
fa3bfd
+++ b/nis/nss_nis/nis-hosts.c
fa3bfd
@@ -28,7 +28,7 @@
fa3bfd
 #include <string.h>
fa3bfd
 #include <netinet/in.h>
fa3bfd
 #include <arpa/inet.h>
fa3bfd
-#include <resolv.h>
fa3bfd
+#include <resolv/resolv-internal.h>
fa3bfd
 #include <bits/libc-lock.h>
fa3bfd
 #include <rpcsvc/yp.h>
fa3bfd
 #include <rpcsvc/ypclnt.h>
fa3bfd
@@ -232,8 +232,8 @@ _nss_nis_gethostent_r (struct hostent *host, char *buffer, size_t buflen,
fa3bfd
   __libc_lock_lock (lock);
fa3bfd
 
fa3bfd
   status = internal_nis_gethostent_r (host, buffer, buflen, errnop, h_errnop,
fa3bfd
-			((_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET),
fa3bfd
-			((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0 ));
fa3bfd
+			(res_use_inet6 () ? AF_INET6 : AF_INET),
fa3bfd
+			(res_use_inet6 () ? AI_V4MAPPED : 0 ));
fa3bfd
 
fa3bfd
   __libc_lock_unlock (lock);
fa3bfd
 
fa3bfd
@@ -345,7 +345,7 @@ _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host,
fa3bfd
 
fa3bfd
   return internal_gethostbyname2_r (name, af, host, buffer, buflen, errnop,
fa3bfd
 				    h_errnop,
fa3bfd
-			((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0));
fa3bfd
+			(res_use_inet6 () ? AI_V4MAPPED : 0));
fa3bfd
 }
fa3bfd
 
fa3bfd
 
fa3bfd
@@ -353,7 +353,7 @@ enum nss_status
fa3bfd
 _nss_nis_gethostbyname_r (const char *name, struct hostent *host, char *buffer,
fa3bfd
 			  size_t buflen, int *errnop, int *h_errnop)
fa3bfd
 {
fa3bfd
-  if (_res.options & RES_USE_INET6)
fa3bfd
+  if (res_use_inet6 ())
fa3bfd
     {
fa3bfd
       enum nss_status status;
fa3bfd
 
fa3bfd
@@ -427,9 +427,8 @@ _nss_nis_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af,
fa3bfd
   free (result);
fa3bfd
 
fa3bfd
   int parse_res = parse_line (p, host, data, buflen, errnop, af,
fa3bfd
-			      ((_res.options & RES_USE_INET6)
fa3bfd
-			       ? AI_V4MAPPED : 0));
fa3bfd
-  if (__builtin_expect (parse_res < 1, 0))
fa3bfd
+			      (res_use_inet6 () ? AI_V4MAPPED : 0));
fa3bfd
+  if (__glibc_unlikely (parse_res < 1))
fa3bfd
     {
fa3bfd
       if (parse_res == -1)
fa3bfd
 	{
fa3bfd
diff --git a/nis/nss_nisplus/nisplus-hosts.c b/nis/nss_nisplus/nisplus-hosts.c
fa3bfd
index 772d71097d6a2442..fb7461579b5408c9 100644
fa3bfd
--- a/nis/nss_nisplus/nisplus-hosts.c
fa3bfd
+++ b/nis/nss_nisplus/nisplus-hosts.c
fa3bfd
@@ -43,6 +43,7 @@ static u_long tablename_len;
fa3bfd
 	(NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len)
fa3bfd
 
fa3bfd
 /* Get implementation for some internal functions. */
fa3bfd
+#include <resolv/resolv-internal.h>
fa3bfd
 #include <resolv/mapv4v6addr.h>
fa3bfd
 
fa3bfd
 
fa3bfd
@@ -321,7 +322,7 @@ internal_nisplus_gethostent_r (struct hostent *host, char *buffer,
fa3bfd
 	    }
fa3bfd
 	}
fa3bfd
 
fa3bfd
-      if (_res.options & RES_USE_INET6)
fa3bfd
+      if (res_use_inet6 ())
fa3bfd
 	parse_res = _nss_nisplus_parse_hostent (result, AF_INET6, host, buffer,
fa3bfd
 						buflen, errnop, AI_V4MAPPED);
fa3bfd
       else
fa3bfd
@@ -488,7 +489,7 @@ _nss_nisplus_gethostbyname2_r (const char *name, int af, struct hostent *host,
fa3bfd
 
fa3bfd
   return internal_gethostbyname2_r (name, af, host, buffer, buflen, errnop,
fa3bfd
 				    herrnop,
fa3bfd
-			 ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0));
fa3bfd
+				    (res_use_inet6 () ? AI_V4MAPPED : 0));
fa3bfd
 }
fa3bfd
 
fa3bfd
 
fa3bfd
@@ -497,7 +498,7 @@ _nss_nisplus_gethostbyname_r (const char *name, struct hostent *host,
fa3bfd
 			      char *buffer, size_t buflen, int *errnop,
fa3bfd
 			      int *h_errnop)
fa3bfd
 {
fa3bfd
-  if (_res.options & RES_USE_INET6)
fa3bfd
+  if (res_use_inet6 ())
fa3bfd
     {
fa3bfd
       enum nss_status status;
fa3bfd
 
fa3bfd
@@ -558,7 +559,7 @@ _nss_nisplus_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af,
fa3bfd
 
fa3bfd
   parse_res = _nss_nisplus_parse_hostent (result, af, host,
fa3bfd
 					  buffer, buflen, errnop,
fa3bfd
-					  ((_res.options & RES_USE_INET6)
fa3bfd
+					  (res_use_inet6 ()
fa3bfd
 					   ? AI_V4MAPPED : 0));
fa3bfd
   nis_freeresult (result);
fa3bfd
 
fa3bfd
diff --git a/nscd/aicache.c b/nscd/aicache.c
fa3bfd
index abab042757920811..0ee25247cd464940 100644
fa3bfd
--- a/nscd/aicache.c
fa3bfd
+++ b/nscd/aicache.c
fa3bfd
@@ -25,6 +25,7 @@
fa3bfd
 #include <time.h>
fa3bfd
 #include <unistd.h>
fa3bfd
 #include <sys/mman.h>
fa3bfd
+#include <resolv/resolv-internal.h>
fa3bfd
 #include <resolv/res_hconf.h>
fa3bfd
 
fa3bfd
 #include "dbg_log.h"
fa3bfd
@@ -112,7 +113,7 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
fa3bfd
      IPv6 addresses.  Currently this is decided by setting the
fa3bfd
      RES_USE_INET6 bit in _res.options.  */
fa3bfd
   int old_res_options = _res.options;
fa3bfd
-  _res.options &= ~RES_USE_INET6;
fa3bfd
+  _res.options &= ~DEPRECATED_RES_USE_INET6;
fa3bfd
 
fa3bfd
   size_t tmpbuf6len = 1024;
fa3bfd
   char *tmpbuf6 = alloca (tmpbuf6len);
fa3bfd
@@ -537,7 +538,7 @@ next_nip:
fa3bfd
    }
fa3bfd
 
fa3bfd
  out:
fa3bfd
-  _res.options |= old_res_options & RES_USE_INET6;
fa3bfd
+  _res.options |= old_res_options & DEPRECATED_RES_USE_INET6;
fa3bfd
 
fa3bfd
   if (dataset != NULL && !alloca_used)
fa3bfd
     {
fa3bfd
diff --git a/nscd/nscd_gethst_r.c b/nscd/nscd_gethst_r.c
fa3bfd
index d64ad2e7b6c9e58b..41488ed6c033ffcd 100644
fa3bfd
--- a/nscd/nscd_gethst_r.c
fa3bfd
+++ b/nscd/nscd_gethst_r.c
fa3bfd
@@ -17,7 +17,7 @@
fa3bfd
    <http://www.gnu.org/licenses/>.  */
fa3bfd
 
fa3bfd
 #include <errno.h>
fa3bfd
-#include <resolv.h>
fa3bfd
+#include <resolv/resolv-internal.h>
fa3bfd
 #include <stdio.h>
fa3bfd
 #include <string.h>
fa3bfd
 #include <arpa/nameser.h>
fa3bfd
@@ -41,7 +41,7 @@ __nscd_gethostbyname_r (const char *name, struct hostent *resultbuf,
fa3bfd
 {
fa3bfd
   request_type reqtype;
fa3bfd
 
fa3bfd
-  reqtype = (_res.options & RES_USE_INET6) ? GETHOSTBYNAMEv6 : GETHOSTBYNAME;
fa3bfd
+  reqtype = res_use_inet6 () ? GETHOSTBYNAMEv6 : GETHOSTBYNAME;
fa3bfd
 
fa3bfd
   return nscd_gethst_r (name, strlen (name) + 1, reqtype, resultbuf,
fa3bfd
 			buffer, buflen, result, h_errnop);
fa3bfd
diff --git a/nss/digits_dots.c b/nss/digits_dots.c
fa3bfd
index ee530c69610d5393..7a2b57bdebe03408 100644
fa3bfd
--- a/nss/digits_dots.c
fa3bfd
+++ b/nss/digits_dots.c
fa3bfd
@@ -22,7 +22,7 @@
fa3bfd
 #include <stdlib.h>
fa3bfd
 #include <ctype.h>
fa3bfd
 #include <wctype.h>
fa3bfd
-#include <resolv.h>
fa3bfd
+#include <resolv/resolv-internal.h>
fa3bfd
 #include <netdb.h>
fa3bfd
 #include <arpa/inet.h>
fa3bfd
 #include "nsswitch.h"
fa3bfd
@@ -80,7 +80,7 @@ __nss_hostname_digits_dots (const char *name, struct hostent *resbuf,
fa3bfd
 	  break;
fa3bfd
 
fa3bfd
 	default:
fa3bfd
-	  af = (_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET;
fa3bfd
+	  af = res_use_inet6 () ? AF_INET6 : AF_INET;
fa3bfd
 	  addr_size = af == AF_INET6 ? IN6ADDRSZ : INADDRSZ;
fa3bfd
 	  break;
fa3bfd
 	}
fa3bfd
@@ -167,7 +167,7 @@ __nss_hostname_digits_dots (const char *name, struct hostent *resbuf,
fa3bfd
 		  (*h_addr_ptrs)[0] = (char *) host_addr;
fa3bfd
 		  (*h_addr_ptrs)[1] = NULL;
fa3bfd
 		  resbuf->h_addr_list = *h_addr_ptrs;
fa3bfd
-		  if (af == AF_INET && (_res.options & RES_USE_INET6))
fa3bfd
+		  if (af == AF_INET && res_use_inet6 ())
fa3bfd
 		    {
fa3bfd
 		      /* We need to change the IP v4 address into the
fa3bfd
 			 IP v6 address.  */
fa3bfd
@@ -211,7 +211,7 @@ __nss_hostname_digits_dots (const char *name, struct hostent *resbuf,
fa3bfd
 	  switch (af)
fa3bfd
 	    {
fa3bfd
 	    default:
fa3bfd
-	      af = (_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET;
fa3bfd
+	      af = res_use_inet6 () ? AF_INET6 : AF_INET;
fa3bfd
 	      if (af == AF_INET6)
fa3bfd
 		{
fa3bfd
 		  addr_size = IN6ADDRSZ;
fa3bfd
diff --git a/nss/nss_files/files-hosts.c b/nss/nss_files/files-hosts.c
fa3bfd
index 6c06b89dc179fd9a..b25ebe5ed19bdded 100644
fa3bfd
--- a/nss/nss_files/files-hosts.c
fa3bfd
+++ b/nss/nss_files/files-hosts.c
fa3bfd
@@ -21,7 +21,7 @@
fa3bfd
 #include <arpa/inet.h>
fa3bfd
 #include <arpa/nameser.h>
fa3bfd
 #include <netdb.h>
fa3bfd
-#include <resolv.h>
fa3bfd
+#include <resolv/resolv-internal.h>
fa3bfd
 
fa3bfd
 
fa3bfd
 /* Get implementation for some internal functions.  */
fa3bfd
@@ -98,8 +98,8 @@ LINE_PARSER
fa3bfd
  })
fa3bfd
 
fa3bfd
 #define EXTRA_ARGS_VALUE \
fa3bfd
-  , ((_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET),		      \
fa3bfd
-  ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0)
fa3bfd
+  , (res_use_inet6 () ? AF_INET6 : AF_INET),		      \
fa3bfd
+  (res_use_inet6 () ? AI_V4MAPPED : 0)
fa3bfd
 #include "files-XXX.c"
fa3bfd
 #undef EXTRA_ARGS_VALUE
fa3bfd
 
fa3bfd
@@ -133,7 +133,7 @@ _nss_files_gethostbyname3_r (const char *name, int af, struct hostent *result,
fa3bfd
     {
fa3bfd
       /* XXX Is using _res to determine whether we want to convert IPv4
fa3bfd
          addresses to IPv6 addresses really the right thing to do?  */
fa3bfd
-      int flags = ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0);
fa3bfd
+      int flags = (res_use_inet6 () ? AI_V4MAPPED : 0);
fa3bfd
 
fa3bfd
       /* Tell getent function that we have repositioned the file pointer.  */
fa3bfd
       last_use = getby;
fa3bfd
@@ -358,7 +358,7 @@ _nss_files_gethostbyname_r (const char *name, struct hostent *result,
fa3bfd
 			    char *buffer, size_t buflen, int *errnop,
fa3bfd
 			    int *herrnop)
fa3bfd
 {
fa3bfd
-  int af = ((_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET);
fa3bfd
+  int af = (res_use_inet6 () ? AF_INET6 : AF_INET);
fa3bfd
 
fa3bfd
   return _nss_files_gethostbyname3_r (name, af, result, buffer, buflen,
fa3bfd
 				      errnop, herrnop, NULL, NULL);
fa3bfd
diff --git a/resolv/README b/resolv/README
fa3bfd
index 416205da77a15564..1a70bbb1dc615ac9 100644
fa3bfd
--- a/resolv/README
fa3bfd
+++ b/resolv/README
fa3bfd
@@ -84,11 +84,7 @@ code:
fa3bfd
 
fa3bfd
 * In Multi-threaded that manipulate the _res structure, calls to
fa3bfd
   functions like `gethostbyname' in threads other than the "main"
fa3bfd
-  thread won't be influenced by the those changes anymore.  So if you
fa3bfd
-  set RES_USE_INET6, a call to `gethostbyname' won't return any IPv6
fa3bfd
-  hosts anymore.  If you recompile such programs, manipulating the
fa3bfd
-  _res structure will affect the thread in which you do so instead of
fa3bfd
-  the "main" thread.
fa3bfd
+  thread won't be influenced by the those changes anymore.
fa3bfd
 
fa3bfd
 We recommend to use the new thread-safe interfaces in new code, since
fa3bfd
 the traditional interfaces have been deprecated by the BIND folks.
fa3bfd
diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
fa3bfd
index 774d575dd1ce22af..7fc154db5d3130a3 100644
fa3bfd
--- a/resolv/nss_dns/dns-host.c
fa3bfd
+++ b/resolv/nss_dns/dns-host.c
fa3bfd
@@ -82,7 +82,8 @@
fa3bfd
 
fa3bfd
 #include "nsswitch.h"
fa3bfd
 
fa3bfd
-/* Get implementation for some internal functions.  */
fa3bfd
+/* Get implementeation for some internal functions.  */
fa3bfd
+#include <resolv/resolv-internal.h>
fa3bfd
 #include <resolv/mapv4v6addr.h>
fa3bfd
 #include <resolv/mapv4v6hostent.h>
fa3bfd
 
fa3bfd
@@ -221,7 +222,7 @@ _nss_dns_gethostbyname3_r (const char *name, int af, struct hostent *result,
fa3bfd
       /* If we are looking for an IPv6 address and mapping is enabled
fa3bfd
 	 by having the RES_USE_INET6 bit in _res.options set, we try
fa3bfd
 	 another lookup.  */
fa3bfd
-      if (af == AF_INET6 && (_res.options & RES_USE_INET6))
fa3bfd
+      if (af == AF_INET6 && res_use_inet6 ())
fa3bfd
 	n = __libc_res_nsearch (&_res, name, C_IN, T_A, host_buffer.buf->buf,
fa3bfd
 				host_buffer.buf != orig_host_buffer
fa3bfd
 				? MAXPACKET : 1024, &host_buffer.ptr,
fa3bfd
@@ -266,7 +267,7 @@ _nss_dns_gethostbyname_r (const char *name, struct hostent *result,
fa3bfd
 {
fa3bfd
   enum nss_status status = NSS_STATUS_NOTFOUND;
fa3bfd
 
fa3bfd
-  if (_res.options & RES_USE_INET6)
fa3bfd
+  if (res_use_inet6 ())
fa3bfd
     status = _nss_dns_gethostbyname3_r (name, AF_INET6, result, buffer,
fa3bfd
 					buflen, errnop, h_errnop, NULL, NULL);
fa3bfd
   if (status == NSS_STATUS_NOTFOUND)
fa3bfd
@@ -519,17 +520,6 @@ _nss_dns_gethostbyaddr2_r (const void *addr, socklen_t len, int af,
fa3bfd
   memcpy (host_data->host_addr, addr, len);
fa3bfd
   host_data->h_addr_ptrs[0] = (char *) host_data->host_addr;
fa3bfd
   host_data->h_addr_ptrs[1] = NULL;
fa3bfd
-#if 0
fa3bfd
-  /* XXX I think this is wrong.  Why should an IPv4 address be
fa3bfd
-     converted to IPv6 if the user explicitly asked for IPv4?  */
fa3bfd
-  if (af == AF_INET && (_res.options & RES_USE_INET6))
fa3bfd
-    {
fa3bfd
-      map_v4v6_address ((char *) host_data->host_addr,
fa3bfd
-			(char *) host_data->host_addr);
fa3bfd
-      result->h_addrtype = AF_INET6;
fa3bfd
-      result->h_length = IN6ADDRSZ;
fa3bfd
-    }
fa3bfd
-#endif
fa3bfd
   *h_errnop = NETDB_SUCCESS;
fa3bfd
   return NSS_STATUS_SUCCESS;
fa3bfd
 }
fa3bfd
diff --git a/resolv/res_debug.c b/resolv/res_debug.c
fa3bfd
index 3daa44e273db5a41..6549e4ba5ee77f93 100644
fa3bfd
--- a/resolv/res_debug.c
fa3bfd
+++ b/resolv/res_debug.c
fa3bfd
@@ -106,7 +106,7 @@ static const char rcsid[] = "$BINDId: res_debug.c,v 8.34 2000/02/29 05:30:55 vix
fa3bfd
 #include <errno.h>
fa3bfd
 #include <math.h>
fa3bfd
 #include <netdb.h>
fa3bfd
-#include <resolv.h>
fa3bfd
+#include <resolv/resolv-internal.h>
fa3bfd
 #include <stdio.h>
fa3bfd
 #include <stdlib.h>
fa3bfd
 #include <string.h>
fa3bfd
@@ -582,7 +582,7 @@ p_option(u_long option) {
fa3bfd
 	case RES_DNSRCH:	return "dnsrch";
fa3bfd
 	case RES_INSECURE1:	return "insecure1";
fa3bfd
 	case RES_INSECURE2:	return "insecure2";
fa3bfd
-	case RES_USE_INET6:	return "inet6";
fa3bfd
+	case DEPRECATED_RES_USE_INET6:	return "inet6";
fa3bfd
 	case RES_ROTATE:	return "rotate";
fa3bfd
 	case RES_NOCHECKNAME:	return "no-check-names";
fa3bfd
 	case RES_USEBSTRING:	return "ip6-bytstring";
fa3bfd
diff --git a/resolv/res_init.c b/resolv/res_init.c
fa3bfd
index 2e3d0f746e855aff..0ed74e0520131418 100644
fa3bfd
--- a/resolv/res_init.c
fa3bfd
+++ b/resolv/res_init.c
fa3bfd
@@ -71,7 +71,7 @@ static const char rcsid[] = "$BINDId: res_init.c,v 8.16 2000/05/09 07:10:12 vixi
fa3bfd
 
fa3bfd
 #include <ctype.h>
fa3bfd
 #include <netdb.h>
fa3bfd
-#include <resolv.h>
fa3bfd
+#include <resolv/resolv-internal.h>
fa3bfd
 #include <stdio.h>
fa3bfd
 #include <stdio_ext.h>
fa3bfd
 #include <stdlib.h>
fa3bfd
@@ -530,7 +530,7 @@ res_setoptions(res_state statp, const char *options, const char *source) {
fa3bfd
 		    unsigned long int flag;
fa3bfd
 		  } options[] = {
fa3bfd
 #define STRnLEN(str) str, sizeof (str) - 1
fa3bfd
-		    { STRnLEN ("inet6"), 0, RES_USE_INET6 },
fa3bfd
+		    { STRnLEN ("inet6"), 0, DEPRECATED_RES_USE_INET6 },
fa3bfd
 		    { STRnLEN ("ip6-bytestring"), 0, RES_USEBSTRING },
fa3bfd
 		    { STRnLEN ("no-ip6-dotint"), 0, RES_NOIP6DOTINT },
fa3bfd
 		    { STRnLEN ("ip6-dotint"), 1, ~RES_NOIP6DOTINT },
fa3bfd
diff --git a/resolv/resolv-internal.h b/resolv/resolv-internal.h
fa3bfd
new file mode 100644
fa3bfd
index 0000000000000000..269758c416544cb4
fa3bfd
--- /dev/null
fa3bfd
+++ b/resolv/resolv-internal.h
fa3bfd
@@ -0,0 +1,35 @@
fa3bfd
+/* libresolv interfaces for internal use across glibc.
fa3bfd
+   Copyright (C) 2016 Free Software Foundation, Inc.
fa3bfd
+   This file is part of the GNU C Library.
fa3bfd
+
fa3bfd
+   The GNU C Library is free software; you can redistribute it and/or
fa3bfd
+   modify it under the terms of the GNU Lesser General Public
fa3bfd
+   License as published by the Free Software Foundation; either
fa3bfd
+   version 2.1 of the License, or (at your option) any later version.
fa3bfd
+
fa3bfd
+   The GNU C Library is distributed in the hope that it will be useful,
fa3bfd
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
fa3bfd
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
fa3bfd
+   Lesser General Public License for more details.
fa3bfd
+
fa3bfd
+   You should have received a copy of the GNU Lesser General Public
fa3bfd
+   License along with the GNU C Library; if not, see
fa3bfd
+   <http://www.gnu.org/licenses/>.  */
fa3bfd
+
fa3bfd
+#ifndef _RESOLV_INTERNAL_H
fa3bfd
+#define _RESOLV_INTERNAL_H 1
fa3bfd
+
fa3bfd
+#include <resolv.h>
fa3bfd
+#include <stdbool.h>
fa3bfd
+
fa3bfd
+/* Internal version of RES_USE_INET6 which does not trigger a
fa3bfd
+   deprecation warning.  */
fa3bfd
+#define DEPRECATED_RES_USE_INET6 0x00002000
fa3bfd
+
fa3bfd
+static inline bool
fa3bfd
+res_use_inet6 (void)
fa3bfd
+{
fa3bfd
+  return _res.options & DEPRECATED_RES_USE_INET6;
fa3bfd
+}
fa3bfd
+
fa3bfd
+#endif  /* _RESOLV_INTERNAL_H */
fa3bfd
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
fa3bfd
index a678d8d7e8b23d1d..7a6cf71c170ec42f 100644
fa3bfd
--- a/sysdeps/posix/getaddrinfo.c
fa3bfd
+++ b/sysdeps/posix/getaddrinfo.c
fa3bfd
@@ -41,7 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
fa3bfd
 #include <ifaddrs.h>
fa3bfd
 #include <netdb.h>
fa3bfd
 #include <nss.h>
fa3bfd
-#include <resolv.h>
fa3bfd
+#include <resolv/resolv-internal.h>
fa3bfd
 #include <stdbool.h>
fa3bfd
 #include <stdio.h>
fa3bfd
 #include <stdio_ext.h>
fa3bfd
@@ -222,7 +222,7 @@ gaih_inet_serv (const char *servicename, const struct gaih_typeproto *tp,
fa3bfd
       if (herrno == NETDB_INTERNAL)					      \
fa3bfd
 	{								      \
fa3bfd
 	  __set_h_errno (herrno);					      \
fa3bfd
-	  _res.options |= old_res_options & RES_USE_INET6;		      \
fa3bfd
+	  _res.options |= old_res_options & DEPRECATED_RES_USE_INET6;	      \
fa3bfd
 	  result = -EAI_SYSTEM;						      \
fa3bfd
 	  goto free_and_return;						      \
fa3bfd
 	}								      \
fa3bfd
@@ -839,7 +839,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
fa3bfd
 	     addresses to IPv6 addresses.  Currently this is decided
fa3bfd
 	     by setting the RES_USE_INET6 bit in _res.options.  */
fa3bfd
 	  old_res_options = _res.options;
fa3bfd
-	  _res.options &= ~RES_USE_INET6;
fa3bfd
+	  _res.options &= ~DEPRECATED_RES_USE_INET6;
fa3bfd
 
fa3bfd
 	  size_t tmpbuflen = 1024 + sizeof(struct gaih_addrtuple);
fa3bfd
 	  malloc_tmpbuf = !__libc_use_alloca (alloca_used + tmpbuflen);
fa3bfd
@@ -900,7 +900,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
fa3bfd
 						2 * tmpbuflen);
fa3bfd
 			  if (newp == NULL)
fa3bfd
 			    {
fa3bfd
-			      _res.options |= old_res_options & RES_USE_INET6;
fa3bfd
+			      _res.options |= old_res_options & DEPRECATED_RES_USE_INET6;
fa3bfd
 			      result = -EAI_MEMORY;
fa3bfd
 			      goto free_and_return;
fa3bfd
 			    }
fa3bfd
@@ -1021,7 +1021,8 @@ gaih_inet (const char *name, const struct gaih_service *service,
fa3bfd
 				      if (canonbuf == NULL)
fa3bfd
 					{
fa3bfd
 					  _res.options
fa3bfd
-					    |= old_res_options & RES_USE_INET6;
fa3bfd
+					    |= old_res_options
fa3bfd
+					       & DEPRECATED_RES_USE_INET6;
fa3bfd
 					  result = -EAI_MEMORY;
fa3bfd
 					  goto free_and_return;
fa3bfd
 					}
fa3bfd
@@ -1082,7 +1083,7 @@ gaih_inet (const char *name, const struct gaih_service *service,
fa3bfd
 		nip = nip->next;
fa3bfd
 	    }
fa3bfd
 
fa3bfd
-	  _res.options |= old_res_options & RES_USE_INET6;
fa3bfd
+	  _res.options |= old_res_options & DEPRECATED_RES_USE_INET6;
fa3bfd
 
fa3bfd
 	  if (h_errno == NETDB_INTERNAL)
fa3bfd
 	    {