diff options
author | Hugo Benichi <hugobenichi@google.com> | 2016-10-31 15:07:23 +0900 |
---|---|---|
committer | Hugo Benichi <hugobenichi@google.com> | 2016-12-15 20:50:42 +0900 |
commit | 483afa496bd0fc58aba0c56f1da8f059bd0fa85d (patch) | |
tree | 648a025e7e2af96d1ce87fa109df66b2e962490d | |
parent | 5e07140c33d0a050c640a917045f50917e83f1e1 (diff) | |
download | netd-483afa496bd0fc58aba0c56f1da8f059bd0fa85d.tar.gz |
DO NOT MERGE Add success/errno to connect() event reportingandroid-7.1.2_r9android-7.1.2_r8android-7.1.2_r6android-7.1.2_r5android-7.1.2_r4android-7.1.2_r39android-7.1.2_r38android-7.1.2_r37android-7.1.2_r36android-7.1.2_r33android-7.1.2_r32android-7.1.2_r30android-7.1.2_r3android-7.1.2_r29android-7.1.2_r28android-7.1.2_r27android-7.1.2_r25android-7.1.2_r24android-7.1.2_r23android-7.1.2_r2android-7.1.2_r19android-7.1.2_r18android-7.1.2_r17android-7.1.2_r16android-7.1.2_r15android-7.1.2_r14android-7.1.2_r13android-7.1.2_r12android-7.1.2_r11android-7.1.2_r10android-7.1.2_r1nougat-mr2.3-releasenougat-mr2.2-releasenougat-mr2.1-releasenougat-mr2-security-releasenougat-mr2-releasenougat-mr2-pixel-releasenougat-mr2-dev
Test: $ runtest -x system/netd/tests/netd_integration_test.cpp
Bug: 32198976
(cherry picked from commit 794c5c714a4d4cf169769ec956845a6fb24e7ebc)
Change-Id: I0a7990d7211d5355a48d941ee9659c16e38817ca
-rw-r--r-- | client/NetdClient.cpp | 4 | ||||
-rw-r--r-- | include/FwmarkCommand.h | 4 | ||||
-rw-r--r-- | server/FwmarkServer.cpp | 5 | ||||
-rw-r--r-- | server/binder/android/net/metrics/INetdEventListener.aidl | 7 |
4 files changed, 12 insertions, 8 deletions
diff --git a/client/NetdClient.cpp b/client/NetdClient.cpp index f0252289..948b6172 100644 --- a/client/NetdClient.cpp +++ b/client/NetdClient.cpp @@ -87,13 +87,13 @@ int netdClientConnect(int sockfd, const sockaddr* addr, socklen_t addrlen) { } // Latency measurement does not include time of sending commands to Fwmark Stopwatch s; - int ret = libcConnect(sockfd, addr, addrlen); + const int ret = libcConnect(sockfd, addr, addrlen); // Save errno so it isn't clobbered by sending ON_CONNECT_COMPLETE const int connectErrno = errno; const unsigned latencyMs = lround(s.timeTaken()); // Send an ON_CONNECT_COMPLETE command that includes sockaddr and connect latency for reporting if (shouldSetFwmark && FwmarkClient::shouldReportConnectComplete(addr->sa_family)) { - FwmarkConnectInfo connectInfo(latencyMs, addr); + FwmarkConnectInfo connectInfo(ret == 0 ? 0 : connectErrno, latencyMs, addr); // TODO: get the netId from the socket mark once we have continuous benchmark runs FwmarkCommand command = {FwmarkCommand::ON_CONNECT_COMPLETE, /* netId (ignored) */ 0, /* uid (filled in by the server) */ 0}; diff --git a/include/FwmarkCommand.h b/include/FwmarkCommand.h index a31b320e..39ff233d 100644 --- a/include/FwmarkCommand.h +++ b/include/FwmarkCommand.h @@ -23,6 +23,7 @@ // Additional information sent with ON_CONNECT_COMPLETE command struct FwmarkConnectInfo { + int error; unsigned latencyMs; union { sockaddr s; @@ -32,7 +33,8 @@ struct FwmarkConnectInfo { FwmarkConnectInfo() {} - FwmarkConnectInfo(const unsigned latency, const sockaddr* saddr) { + FwmarkConnectInfo(const int connectErrno, const unsigned latency, const sockaddr* saddr) { + error = connectErrno; latencyMs = latency; if (saddr->sa_family == AF_INET) { addr.sin = *((struct sockaddr_in*) saddr); diff --git a/server/FwmarkServer.cpp b/server/FwmarkServer.cpp index b08f9f9e..80df03f4 100644 --- a/server/FwmarkServer.cpp +++ b/server/FwmarkServer.cpp @@ -165,7 +165,7 @@ int FwmarkServer::processClient(SocketClient* client, int* socketFd) { case FwmarkCommand::ON_CONNECT_COMPLETE: { // Called after a socket connect() completes. // This reports connect event including netId, destination IP address, destination port, - // uid and connect latency + // uid, connect latency, and connect errno if any. // Skip reporting if connect() happened on a UDP socket. int socketProto; @@ -185,7 +185,8 @@ int FwmarkServer::processClient(SocketClient* client, int* socketFd) { addrstr, sizeof(addrstr), portstr, sizeof(portstr), NI_NUMERICHOST | NI_NUMERICSERV); - netdEventListener->onConnectEvent(fwmark.netId, connectInfo.latencyMs, + netdEventListener->onConnectEvent(fwmark.netId, connectInfo.error, + connectInfo.latencyMs, (ret == 0) ? String16(addrstr) : String16(""), (ret == 0) ? strtoul(portstr, NULL, 10) : 0, client->getUid()); } diff --git a/server/binder/android/net/metrics/INetdEventListener.aidl b/server/binder/android/net/metrics/INetdEventListener.aidl index 49a20f2c..e9665372 100644 --- a/server/binder/android/net/metrics/INetdEventListener.aidl +++ b/server/binder/android/net/metrics/INetdEventListener.aidl @@ -52,11 +52,12 @@ oneway interface INetdEventListener { /** * Logs a single connect library call. * - * @param netId the ID of the network the lookup was performed on. - * @param latencyMs the latency of the function call. + * @param netId the ID of the network the connect was performed on. + * @param error 0 if the connect call succeeded, otherwise errno if it failed. + * @param latencyMs the latency of the connect call. * @param ipAddr destination IP address. * @param port destination port number. * @param uid the UID of the application that performed the connection. */ - void onConnectEvent(int netId, int latencyMs, String ipAddr, int port, int uid); + void onConnectEvent(int netId, int error, int latencyMs, String ipAddr, int port, int uid); } |