Revert "fix/workaround art use of non-platform libnetd_client.so"
This reverts commit 23806a153e1261a918c13c1787feed59677661ba.
Reason for revert:
We do not want to support non-platform provided libnetd_client.
This introduces extra startup latency for the first connect()
in all applications.
Bug: 150126287
Change-Id: I105c8d419e82aac74d4de5ea974681f27784195d
diff --git a/client/NetdClient.cpp b/client/NetdClient.cpp
index 45eea38..b6fcc5c 100644
--- a/client/NetdClient.cpp
+++ b/client/NetdClient.cpp
@@ -147,45 +147,12 @@
return acceptedSocket;
}
-static int getFwMarkServerVersion() {
- static int version = -1;
-
- if (version >= 0) return version;
-
- const auto socketFunc = libcSocket ? libcSocket : socket;
- unique_fd sockfd(socketFunc(AF_INET6, SOCK_DGRAM | SOCK_CLOEXEC, 0));
- if (sockfd < 0) return CURRENT_FWMARK_SERVER_VERSION; // should not happen
-
- FwmarkCommand command = {FwmarkCommand::GET_FWMARK_SERVER_VERSION, 0, 0, 0};
- int retval = FwmarkClient().send(&command, sockfd.get(), nullptr);
-
- if (retval == -EPROTO) {
- version = 0; // old netd complains it doesn't recognize the command
- } else if (retval >= 0) {
- version = retval; // new netd returns version
- } else {
- return CURRENT_FWMARK_SERVER_VERSION; // should not happen
- }
-
- return version;
-}
-
int netdClientConnect(int sockfd, const sockaddr* addr, socklen_t addrlen) {
const bool shouldSetFwmark = shouldMarkSocket(sockfd, addr);
if (shouldSetFwmark) {
+ FwmarkCommand command = {FwmarkCommand::ON_CONNECT_WITH_DADDR, 0, 0, 0};
FwmarkConnectInfo connectInfo(0, 0, addr);
- int error;
-
- if (getFwMarkServerVersion() >= 1) {
- FwmarkCommand command = {FwmarkCommand::ON_CONNECT_WITH_DADDR, 0, 0, 0};
- error = FwmarkClient().send(&command, sockfd, &connectInfo);
- } else if (redirectSendX()) {
- FwmarkCommand command = {FwmarkCommand::ON_CONNECT, 0, 0, 0};
- error = FwmarkClient().send(&command, sockfd, &connectInfo);
- } else {
- FwmarkCommand command = {FwmarkCommand::ON_CONNECT, 0, 0, 0};
- error = FwmarkClient().send(&command, sockfd, nullptr);
- }
+ int error = FwmarkClient().send(&command, sockfd, &connectInfo);
if (error) {
errno = -error;