Move cookie tag bpf map dump to NetworkStatsService

Map status dump will do access check if map is null.
This could show different message from the current dump output.

Information in map content dump does not change
$ dumpsys connectivity trafficcontroller
....
      mCookieTagMap:
      cookie=1398 tag=0x0 uid=1029
      cookie=1433 tag=0xffffff82 uid=1051
      cookie=1166 tag=0xfffffe01 uid=1073

$ dumpsys netstats
....
  mCookieTagMap:
    cookie=1144 tag=0xfffffe01 uid=1073
    cookie=1376 tag=0x0 uid=1029
    cookie=1408 tag=0xffffff82 uid=1051

Bug: 217624062
Test: dumpsys netstats, dumpstate, atest NetworkStatsServiceTest
Change-Id: I14dd6f969a0b5eb24ace62361ce2484cf18b7470
This commit is contained in:
Motomu Utsumi
2022-07-27 08:14:09 +00:00
parent d70c34fef2
commit cedfab91c6
4 changed files with 87 additions and 18 deletions

View File

@@ -570,8 +570,6 @@ void TrafficController::dump(int fd, bool verbose) {
ScopedIndent indentPreBpfModule(dw);
dw.blankline();
dw.println("mCookieTagMap status: %s",
getMapStatus(mCookieTagMap.getMap(), COOKIE_TAG_MAP_PATH).c_str());
dw.println("mUidCounterSetMap status: %s",
getMapStatus(mUidCounterSetMap.getMap(), UID_COUNTERSET_MAP_PATH).c_str());
dw.println("mAppUidStatsMap status: %s",
@@ -611,18 +609,6 @@ void TrafficController::dump(int fd, bool verbose) {
ScopedIndent indentForMapContent(dw);
// Print CookieTagMap content.
dumpBpfMap("mCookieTagMap", dw, "");
const auto printCookieTagInfo = [&dw](const uint64_t& key, const UidTagValue& value,
const BpfMap<uint64_t, UidTagValue>&) {
dw.println("cookie=%" PRIu64 " tag=0x%x uid=%u", key, value.tag, value.uid);
return base::Result<void>();
};
base::Result<void> res = mCookieTagMap.iterateWithValue(printCookieTagInfo);
if (!res.ok()) {
dw.println("mCookieTagMap print end with error: %s", res.error().message().c_str());
}
// Print UidCounterSetMap content.
dumpBpfMap("mUidCounterSetMap", dw, "");
const auto printUidInfo = [&dw](const uint32_t& key, const uint8_t& value,
@@ -630,7 +616,7 @@ void TrafficController::dump(int fd, bool verbose) {
dw.println("%u %u", key, value);
return base::Result<void>();
};
res = mUidCounterSetMap.iterateWithValue(printUidInfo);
base::Result<void> res = mUidCounterSetMap.iterateWithValue(printUidInfo);
if (!res.ok()) {
dw.println("mUidCounterSetMap print end with error: %s", res.error().message().c_str());
}