Dump underlying BPF traffic stats as well as higher-level stats. am: 898d5adb31

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/14963612

Change-Id: Idbc82073afde61e7f3706b7d975063a9fa1b25fd
This commit is contained in:
Treehugger Robot
2021-06-15 11:28:05 +00:00
committed by Automerger Merge Worker

View File

@@ -773,6 +773,12 @@ public class BpfCoordinator {
}
pw.decreaseIndent();
pw.println("BPF stats:");
pw.increaseIndent();
dumpBpfStats(pw);
pw.decreaseIndent();
pw.println();
pw.println("Forwarding rules:");
pw.increaseIndent();
dumpIpv6UpstreamRules(pw);
@@ -800,6 +806,22 @@ public class BpfCoordinator {
upstreamIfindex), stats.toString()));
}
}
private void dumpBpfStats(@NonNull IndentingPrintWriter pw) {
try (BpfMap<TetherStatsKey, TetherStatsValue> map = mDeps.getBpfStatsMap()) {
if (map == null) {
pw.println("No BPF stats map");
return;
}
if (map.isEmpty()) {
pw.println("<empty>");
}
map.forEach((k, v) -> {
pw.println(String.format("%s: %s", k, v));
});
} catch (ErrnoException e) {
pw.println("Error dumping BPF stats map: " + e);
}
}
private void dumpIpv6ForwardingRules(@NonNull IndentingPrintWriter pw) {
if (mIpv6ForwardingRules.size() == 0) {