Android-x86
Fork

  • R/O
  • HTTP
  • SSH
  • HTTPS

system-netd: コミット

system/netd


コミットメタ情報

リビジョン483afa496bd0fc58aba0c56f1da8f059bd0fa85d (tree)
日時2016-12-15 20:50:42
作者Hugo Benichi <hugobenichi@goog...>
コミッターHugo Benichi

ログメッセージ

DO NOT MERGE Add success/errno to connect() event reporting

Test: $ runtest -x system/netd/tests/netd_integration_test.cpp
Bug: 32198976

(cherry picked from commit 794c5c714a4d4cf169769ec956845a6fb24e7ebc)

Change-Id: I0a7990d7211d5355a48d941ee9659c16e38817ca

変更サマリ

差分

--- a/client/NetdClient.cpp
+++ b/client/NetdClient.cpp
@@ -87,13 +87,13 @@ int netdClientConnect(int sockfd, const sockaddr* addr, socklen_t addrlen) {
8787 }
8888 // Latency measurement does not include time of sending commands to Fwmark
8989 Stopwatch s;
90- int ret = libcConnect(sockfd, addr, addrlen);
90+ const int ret = libcConnect(sockfd, addr, addrlen);
9191 // Save errno so it isn't clobbered by sending ON_CONNECT_COMPLETE
9292 const int connectErrno = errno;
9393 const unsigned latencyMs = lround(s.timeTaken());
9494 // Send an ON_CONNECT_COMPLETE command that includes sockaddr and connect latency for reporting
9595 if (shouldSetFwmark && FwmarkClient::shouldReportConnectComplete(addr->sa_family)) {
96- FwmarkConnectInfo connectInfo(latencyMs, addr);
96+ FwmarkConnectInfo connectInfo(ret == 0 ? 0 : connectErrno, latencyMs, addr);
9797 // TODO: get the netId from the socket mark once we have continuous benchmark runs
9898 FwmarkCommand command = {FwmarkCommand::ON_CONNECT_COMPLETE, /* netId (ignored) */ 0,
9999 /* uid (filled in by the server) */ 0};
--- a/include/FwmarkCommand.h
+++ b/include/FwmarkCommand.h
@@ -23,6 +23,7 @@
2323
2424 // Additional information sent with ON_CONNECT_COMPLETE command
2525 struct FwmarkConnectInfo {
26+ int error;
2627 unsigned latencyMs;
2728 union {
2829 sockaddr s;
@@ -32,7 +33,8 @@ struct FwmarkConnectInfo {
3233
3334 FwmarkConnectInfo() {}
3435
35- FwmarkConnectInfo(const unsigned latency, const sockaddr* saddr) {
36+ FwmarkConnectInfo(const int connectErrno, const unsigned latency, const sockaddr* saddr) {
37+ error = connectErrno;
3638 latencyMs = latency;
3739 if (saddr->sa_family == AF_INET) {
3840 addr.sin = *((struct sockaddr_in*) saddr);
--- a/server/FwmarkServer.cpp
+++ b/server/FwmarkServer.cpp
@@ -165,7 +165,7 @@ int FwmarkServer::processClient(SocketClient* client, int* socketFd) {
165165 case FwmarkCommand::ON_CONNECT_COMPLETE: {
166166 // Called after a socket connect() completes.
167167 // This reports connect event including netId, destination IP address, destination port,
168- // uid and connect latency
168+ // uid, connect latency, and connect errno if any.
169169
170170 // Skip reporting if connect() happened on a UDP socket.
171171 int socketProto;
@@ -185,7 +185,8 @@ int FwmarkServer::processClient(SocketClient* client, int* socketFd) {
185185 addrstr, sizeof(addrstr), portstr, sizeof(portstr),
186186 NI_NUMERICHOST | NI_NUMERICSERV);
187187
188- netdEventListener->onConnectEvent(fwmark.netId, connectInfo.latencyMs,
188+ netdEventListener->onConnectEvent(fwmark.netId, connectInfo.error,
189+ connectInfo.latencyMs,
189190 (ret == 0) ? String16(addrstr) : String16(""),
190191 (ret == 0) ? strtoul(portstr, NULL, 10) : 0, client->getUid());
191192 }
--- a/server/binder/android/net/metrics/INetdEventListener.aidl
+++ b/server/binder/android/net/metrics/INetdEventListener.aidl
@@ -52,11 +52,12 @@ oneway interface INetdEventListener {
5252 /**
5353 * Logs a single connect library call.
5454 *
55- * @param netId the ID of the network the lookup was performed on.
56- * @param latencyMs the latency of the function call.
55+ * @param netId the ID of the network the connect was performed on.
56+ * @param error 0 if the connect call succeeded, otherwise errno if it failed.
57+ * @param latencyMs the latency of the connect call.
5758 * @param ipAddr destination IP address.
5859 * @param port destination port number.
5960 * @param uid the UID of the application that performed the connection.
6061 */
61- void onConnectEvent(int netId, int latencyMs, String ipAddr, int port, int uid);
62+ void onConnectEvent(int netId, int error, int latencyMs, String ipAddr, int port, int uid);
6263 }
旧リポジトリブラウザで表示