diff mbox

resolv: Deprecate the "inet6" option and RES_USE_INET6 [BZ #19582]

Message ID 20160909144045.38F43401494C7@oldenburg.str.redhat.com
State New
Headers show

Commit Message

Florian Weimer Sept. 9, 2016, 2:40 p.m. UTC
2016-09-09  Florian Weimer  <fweimer@redhat.com>

	[BZ #19582]
	Deprecate RES_USE_INET6.
	* misc/sys/cdefs.h (__glibc_macro_warning1)
	(__glibc_macro_warning): Define.
	* nis/nss_nis/nis-hosts.c (_nss_nis_gethostent_r)
	(_nss_nis_gethostbyname2_r, _nss_nis_gethostbyname_r)
	(_nss_nis_gethostbyaddr_r): Use res_use_inet6 instead of
	RES_USE_INET6.
	* nis/nss_nisplus/nisplus-hosts.c (internal_nisplus_gethostent_r)
	(_nss_nisplus_gethostbyname2_r, _nss_nisplus_gethostbyname_r)
	(_nss_nisplus_gethostbyaddr_r): Likewise.
	* nscd/aicache.c (addhstaiX): Use DEPRECATED_RES_USE_INET6 instead
	of res_use_inet6.
	* nscd/nscd_gethst_r.c (__nscd_gethostbyname_r): Use res_use_inet6
	instead of RES_USE_INET6.
	* nss/digits_dots.c (__nss_hostname_digits_dots): Likewise.
	* nss/nss_files/files-hosts.c (EXTRA_ARGS_VALUE)
	(_nss_files_gethostbyname3_r, _nss_files_gethostbyname_r):
	Likewise.
	* resolv/gethnamaddr.c (getanswer, gethostbyname, gethostbyname2)
	(gethostbyaddr, _gethtent, _gethtbyname): Likewise.
	* resolv/nss_dns/dns-host.c (_nss_dns_gethostbyname3_r)
	(_nss_dns_gethostbyname_r, _nss_dns_gethostbyaddr2_r): Likewise.
	* resolv/res_debug.c (p_option): Use DEPRECATED_RES_USE_INET6
	instead of RES_USE_INET6.
	* resolv/res_init.c (res_setoptions): Likewise.
	* resolv/resolv-internal.h: New file.
	* resolv/resolv.h (RES_USE_INET6): Mark as deprecated.
	* resolv/README (Using the resolver in multi-threaded code): Drop
	reference to RES_USE_INET6.
	* sysdeps/posix/getaddrinfo.c (gethosts, gaih_inet): Use
	DEPRECATED_RES_USE_INET6 instead of res_use_inet6.

Comments

Florian Weimer Sept. 9, 2016, 3:17 p.m. UTC | #1
On 09/09/2016 04:40 PM, Florian Weimer wrote:
> +# define __glibc_macro_warning1(message) _Pragma (#message))

There is a type here (extra ')'), which I have fixed.

It is difficult to test for the presence of the compile-time warning 
without the testing framework.

Florian
Florian Weimer Sept. 21, 2016, 9:10 p.m. UTC | #2
On 09/09/2016 04:40 PM, Florian Weimer wrote:
> +#if __GNUC_PREREQ (4,8)
> +# define __glibc_macro_warning1(message) _Pragma (#message)
> +# define __glibc_macro_warning(message) \
> +  __glibc_macro_warning1 (GCC warning message)
> +#else
> +# define __glibc_macro_warning(msg)
> +#endif

Any comments about this new warning mechanism?

Thanks,
Florian
diff mbox

Patch

diff --git a/NEWS b/NEWS
index ba1ec71..e01e941 100644
--- a/NEWS
+++ b/NEWS
@@ -40,6 +40,11 @@  Version 2.25
   for the Linux quota interface which predates kernel version 2.4.22 has
   been removed.
 
+* The "inet6" option in /etc/resolv.conf and the RES_USE_INET6 flag for
+  _res.flags are deprecated.  The flag was standardized in RFC 2133 with a
+  different meaning (making its behavior non-portable), and removed from the
+  standard in RFC 2553.  Applications should use getaddrinfo instead.
+
 Security related changes:
 
   On ARM EABI (32-bit), generating a backtrace for execution contexts which
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 6e9b840..04b8b68 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -466,4 +466,12 @@ 
 # endif
 #endif
 
+#if __GNUC_PREREQ (4,8)
+# define __glibc_macro_warning1(message) _Pragma (#message))
+# define __glibc_macro_warning(message) \
+  __glibc_macro_warning1 (GCC warning message)
+#else
+# define __glibc_macro_warning(msg)
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/nis/nss_nis/nis-hosts.c b/nis/nss_nis/nis-hosts.c
index d266cf2..a337797 100644
--- a/nis/nss_nis/nis-hosts.c
+++ b/nis/nss_nis/nis-hosts.c
@@ -27,7 +27,7 @@ 
 #include <string.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
-#include <resolv.h>
+#include <resolv/resolv-internal.h>
 #include <libc-lock.h>
 #include <rpcsvc/yp.h>
 #include <rpcsvc/ypclnt.h>
@@ -231,8 +231,8 @@  _nss_nis_gethostent_r (struct hostent *host, char *buffer, size_t buflen,
   __libc_lock_lock (lock);
 
   status = internal_nis_gethostent_r (host, buffer, buflen, errnop, h_errnop,
-			((_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET),
-			((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0 ));
+			(res_use_inet6 () ? AF_INET6 : AF_INET),
+			(res_use_inet6 () ? AI_V4MAPPED : 0 ));
 
   __libc_lock_unlock (lock);
 
@@ -351,7 +351,7 @@  _nss_nis_gethostbyname2_r (const char *name, int af, struct hostent *host,
 
   return internal_gethostbyname2_r (name, af, host, buffer, buflen, errnop,
 				    h_errnop,
-			((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0));
+			(res_use_inet6 () ? AI_V4MAPPED : 0));
 }
 
 
@@ -359,7 +359,7 @@  enum nss_status
 _nss_nis_gethostbyname_r (const char *name, struct hostent *host, char *buffer,
 			  size_t buflen, int *errnop, int *h_errnop)
 {
-  if (_res.options & RES_USE_INET6)
+  if (res_use_inet6 ())
     {
       enum nss_status status;
 
@@ -433,8 +433,7 @@  _nss_nis_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af,
   free (result);
 
   int parse_res = parse_line (p, host, data, buflen, errnop, af,
-			      ((_res.options & RES_USE_INET6)
-			       ? AI_V4MAPPED : 0));
+			      (res_use_inet6 () ? AI_V4MAPPED : 0));
   if (__glibc_unlikely (parse_res < 1))
     {
       if (parse_res == -1)
diff --git a/nis/nss_nisplus/nisplus-hosts.c b/nis/nss_nisplus/nisplus-hosts.c
index 2751e59..97a03aa 100644
--- a/nis/nss_nisplus/nisplus-hosts.c
+++ b/nis/nss_nisplus/nisplus-hosts.c
@@ -43,6 +43,7 @@  static u_long tablename_len;
 	(NIS_RES_OBJECT (res)[idx].EN_data.en_cols.en_cols_val[col].ec_value.ec_value_len)
 
 /* Get implementation for some internal functions. */
+#include <resolv/resolv-internal.h>
 #include <resolv/mapv4v6addr.h>
 
 
@@ -321,7 +322,7 @@  internal_nisplus_gethostent_r (struct hostent *host, char *buffer,
 	    }
 	}
 
-      if (_res.options & RES_USE_INET6)
+      if (res_use_inet6 ())
 	parse_res = _nss_nisplus_parse_hostent (result, AF_INET6, host, buffer,
 						buflen, errnop, AI_V4MAPPED);
       else
@@ -488,7 +489,7 @@  _nss_nisplus_gethostbyname2_r (const char *name, int af, struct hostent *host,
 
   return internal_gethostbyname2_r (name, af, host, buffer, buflen, errnop,
 				    herrnop,
-			 ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0));
+				    (res_use_inet6 () ? AI_V4MAPPED : 0));
 }
 
 
@@ -497,7 +498,7 @@  _nss_nisplus_gethostbyname_r (const char *name, struct hostent *host,
 			      char *buffer, size_t buflen, int *errnop,
 			      int *h_errnop)
 {
-  if (_res.options & RES_USE_INET6)
+  if (res_use_inet6 ())
     {
       enum nss_status status;
 
@@ -558,7 +559,7 @@  _nss_nisplus_gethostbyaddr_r (const void *addr, socklen_t addrlen, int af,
 
   parse_res = _nss_nisplus_parse_hostent (result, af, host,
 					  buffer, buflen, errnop,
-					  ((_res.options & RES_USE_INET6)
+					  (res_use_inet6 ()
 					   ? AI_V4MAPPED : 0));
   nis_freeresult (result);
 
diff --git a/nscd/aicache.c b/nscd/aicache.c
index 32c8f57..f955be7 100644
--- a/nscd/aicache.c
+++ b/nscd/aicache.c
@@ -25,6 +25,7 @@ 
 #include <time.h>
 #include <unistd.h>
 #include <sys/mman.h>
+#include <resolv/resolv-internal.h>
 #include <resolv/res_hconf.h>
 
 #include "dbg_log.h"
@@ -110,7 +111,7 @@  addhstaiX (struct database_dyn *db, int fd, request_header *req,
      IPv6 addresses.  Currently this is decided by setting the
      RES_USE_INET6 bit in _res.options.  */
   int old_res_options = _res.options;
-  _res.options &= ~RES_USE_INET6;
+  _res.options &= ~DEPRECATED_RES_USE_INET6;
 
   size_t tmpbuf6len = 1024;
   char *tmpbuf6 = alloca (tmpbuf6len);
@@ -535,7 +536,7 @@  next_nip:
    }
 
  out:
-  _res.options |= old_res_options & RES_USE_INET6;
+  _res.options |= old_res_options & DEPRECATED_RES_USE_INET6;
 
   if (dataset != NULL && !alloca_used)
     {
diff --git a/nscd/nscd_gethst_r.c b/nscd/nscd_gethst_r.c
index 7448add..820a2fe 100644
--- a/nscd/nscd_gethst_r.c
+++ b/nscd/nscd_gethst_r.c
@@ -17,7 +17,7 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
-#include <resolv.h>
+#include <resolv/resolv-internal.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdint.h>
@@ -42,7 +42,7 @@  __nscd_gethostbyname_r (const char *name, struct hostent *resultbuf,
 {
   request_type reqtype;
 
-  reqtype = (_res.options & RES_USE_INET6) ? GETHOSTBYNAMEv6 : GETHOSTBYNAME;
+  reqtype = res_use_inet6 () ? GETHOSTBYNAMEv6 : GETHOSTBYNAME;
 
   return nscd_gethst_r (name, strlen (name) + 1, reqtype, resultbuf,
 			buffer, buflen, result, h_errnop);
diff --git a/nss/digits_dots.c b/nss/digits_dots.c
index 57f0e4d..14f5b56 100644
--- a/nss/digits_dots.c
+++ b/nss/digits_dots.c
@@ -22,7 +22,7 @@ 
 #include <stdlib.h>
 #include <ctype.h>
 #include <wctype.h>
-#include <resolv.h>
+#include <resolv/resolv-internal.h>
 #include <netdb.h>
 #include <arpa/inet.h>
 #include "nsswitch.h"
@@ -80,7 +80,7 @@  __nss_hostname_digits_dots (const char *name, struct hostent *resbuf,
 	  break;
 
 	default:
-	  af = (_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET;
+	  af = res_use_inet6 () ? AF_INET6 : AF_INET;
 	  addr_size = af == AF_INET6 ? IN6ADDRSZ : INADDRSZ;
 	  break;
 	}
@@ -167,7 +167,7 @@  __nss_hostname_digits_dots (const char *name, struct hostent *resbuf,
 		  (*h_addr_ptrs)[0] = (char *) host_addr;
 		  (*h_addr_ptrs)[1] = NULL;
 		  resbuf->h_addr_list = *h_addr_ptrs;
-		  if (af == AF_INET && (_res.options & RES_USE_INET6))
+		  if (af == AF_INET && res_use_inet6 ())
 		    {
 		      /* We need to change the IP v4 address into the
 			 IP v6 address.  */
@@ -211,7 +211,7 @@  __nss_hostname_digits_dots (const char *name, struct hostent *resbuf,
 	  switch (af)
 	    {
 	    default:
-	      af = (_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET;
+	      af = res_use_inet6 () ? AF_INET6 : AF_INET;
 	      if (af == AF_INET6)
 		{
 		  addr_size = IN6ADDRSZ;
diff --git a/nss/nss_files/files-hosts.c b/nss/nss_files/files-hosts.c
index 2a4a665..8f330b1 100644
--- a/nss/nss_files/files-hosts.c
+++ b/nss/nss_files/files-hosts.c
@@ -21,7 +21,7 @@ 
 #include <arpa/inet.h>
 #include <arpa/nameser.h>
 #include <netdb.h>
-#include <resolv.h>
+#include <resolv/resolv-internal.h>
 
 
 /* Get implementation for some internal functions.  */
@@ -98,8 +98,8 @@  LINE_PARSER
  })
 
 #define EXTRA_ARGS_VALUE \
-  , ((_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET),		      \
-  ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0)
+  , (res_use_inet6 () ? AF_INET6 : AF_INET),		      \
+  (res_use_inet6 () ? AI_V4MAPPED : 0)
 #include "files-XXX.c"
 #undef EXTRA_ARGS_VALUE
 
@@ -132,7 +132,7 @@  _nss_files_gethostbyname3_r (const char *name, int af, struct hostent *result,
     {
       /* XXX Is using _res to determine whether we want to convert IPv4
          addresses to IPv6 addresses really the right thing to do?  */
-      int flags = ((_res.options & RES_USE_INET6) ? AI_V4MAPPED : 0);
+      int flags = (res_use_inet6 () ? AI_V4MAPPED : 0);
 
       while ((status = internal_getent (stream, result, buffer, buflen, errnop,
 					herrnop, af, flags))
@@ -351,7 +351,7 @@  _nss_files_gethostbyname_r (const char *name, struct hostent *result,
 			    char *buffer, size_t buflen, int *errnop,
 			    int *herrnop)
 {
-  int af = ((_res.options & RES_USE_INET6) ? AF_INET6 : AF_INET);
+  int af = (res_use_inet6 () ? AF_INET6 : AF_INET);
 
   return _nss_files_gethostbyname3_r (name, af, result, buffer, buflen,
 				      errnop, herrnop, NULL, NULL);
diff --git a/resolv/README b/resolv/README
index 17aa631..c500251 100644
--- a/resolv/README
+++ b/resolv/README
@@ -80,11 +80,7 @@  code:
 
 * In Multi-threaded that manipulate the _res structure, calls to
   functions like `gethostbyname' in threads other than the "main"
-  thread won't be influenced by the those changes anymore.  So if you
-  set RES_USE_INET6, a call to `gethostbyname' won't return any IPv6
-  hosts anymore.  If you recompile such programs, manipulating the
-  _res structure will affect the thread in which you do so instead of
-  the "main" thread.
+  thread won't be influenced by the those changes anymore.
 
 We recommend to use the new thread-safe interfaces in new code, since
 the traditional interfaces have been deprecated by the BIND folks.
diff --git a/resolv/gethnamaddr.c b/resolv/gethnamaddr.c
index 9ad2c30..ef8aaba 100644
--- a/resolv/gethnamaddr.c
+++ b/resolv/gethnamaddr.c
@@ -63,7 +63,7 @@ 
 
 #include <stdio.h>
 #include <netdb.h>
-#include <resolv.h>
+#include <resolv/resolv-internal.h>
 #include <ctype.h>
 #include <errno.h>
 #include <stdlib.h>
@@ -409,7 +409,7 @@  getanswer (const querybuf *answer, int anslen, const char *qname, int qtype)
 			bp += n;
 			buflen -= n;
 		}
-		if (_res.options & RES_USE_INET6)
+		if (res_use_inet6 ())
 			map_v4v6_hostent(&host, &bp, &buflen);
 		__set_h_errno (NETDB_SUCCESS);
 		return (&host);
@@ -431,7 +431,7 @@  gethostbyname (const char *name)
 		__set_h_errno (NETDB_INTERNAL);
 		return (NULL);
 	}
-	if (_res.options & RES_USE_INET6) {
+	if (res_use_inet6 ()) {
 		hp = gethostbyname2(name, AF_INET6);
 		if (hp)
 			return (hp);
@@ -512,7 +512,7 @@  gethostbyname2 (const char *name, int af)
 				h_addr_ptrs[0] = (char *)host_addr;
 				h_addr_ptrs[1] = NULL;
 				host.h_addr_list = h_addr_ptrs;
-				if (_res.options & RES_USE_INET6)
+				if (res_use_inet6 ())
 					map_v4v6_hostent(&host, &bp, &len);
 				__set_h_errno (NETDB_SUCCESS);
 				return (&host);
@@ -666,7 +666,7 @@  gethostbyaddr (const void *addr, socklen_t len, int af)
 	memmove(host_addr, addr, len);
 	h_addr_ptrs[0] = (char *)host_addr;
 	h_addr_ptrs[1] = NULL;
-	if (af == AF_INET && (_res.options & RES_USE_INET6)) {
+	if (af == AF_INET && res_use_inet6 ()) {
 		map_v4v6_address((char*)host_addr, (char*)host_addr);
 		hp->h_addrtype = AF_INET6;
 		hp->h_length = IN6ADDRSZ;
@@ -723,7 +723,7 @@  _gethtent (void)
 		af = AF_INET6;
 		len = IN6ADDRSZ;
 	} else if (inet_pton(AF_INET, p, host_addr) > 0) {
-		if (_res.options & RES_USE_INET6) {
+		if (res_use_inet6 ()) {
 			map_v4v6_address((char*)host_addr, (char*)host_addr);
 			af = AF_INET6;
 			len = IN6ADDRSZ;
@@ -766,7 +766,7 @@  _gethtbyname (const char *name)
 {
 	struct hostent *hp;
 
-	if (_res.options & RES_USE_INET6) {
+	if (res_use_inet6 ()) {
 		hp = _gethtbyname2(name, AF_INET6);
 		if (hp)
 			return (hp);
diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
index 5f9e357..69f8d04 100644
--- a/resolv/nss_dns/dns-host.c
+++ b/resolv/nss_dns/dns-host.c
@@ -81,7 +81,8 @@ 
 
 #include "nsswitch.h"
 
-/* Get implementation for some internal functions.  */
+/* Get implementeation for some internal functions.  */
+#include <resolv/resolv-internal.h>
 #include <resolv/mapv4v6addr.h>
 #include <resolv/mapv4v6hostent.h>
 
@@ -232,7 +233,7 @@  _nss_dns_gethostbyname3_r (const char *name, int af, struct hostent *result,
       /* If we are looking for an IPv6 address and mapping is enabled
 	 by having the RES_USE_INET6 bit in _res.options set, we try
 	 another lookup.  */
-      if (af == AF_INET6 && (_res.options & RES_USE_INET6))
+      if (af == AF_INET6 && res_use_inet6 ())
 	n = __libc_res_nsearch (&_res, name, C_IN, T_A, host_buffer.buf->buf,
 				host_buffer.buf != orig_host_buffer
 				? MAXPACKET : 1024, &host_buffer.ptr,
@@ -277,7 +278,7 @@  _nss_dns_gethostbyname_r (const char *name, struct hostent *result,
 {
   enum nss_status status = NSS_STATUS_NOTFOUND;
 
-  if (_res.options & RES_USE_INET6)
+  if (res_use_inet6 ())
     status = _nss_dns_gethostbyname3_r (name, AF_INET6, result, buffer,
 					buflen, errnop, h_errnop, NULL, NULL);
   if (status == NSS_STATUS_NOTFOUND)
@@ -528,7 +529,7 @@  _nss_dns_gethostbyaddr2_r (const void *addr, socklen_t len, int af,
 #if 0
   /* XXX I think this is wrong.  Why should an IPv4 address be
      converted to IPv6 if the user explicitly asked for IPv4?  */
-  if (af == AF_INET && (_res.options & RES_USE_INET6))
+  if (af == AF_INET && res_use_inet6 ())
     {
       map_v4v6_address ((char *) host_data->host_addr,
 			(char *) host_data->host_addr);
diff --git a/resolv/res_debug.c b/resolv/res_debug.c
index bd95590..4135be0 100644
--- a/resolv/res_debug.c
+++ b/resolv/res_debug.c
@@ -101,7 +101,7 @@ 
 #include <errno.h>
 #include <math.h>
 #include <netdb.h>
-#include <resolv.h>
+#include <resolv/resolv-internal.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -575,7 +575,7 @@  p_option(u_long option) {
 	case RES_INSECURE1:	return "insecure1";
 	case RES_INSECURE2:	return "insecure2";
 	case RES_NOALIASES:	return "noaliases";
-	case RES_USE_INET6:	return "inet6";
+	case DEPRECATED_RES_USE_INET6:	return "inet6";
 	case RES_ROTATE:	return "rotate";
 	case RES_NOCHECKNAME:	return "no-check-names(unimpl)";
 	case RES_KEEPTSIG:	return "keeptsig(unimpl)";
diff --git a/resolv/res_init.c b/resolv/res_init.c
index cea4c8a..064211e 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -66,7 +66,7 @@ 
 
 #include <ctype.h>
 #include <netdb.h>
-#include <resolv.h>
+#include <resolv/resolv-internal.h>
 #include <stdio.h>
 #include <stdio_ext.h>
 #include <stdlib.h>
@@ -450,7 +450,7 @@  res_setoptions(res_state statp, const char *options, const char *source) {
 		    unsigned long int flag;
 		  } options[] = {
 #define STRnLEN(str) str, sizeof (str) - 1
-		    { STRnLEN ("inet6"), 0, RES_USE_INET6 },
+		    { STRnLEN ("inet6"), 0, DEPRECATED_RES_USE_INET6 },
 		    { STRnLEN ("ip6-bytestring"), 0, RES_USEBSTRING },
 		    { STRnLEN ("no-ip6-dotint"), 0, RES_NOIP6DOTINT },
 		    { STRnLEN ("ip6-dotint"), 1, ~RES_NOIP6DOTINT },
diff --git a/resolv/resolv-internal.h b/resolv/resolv-internal.h
new file mode 100644
index 0000000..269758c
--- /dev/null
+++ b/resolv/resolv-internal.h
@@ -0,0 +1,35 @@ 
+/* libresolv interfaces for internal use across glibc.
+   Copyright (C) 2016 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/>.  */
+
+#ifndef _RESOLV_INTERNAL_H
+#define _RESOLV_INTERNAL_H 1
+
+#include <resolv.h>
+#include <stdbool.h>
+
+/* Internal version of RES_USE_INET6 which does not trigger a
+   deprecation warning.  */
+#define DEPRECATED_RES_USE_INET6 0x00002000
+
+static inline bool
+res_use_inet6 (void)
+{
+  return _res.options & DEPRECATED_RES_USE_INET6;
+}
+
+#endif  /* _RESOLV_INTERNAL_H */
diff --git a/resolv/resolv.h b/resolv/resolv.h
index f55e7ce..5a66265 100644
--- a/resolv/resolv.h
+++ b/resolv/resolv.h
@@ -205,7 +205,8 @@  struct res_sym {
 #define	RES_INSECURE1	0x00000400	/* type 1 security disabled */
 #define	RES_INSECURE2	0x00000800	/* type 2 security disabled */
 #define	RES_NOALIASES	0x00001000	/* shuts off HOSTALIASES feature */
-#define	RES_USE_INET6	0x00002000	/* use/map IPv6 in gethostbyname() */
+#define	RES_USE_INET6	\
+  __glibc_macro_warning ("RES_USE_INET6 is deprecated") 0x00002000
 #define RES_ROTATE	0x00004000	/* rotate ns list after each query */
 #define	RES_NOCHECKNAME	0x00008000	/* do not check names for sanity (!IMPL) */
 #define	RES_KEEPTSIG	0x00010000	/* do not strip TSIG records */
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 09fbc83..fb51c07 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -59,7 +59,7 @@  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <ifaddrs.h>
 #include <netdb.h>
 #include <nss.h>
-#include <resolv.h>
+#include <resolv/resolv-internal.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdio_ext.h>
@@ -266,7 +266,7 @@  convert_hostent_to_gaih_addrtuple (const struct addrinfo *req,
       if (herrno == NETDB_INTERNAL)					      \
 	{								      \
 	  __set_h_errno (herrno);					      \
-	  _res.options |= old_res_options & RES_USE_INET6;		      \
+	  _res.options |= old_res_options & DEPRECATED_RES_USE_INET6;	      \
 	  result = -EAI_SYSTEM;						      \
 	  goto free_and_return;						      \
 	}								      \
@@ -282,7 +282,7 @@  convert_hostent_to_gaih_addrtuple (const struct addrinfo *req,
 	addrmem = NULL;							      \
       if (!convert_hostent_to_gaih_addrtuple (req, _family,h, &addrmem))      \
 	{								      \
-	  _res.options |= old_res_options & RES_USE_INET6;		      \
+	  _res.options |= old_res_options & DEPRECATED_RES_USE_INET6;	      \
 	  result = -EAI_SYSTEM;						      \
 	  goto free_and_return;						      \
 	}								      \
@@ -825,7 +825,7 @@  gaih_inet (const char *name, const struct gaih_service *service,
 	     addresses to IPv6 addresses.  Currently this is decided
 	     by setting the RES_USE_INET6 bit in _res.options.  */
 	  old_res_options = _res.options;
-	  _res.options &= ~RES_USE_INET6;
+	  _res.options &= ~DEPRECATED_RES_USE_INET6;
 
 	  while (!no_more)
 	    {
@@ -862,7 +862,8 @@  gaih_inet (const char *name, const struct gaih_service *service,
 
 		      if (!scratch_buffer_grow (tmpbuf))
 			{
-			  _res.options |= old_res_options & RES_USE_INET6;
+			  _res.options
+			    |= old_res_options & DEPRECATED_RES_USE_INET6;
 			  result = -EAI_MEMORY;
 			  goto free_and_return;
 			}
@@ -979,7 +980,8 @@  gaih_inet (const char *name, const struct gaih_service *service,
 				      if (canonbuf == NULL)
 					{
 					  _res.options
-					    |= old_res_options & RES_USE_INET6;
+					    |= old_res_options
+					       & DEPRECATED_RES_USE_INET6;
 					  result = -EAI_MEMORY;
 					  goto free_and_return;
 					}
@@ -1041,7 +1043,7 @@  gaih_inet (const char *name, const struct gaih_service *service,
 		nip = nip->next;
 	    }
 
-	  _res.options |= old_res_options & RES_USE_INET6;
+	  _res.options |= old_res_options & DEPRECATED_RES_USE_INET6;
 
 	  if (h_errno == NETDB_INTERNAL)
 	    {