diff options
| author | Maciej Żenczykowski <maze@google.com> | 2021-01-21 14:25:10 -0800 |
|---|---|---|
| committer | Maciej Żenczykowski <maze@google.com> | 2021-01-22 17:41:10 +0000 |
| commit | ee50131be4d6d219a9eaa000cd26e70c1c55dffc (patch) | |
| tree | b61491fac39f4c81c5d9f2208f1d2cffb6d9ea2d /server/TetherController.cpp | |
| parent | be791974df68cafb7c1153b0eeffc217f9b79817 (diff) | |
add code to dump the content of the tether offload upstream6 map
Test: atest, TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I69c4d20952927ddae4131faadf3e2fb8410c0a21
Diffstat (limited to 'server/TetherController.cpp')
| -rw-r--r-- | server/TetherController.cpp | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/server/TetherController.cpp b/server/TetherController.cpp index 0500d549..334991a4 100644 --- a/server/TetherController.cpp +++ b/server/TetherController.cpp @@ -1266,7 +1266,9 @@ std::string l2ToString(const uint8_t* addr, size_t len) { } // namespace void TetherController::dumpBpf(DumpWriter& dw) { - if (!mBpfDownstream6Map.isValid() || !mBpfStatsMap.isValid() || !mBpfLimitMap.isValid()) { + if (!mBpfDownstream6Map.isValid() || !mBpfDownstream64Map.isValid() || + !mBpfDownstream4Map.isValid() || !mBpfUpstream6Map.isValid() || + !mBpfUpstream4Map.isValid() || !mBpfStatsMap.isValid() || !mBpfLimitMap.isValid()) { dw.println("BPF not supported"); return; } @@ -1302,13 +1304,39 @@ void TetherController::dumpBpf(DumpWriter& dw) { } dw.decIndent(); - dw.println("BPF stats (downlink): iif(iface) -> packets bytes errors"); + dw.println("BPF upstream ipv6 map: iif(iface) -> oif(iface) srcmac dstmac ethertype [pmtu]"); + const auto printUpstream6Map = [&dw](const TetherUpstream6Key& key, + const TetherUpstream6Value& value, + const BpfMap<TetherUpstream6Key, TetherUpstream6Value>&) { + std::string src = l2ToString(value.macHeader.h_source, sizeof(value.macHeader.h_source)); + std::string dst = l2ToString(value.macHeader.h_dest, sizeof(value.macHeader.h_dest)); + + char iifStr[IFNAMSIZ] = "?"; + char oifStr[IFNAMSIZ] = "?"; + if_indextoname(key.iif, iifStr); + if_indextoname(value.oif, oifStr); + dw.println("%u(%s) -> %u(%s) %s %s %04x [%u]", key.iif, iifStr, value.oif, oifStr, + src.c_str(), dst.c_str(), ntohs(value.macHeader.h_proto), value.pmtu); + + return Result<void>(); + }; + + dw.incIndent(); + ret = mBpfUpstream6Map.iterateWithValue(printUpstream6Map); + if (!ret.ok()) { + dw.println("Error printing BPF upstream ipv6 map: %s", ret.error().message().c_str()); + } + dw.decIndent(); + + dw.println( + "BPF stats: iif(iface) -> downlink.packets/bytes/errors uplink.packets/bytes/errors"); const auto printStatsMap = [&dw](const TetherStatsKey& key, const TetherStatsValue& value, const BpfMap<TetherStatsKey, TetherStatsValue>&) { char iifStr[IFNAMSIZ] = "?"; if_indextoname(key, iifStr); - dw.println("%u(%s) -> %" PRIu64 " %" PRIu64 " %" PRIu64, key, iifStr, value.rxPackets, - value.rxBytes, value.rxErrors); + dw.println("%u(%s) -> %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64, + key, iifStr, value.rxPackets, value.rxBytes, value.rxErrors, value.txPackets, + value.txBytes, value.txErrors); return Result<void>(); }; |
