From 1e01f0872e84da2c9eebb862b01103ed5ca7bd17 Mon Sep 17 00:00:00 2001 From: Lorenzo Colitti Date: Thu, 3 Mar 2016 17:53:46 +0900 Subject: [PATCH] APF: add debug code. 1. Store additional debug information when RA filtering. 2. Add a toString method for RA packets. 3. Make "adb shell dumpsys connectivity apf" dump APF filter state. Bug: 26238573 Change-Id: I1441ff7bc90e63624f8b10a220b2ac97f4d390a5 --- .../android/server/ConnectivityService.java | 55 ++++++++++++++----- 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index 3c1357742f..b7fca1a10f 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -1784,6 +1784,38 @@ public class ConnectivityService extends IConnectivityManager.Stub return false; } + private void dumpNetworkDiagnostics(IndentingPrintWriter pw) { + final List netDiags = new ArrayList(); + final long DIAG_TIME_MS = 5000; + for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) { + // Start gathering diagnostic information. + netDiags.add(new NetworkDiagnostics( + nai.network, + new LinkProperties(nai.linkProperties), // Must be a copy. + DIAG_TIME_MS)); + } + + for (NetworkDiagnostics netDiag : netDiags) { + pw.println(); + netDiag.waitForMeasurements(); + netDiag.dump(pw); + } + } + + private void dumpApf(IndentingPrintWriter pw) { + pw.println("APF filters:"); + pw.increaseIndent(); + for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) { + if (nai.apfFilter != null) { + pw.println(nai.name() + ":"); + pw.increaseIndent(); + nai.apfFilter.dump(pw); + pw.decreaseIndent(); + } + } + pw.decreaseIndent(); + } + @Override protected void dump(FileDescriptor fd, PrintWriter writer, String[] args) { final IndentingPrintWriter pw = new IndentingPrintWriter(writer, " "); @@ -1796,23 +1828,13 @@ public class ConnectivityService extends IConnectivityManager.Stub return; } - final List netDiags = new ArrayList(); if (argsContain(args, "--diag")) { - final long DIAG_TIME_MS = 5000; - for (NetworkAgentInfo nai : mNetworkAgentInfos.values()) { - // Start gathering diagnostic information. - netDiags.add(new NetworkDiagnostics( - nai.network, - new LinkProperties(nai.linkProperties), // Must be a copy. - DIAG_TIME_MS)); - } - - for (NetworkDiagnostics netDiag : netDiags) { - pw.println(); - netDiag.waitForMeasurements(); - netDiag.dump(pw); - } + dumpNetworkDiagnostics(pw); + return; + } + if (argsContain(args, "apf")) { + dumpApf(pw); return; } @@ -1878,6 +1900,9 @@ public class ConnectivityService extends IConnectivityManager.Stub pw.println(); mKeepaliveTracker.dump(pw); + pw.println(); + dumpApf(pw); + if (mInetLog != null && mInetLog.size() > 0) { pw.println(); pw.println("Inet condition reports:");