diff options
| author | 2017-11-21 05:58:09 +0000 | |
|---|---|---|
| committer | 2017-11-21 05:58:09 +0000 | |
| commit | 3d8600a07466d13e695fbcfeef7c64ff1f0971eb (patch) | |
| tree | 2a34ef6e7a78d673821b13defa20adaab0d2d342 | |
| parent | 3f297c11a9f1975424cca54bb8726fa4c2edadcb (diff) | |
| parent | 884970e0ba74c96f7c375454d3c58bb3fdc0bf46 (diff) | |
Merge "Define PacketWakeup pushed events for statds"
4 files changed, 40 insertions, 5 deletions
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index ba93febe8ad4..57a92b61a5c9 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -73,6 +73,7 @@ message Atom { SettingChanged setting_changed = 41; ActivityForegroundStateChanged activity_foreground_state_changed = 42; IsolatedUidChanged isolated_uid_changed = 43; + PacketWakeupOccurred packet_wakeup_occurred = 44; // TODO: Reorder the numbering so that the most frequent occur events occur in the first 15. } @@ -906,3 +907,32 @@ message CpuTimePerUidFreqPulled { optional uint64 freq_idx = 2; optional uint64 time_ms = 3; } + +/* + * Logs the reception of an incoming network packet causing the main system to wake up for + * processing that packet. These events are notified by the kernel via Netlink NFLOG to Netd + * and processed by WakeupController.cpp. + */ +message PacketWakeupOccurred { + // The uid owning the socket into which the packet was delivered, or -1 if the packet was + // delivered nowhere. + optional int32 uid = 1; + // The interface name on which the packet was received. + optional string iface = 2; + // The ethertype value of the packet. + optional int32 ethertype = 3; + // String representation of the destination MAC address of the packet. + optional string destination_hardware_address = 4; + // String representation of the source address of the packet if this was an IP packet. + optional string source_ip = 5; + // String representation of the destination address of the packet if this was an IP packet. + optional string destination_ip = 6; + // The value of the protocol field if this was an IPv4 packet or the value of the Next Header + // field if this was an IPv6 packet. The range of possible values is the same for both IP + // families. + optional int32 ip_next_header = 7; + // The source port if this was a TCP or UDP packet. + optional int32 source_port = 8; + // The destination port if this was a TCP or UDP packet. + optional int32 destination_port = 9; +} diff --git a/core/java/android/net/metrics/WakeupEvent.java b/core/java/android/net/metrics/WakeupEvent.java index 8f1a5c42e6ac..af9a73ca31ee 100644 --- a/core/java/android/net/metrics/WakeupEvent.java +++ b/core/java/android/net/metrics/WakeupEvent.java @@ -29,7 +29,7 @@ public class WakeupEvent { public String iface; public int uid; public int ethertype; - public byte[] dstHwAddr; + public MacAddress dstHwAddr; public String srcIp; public String dstIp; public int ipNextHeader; @@ -44,7 +44,7 @@ public class WakeupEvent { j.add(iface); j.add("uid: " + Integer.toString(uid)); j.add("eth=0x" + Integer.toHexString(ethertype)); - j.add("dstHw=" + MacAddress.stringAddrFromByteAddr(dstHwAddr)); + j.add("dstHw=" + dstHwAddr); if (ipNextHeader > 0) { j.add("ipNxtHdr=" + ipNextHeader); j.add("srcIp=" + srcIp); diff --git a/core/java/android/net/metrics/WakeupStats.java b/core/java/android/net/metrics/WakeupStats.java index 1ba97771b595..23c1f20f1a44 100644 --- a/core/java/android/net/metrics/WakeupStats.java +++ b/core/java/android/net/metrics/WakeupStats.java @@ -16,7 +16,6 @@ package android.net.metrics; -import android.net.MacAddress; import android.os.Process; import android.os.SystemClock; import android.util.SparseIntArray; @@ -80,7 +79,7 @@ public class WakeupStats { break; } - switch (MacAddress.macAddressType(ev.dstHwAddr)) { + switch (ev.dstHwAddr.addressType()) { case UNICAST: l2UnicastCount++; break; diff --git a/services/core/java/com/android/server/connectivity/NetdEventListenerService.java b/services/core/java/com/android/server/connectivity/NetdEventListenerService.java index 4bdbbe3959b7..e243e56cbd7e 100644 --- a/services/core/java/com/android/server/connectivity/NetdEventListenerService.java +++ b/services/core/java/com/android/server/connectivity/NetdEventListenerService.java @@ -21,6 +21,7 @@ import static android.util.TimeUtils.NANOS_PER_MS; import android.content.Context; import android.net.ConnectivityManager; import android.net.INetdEventCallback; +import android.net.MacAddress; import android.net.Network; import android.net.NetworkCapabilities; import android.net.metrics.ConnectStats; @@ -35,6 +36,7 @@ import android.text.format.DateUtils; import android.util.Log; import android.util.ArrayMap; import android.util.SparseArray; +import android.util.StatsLog; import com.android.internal.annotations.GuardedBy; import com.android.internal.annotations.VisibleForTesting; @@ -242,13 +244,17 @@ public class NetdEventListenerService extends INetdEventListener.Stub { event.timestampMs = timestampMs; event.uid = uid; event.ethertype = ethertype; - event.dstHwAddr = dstHw; + event.dstHwAddr = new MacAddress(dstHw); event.srcIp = srcIp; event.dstIp = dstIp; event.ipNextHeader = ipNextHeader; event.srcPort = srcPort; event.dstPort = dstPort; addWakeupEvent(event); + + String dstMac = event.dstHwAddr.toString(); + StatsLog.write(StatsLog.PACKET_WAKEUP_OCCURRED, + uid, iface, ethertype, dstMac, srcIp, dstIp, ipNextHeader, srcPort, dstPort); } private void addWakeupEvent(WakeupEvent event) { |