Merge "Dump underlying BPF traffic stats as well as higher-level stats."

This commit is contained in:
Treehugger Robot
2021-06-15 07:05:05 +00:00
committed by Gerrit Code Review

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) {