bionic: Replace iface with opaque netid in resolver.

Replace iface cache key with netid.

Replace _mark with netid.

Mark sockets used to test IPv4/IPv6 support as well as sockets
used to determine source address for rfc6724 sort.

Remove pid/uid mappings (functionality moved to system/netd).

Do not create resolv_cache when it does not exist, but rather only
when DNS configuration is supplied.

Clean up unused functions.

Change-Id: I9ccfda2902cc0943e87c9bc346ad9a2578accdab
diff --git a/libc/dns/resolv/res_init.c b/libc/dns/resolv/res_init.c
index 973226a..9f3a9da 100644
--- a/libc/dns/resolv/res_init.c
+++ b/libc/dns/resolv/res_init.c
@@ -110,6 +110,7 @@
 
 /* ensure that sockaddr_in6 and IN6ADDR_ANY_INIT are declared / defined */
 #ifdef ANDROID_CHANGES
+#include "resolv_netid.h"
 #include "resolv_private.h"
 #else
 #include <resolv.h>
@@ -183,10 +184,12 @@
                 res_ndestroy(statp);
 
 	if (!preinit) {
+		statp->netid = NETID_UNSET;
 		statp->retrans = RES_TIMEOUT;
 		statp->retry = RES_DFLRETRY;
 		statp->options = RES_DEFAULT;
 		statp->id = res_randomid();
+		statp->_mark = MARK_UNSET;
 	}
 
 	memset(u, 0, sizeof(u));
@@ -793,24 +796,18 @@
 }
 
 #ifdef ANDROID_CHANGES
-void res_setiface(res_state statp, const char* iface)
+void res_setnetid(res_state statp, unsigned netid)
 {
 	if (statp != NULL) {
-		// set interface
-		if (iface && iface[0] != '\0') {
-			int len = sizeof(statp->iface);
-			strncpy(statp->iface, iface, len - 1);
-			statp->iface[len - 1] = '\0';
-		} else {
-			statp->iface[0] = '\0';
-		}
+		statp->netid = netid;
 	}
 }
 
-void res_setmark(res_state statp, int mark)
+void res_setmark(res_state statp, unsigned mark)
 {
 	if (statp != NULL) {
 		statp->_mark = mark;
 	}
 }
+
 #endif /* ANDROID_CHANGES */