From 4c1233433d4d46f6e4a755a79944ded2cc7e5420 Mon Sep 17 00:00:00 2001
From: ume <ume@FreeBSD.org>
Date: Mon, 19 Feb 2001 13:13:51 +0000
Subject: [PATCH] Enable AI_ADDRCONFIG as a valid flag of getaddrinfo(3).  Some
 applications specify AI_ADDRCONFIG and fail to run under FreeBSD. Latest mews
 is known.  Now, getaddrinfo(3) behaves according to AI_ADDRCONFIG.

---
 include/netdb.h            | 3 ++-
 lib/libc/net/getaddrinfo.c | 5 -----
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/include/netdb.h b/include/netdb.h
index 03b4f3ee4061..f07cbf3fdaa7 100644
--- a/include/netdb.h
+++ b/include/netdb.h
@@ -167,7 +167,8 @@ struct addrinfo {
 #define	AI_CANONNAME	0x00000002 /* fill ai_canonname */
 #define	AI_NUMERICHOST	0x00000004 /* prevent name resolution */
 /* valid flags for addrinfo */
-#define	AI_MASK		(AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
+#define AI_MASK \
+    (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_ADDRCONFIG)
 
 #define	AI_ALL		0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
 #define	AI_V4MAPPED_CFG	0x00000200 /* accept IPv4-mapped if kernel supports */
diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c
index 9e498e5d70bd..a06114b55320 100644
--- a/lib/libc/net/getaddrinfo.c
+++ b/lib/libc/net/getaddrinfo.c
@@ -82,7 +82,6 @@
  * - AI_ADDRCONFIG support is supplied
  * - EDNS0 support is not available due to resolver differences
  * - some of FreeBSD style (#define tabify and others)
- * - AI_ADDRCONFIG is turned on by default.
  * - classful IPv4 numeric (127.1) is allowed.
  */
 
@@ -522,10 +521,6 @@ getaddrinfo(hostname, servname, hints, res)
 	if (hostname == NULL)
 		ERR(EAI_NODATA);
 
-#if 1
-	/* XXX: temporarily, behave as if AI_ADDRCONFIG is specified */
-	pai->ai_flags |= AI_ADDRCONFIG;
-#endif
 	if ((pai->ai_flags & AI_ADDRCONFIG) != 0 && !addrconfig(&ai0))
 		ERR(EAI_FAIL);