summaryrefslogtreecommitdiff
path: root/server/TetherController.cpp
diff options
context:
space:
mode:
authorMaciej Żenczykowski <maze@google.com>2020-06-10 16:58:22 -0700
committerMaciej Żenczykowski <maze@google.com>2020-06-11 02:58:22 +0000
commit7064f6f80f18bc8113eb0d46eb3983986383140d (patch)
tree9c5af35d82c137ed841f5c0f9423cdea1bfd9998 /server/TetherController.cpp
parent565a43dba257430469094511ae8ef9309347badf (diff)
TetherController - print iface names in bpf info
Test: adb shell dumpsys netd --short | sed -rn '/^ TetherController$/,/^ *Log:$/p' TetherController Forwarding requests: Tethering DNS: netId 100 servers [198.224.173.135, 198.224.174.135, 2001:4888:68:ff00:608:d::, 2001:4888:61:ff00:604:d::] dnsmasq PID: 4395 Interface pairs: rmnet_data2 -> rndis0 ACTIVE BPF ingress map: iif(iface) v6addr -> oif(iface) srcmac dstmac ethertype [pmtu] 12(rmnet_data2) 2600:1010:b009:76c8:b0fc:57ff:fe6e:8cc4 -> 33(rndis0) be:b2:04:f9:1a:98 b2:fc:57:6e:8c:c4 86dd [1500] BPF stats (downlink): iif(iface) -> packets bytes errors 12(rmnet_data2) -> 1 104 0 BPF limit: iif(iface) -> bytes 12(rmnet_data2) -> 9223372036854775807 Bug: 150736748 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I19148e4b079ac1fd2e8a5bf983bd9d8aa1dc4305
Diffstat (limited to 'server/TetherController.cpp')
-rw-r--r--server/TetherController.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/server/TetherController.cpp b/server/TetherController.cpp
index ad6e8a97..d542f652 100644
--- a/server/TetherController.cpp
+++ b/server/TetherController.cpp
@@ -1238,7 +1238,7 @@ void TetherController::dumpBpf(DumpWriter& dw) {
return;
}
- dw.println("BPF ingress map: iif v6addr -> oif srcmac dstmac ethertype [pmtu]");
+ dw.println("BPF ingress map: iif(iface) v6addr -> oif(iface) srcmac dstmac ethertype [pmtu]");
const auto printIngressMap = [&dw](const TetherIngressKey& key, const TetherIngressValue& value,
const BpfMap<TetherIngressKey, TetherIngressValue>&) {
char addr[INET6_ADDRSTRLEN];
@@ -1246,8 +1246,12 @@ void TetherController::dumpBpf(DumpWriter& dw) {
std::string dst = l2ToString(value.macHeader.h_dest, sizeof(value.macHeader.h_dest));
inet_ntop(AF_INET6, &key.neigh6, addr, sizeof(addr));
- dw.println("%u %s -> %u %s %s %04x [%u]", key.iif, addr, value.oif, src.c_str(),
- dst.c_str(), ntohs(value.macHeader.h_proto), value.pmtu);
+ char iifStr[IFNAMSIZ] = "?";
+ char oifStr[IFNAMSIZ] = "?";
+ if_indextoname(key.iif, iifStr);
+ if_indextoname(value.oif, oifStr);
+ dw.println("%u(%s) %s -> %u(%s) %s %s %04x [%u]", key.iif, iifStr, addr, value.oif, oifStr,
+ src.c_str(), dst.c_str(), ntohs(value.macHeader.h_proto), value.pmtu);
return Result<void>();
};
@@ -1259,11 +1263,13 @@ void TetherController::dumpBpf(DumpWriter& dw) {
}
dw.decIndent();
- dw.println("BPF stats (downlink): iif -> packets bytes errors");
+ dw.println("BPF stats (downlink): iif(iface) -> packets bytes errors");
const auto printStatsMap = [&dw](const uint32_t& key, const TetherStatsValue& value,
const BpfMap<uint32_t, TetherStatsValue>&) {
- dw.println("%u -> %" PRIu64 " %" PRIu64 " %" PRIu64, key, value.rxPackets, value.rxBytes,
- value.rxErrors);
+ char iifStr[IFNAMSIZ] = "?";
+ if_indextoname(key, iifStr);
+ dw.println("%u(%s) -> %" PRIu64 " %" PRIu64 " %" PRIu64, key, iifStr, value.rxPackets,
+ value.rxBytes, value.rxErrors);
return Result<void>();
};
@@ -1275,10 +1281,12 @@ void TetherController::dumpBpf(DumpWriter& dw) {
}
dw.decIndent();
- dw.println("BPF limit: iif -> bytes");
+ dw.println("BPF limit: iif(iface) -> bytes");
const auto printLimitMap = [&dw](const uint32_t& key, const uint64_t& value,
const BpfMap<uint32_t, uint64_t>&) {
- dw.println("%u -> %" PRIu64, key, value);
+ char iifStr[IFNAMSIZ] = "?";
+ if_indextoname(key, iifStr);
+ dw.println("%u(%s) -> %" PRIu64, key, iifStr, value);
return Result<void>();
};