Revert mCookieTagMap dump in TrafficController
aosp/2167063 moved mCookieTagMap dump from TrafficController to NetworkStatsService. But this dump was used from Cts TagSocketTest. So, this CL re-adds mCookieTagMap dump to TrafficController to avoid failure of released Cts. Upcoming CL will update Cts test to check dump both from TrafficController and NetworkStatsService. And after the old Cts support period is over, mCookieTagMap dump in TrafficController can be removed. Bug: 241787285 Test: atest TagSocketTest TrafficControllerTest Change-Id: Ie2ef09fa7d91cf96f56c5efcbe9d863dd68a1020
This commit is contained in:
@@ -612,6 +612,8 @@ void TrafficController::dump(int fd, bool verbose) {
|
|||||||
ScopedIndent indentPreBpfModule(dw);
|
ScopedIndent indentPreBpfModule(dw);
|
||||||
|
|
||||||
dw.blankline();
|
dw.blankline();
|
||||||
|
dw.println("mCookieTagMap status: %s",
|
||||||
|
getMapStatus(mCookieTagMap.getMap(), COOKIE_TAG_MAP_PATH).c_str());
|
||||||
dw.println("mStatsMapA status: %s",
|
dw.println("mStatsMapA status: %s",
|
||||||
getMapStatus(mStatsMapA.getMap(), STATS_MAP_A_PATH).c_str());
|
getMapStatus(mStatsMapA.getMap(), STATS_MAP_A_PATH).c_str());
|
||||||
dw.println("mStatsMapB status: %s",
|
dw.println("mStatsMapB status: %s",
|
||||||
@@ -647,6 +649,21 @@ void TrafficController::dump(int fd, bool verbose) {
|
|||||||
|
|
||||||
ScopedIndent indentForMapContent(dw);
|
ScopedIndent indentForMapContent(dw);
|
||||||
|
|
||||||
|
// Print CookieTagMap content.
|
||||||
|
// TagSocketTest in CTS was using the output of mCookieTagMap dump.
|
||||||
|
// So, mCookieTagMap dump can not be removed until the previous CTS support period is over.
|
||||||
|
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 uidStatsMap content.
|
// Print uidStatsMap content.
|
||||||
std::string statsHeader = StringPrintf("ifaceIndex ifaceName tag_hex uid_int cnt_set rxBytes"
|
std::string statsHeader = StringPrintf("ifaceIndex ifaceName tag_hex uid_int cnt_set rxBytes"
|
||||||
" rxPackets txBytes txPackets");
|
" rxPackets txBytes txPackets");
|
||||||
@@ -663,7 +680,7 @@ void TrafficController::dump(int fd, bool verbose) {
|
|||||||
value.rxPackets, value.txBytes, value.txPackets);
|
value.rxPackets, value.txBytes, value.txPackets);
|
||||||
return base::Result<void>();
|
return base::Result<void>();
|
||||||
};
|
};
|
||||||
base::Result<void> res = mStatsMapA.iterateWithValue(printStatsInfo);
|
res = mStatsMapA.iterateWithValue(printStatsInfo);
|
||||||
if (!res.ok()) {
|
if (!res.ok()) {
|
||||||
dw.println("mStatsMapA print end with error: %s", res.error().message().c_str());
|
dw.println("mStatsMapA print end with error: %s", res.error().message().c_str());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -791,6 +791,8 @@ TEST_F(TrafficControllerTest, TestDumpsys) {
|
|||||||
// ifaceIndex ifaceName tag_hex uid_int cnt_set rxBytes rxPackets txBytes txPackets
|
// ifaceIndex ifaceName tag_hex uid_int cnt_set rxBytes rxPackets txBytes txPackets
|
||||||
// 999 test0 0x2a 10086 1 100 1 0 0
|
// 999 test0 0x2a 10086 1 100 1 0 0
|
||||||
std::vector<std::string> expectedLines = {
|
std::vector<std::string> expectedLines = {
|
||||||
|
"mCookieTagMap:",
|
||||||
|
fmt::format("cookie={} tag={:#x} uid={}", TEST_COOKIE, TEST_TAG, TEST_UID),
|
||||||
"mStatsMapA",
|
"mStatsMapA",
|
||||||
"ifaceIndex ifaceName tag_hex uid_int cnt_set rxBytes rxPackets txBytes txPackets",
|
"ifaceIndex ifaceName tag_hex uid_int cnt_set rxBytes rxPackets txBytes txPackets",
|
||||||
fmt::format("{} {} {:#x} {} {} {} {} {} {}",
|
fmt::format("{} {} {:#x} {} {} {} {} {} {}",
|
||||||
@@ -826,6 +828,7 @@ TEST_F(TrafficControllerTest, dumpsysInvalidMaps) {
|
|||||||
"Read value of map -1 failed: Bad file descriptor";
|
"Read value of map -1 failed: Bad file descriptor";
|
||||||
|
|
||||||
std::vector<std::string> expectedLines = {
|
std::vector<std::string> expectedLines = {
|
||||||
|
fmt::format("mCookieTagMap {}", kErrIterate),
|
||||||
fmt::format("mStatsMapA {}", kErrIterate),
|
fmt::format("mStatsMapA {}", kErrIterate),
|
||||||
fmt::format("mStatsMapB {}", kErrIterate),
|
fmt::format("mStatsMapB {}", kErrIterate),
|
||||||
fmt::format("mIfaceIndexNameMap {}", kErrIterate),
|
fmt::format("mIfaceIndexNameMap {}", kErrIterate),
|
||||||
|
|||||||
Reference in New Issue
Block a user