Move DnsProxyListener to libnetd_resolv
[1] Support APIs for netd to set callbacks and bring up
DnsProxyListener.
[2] Keep DnsProxyListener functioning as usual by function pointers,
including getNetworkContext(), checkCallingPermission(), and
getPrefix64().
[3] Use libbinder_ndk to report onDnsEvent().
Test: as follows
- built, flashed, booted
- system/netd/tests/runtests.sh passed
- netd_benchmark passed
- Browsing websites passed
Change-Id: Ib6575833c248579aa079e302795b6d6cddde1f2b
diff --git a/server/main.cpp b/server/main.cpp
index 51ce7ea..fd0856e 100644
--- a/server/main.cpp
+++ b/server/main.cpp
@@ -39,7 +39,6 @@
#include "CommandListener.h"
#include "Controllers.h"
-#include "DnsProxyListener.h"
#include "FwmarkServer.h"
#include "MDnsSdListener.h"
#include "NFLogListener.h"
@@ -58,7 +57,6 @@
using android::ProcessState;
using android::defaultServiceManager;
using android::net::CommandListener;
-using android::net::DnsProxyListener;
using android::net::FwmarkServer;
using android::net::NetdHwService;
using android::net::NetdNativeService;
@@ -67,6 +65,7 @@
using android::net::makeNFLogListener;
const char* const PID_FILE_PATH = "/data/misc/net/netd_pid";
+constexpr const char DNSPROXYLISTENER_SOCKET_NAME[] = "dnsproxyd";
std::mutex android::net::gBigNetdLock;
@@ -83,7 +82,7 @@
// FrameworkListener does this on initialization as well, but we only initialize these
// components after having initialized other subsystems that can fork.
for (const auto& sock : { CommandListener::SOCKET_NAME,
- DnsProxyListener::SOCKET_NAME,
+ DNSPROXYLISTENER_SOCKET_NAME,
FwmarkServer::SOCKET_NAME,
MDnsSdListener::SOCKET_NAME }) {
setCloseOnExec(sock);
@@ -132,10 +131,11 @@
// Set local DNS mode, to prevent bionic from proxying
// back to this service, recursively.
+ // TODO: Check if we could remove it since resolver cache no loger
+ // checks this environment variable after aosp/838050.
setenv("ANDROID_DNS_MODE", "local", 1);
- DnsProxyListener dpl(&gCtls->netCtrl);
- if (dpl.startListener()) {
- ALOGE("Unable to start DnsProxyListener (%s)", strerror(errno));
+ if (!gCtls->resolverCtrl.initResolver()) {
+ ALOGE("Unable to init resolver");
exit(1);
}