Move current StatsMap dump to BpfNetMaps
Information in the dump does not change .... current statsMap configuration: 0 SELECT_MAP_A .... Bug: 217624062 Test: dumpsys connectivity trafficcontroller, atest BpfNetMapsTest Change-Id: I42a844227f258b91ba5b368d8e8abf82a773a801
This commit is contained in:
@@ -677,26 +677,6 @@ void TrafficController::dump(int fd, bool verbose) {
|
|||||||
dw.println("mConfigurationMap read ownerMatch configure failed with error: %s",
|
dw.println("mConfigurationMap read ownerMatch configure failed with error: %s",
|
||||||
configuration.error().message().c_str());
|
configuration.error().message().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
key = CURRENT_STATS_MAP_CONFIGURATION_KEY;
|
|
||||||
configuration = mConfigurationMap.readValue(key);
|
|
||||||
if (configuration.ok()) {
|
|
||||||
const char* statsMapDescription = "???";
|
|
||||||
switch (configuration.value()) {
|
|
||||||
case SELECT_MAP_A:
|
|
||||||
statsMapDescription = "SELECT_MAP_A";
|
|
||||||
break;
|
|
||||||
case SELECT_MAP_B:
|
|
||||||
statsMapDescription = "SELECT_MAP_B";
|
|
||||||
break;
|
|
||||||
// No default clause, so if we ever add a third map, this code will fail to build.
|
|
||||||
}
|
|
||||||
dw.println("current statsMap configuration: %d %s", configuration.value(),
|
|
||||||
statsMapDescription);
|
|
||||||
} else {
|
|
||||||
dw.println("mConfigurationMap read stats map configure failed with error: %s",
|
|
||||||
configuration.error().message().c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace net
|
} // namespace net
|
||||||
|
|||||||
@@ -803,14 +803,11 @@ TEST_F(TrafficControllerTest, dumpsysInvalidMaps) {
|
|||||||
"Bad file descriptor";
|
"Bad file descriptor";
|
||||||
const std::string kErrReadRulesConfig = "read ownerMatch configure failed with error: "
|
const std::string kErrReadRulesConfig = "read ownerMatch configure failed with error: "
|
||||||
"Read value of map -1 failed: Bad file descriptor";
|
"Read value of map -1 failed: Bad file descriptor";
|
||||||
const std::string kErrReadStatsMapConfig = "read stats map configure failed with error: "
|
|
||||||
"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("mCookieTagMap {}", kErrIterate),
|
||||||
fmt::format("mIfaceStatsMap {}", kErrIterate),
|
fmt::format("mIfaceStatsMap {}", kErrIterate),
|
||||||
fmt::format("mConfigurationMap {}", kErrReadRulesConfig),
|
fmt::format("mConfigurationMap {}", kErrReadRulesConfig)};
|
||||||
fmt::format("mConfigurationMap {}", kErrReadStatsMapConfig)};
|
|
||||||
EXPECT_TRUE(expectDumpsysContains(expectedLines));
|
EXPECT_TRUE(expectDumpsysContains(expectedLines));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -984,6 +984,17 @@ public class BpfNetMaps {
|
|||||||
return sj.toString();
|
return sj.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void dumpCurrentStatsMapConfig(final IndentingPrintWriter pw) {
|
||||||
|
try {
|
||||||
|
final long config = sConfigurationMap.getValue(CURRENT_STATS_MAP_CONFIGURATION_KEY).val;
|
||||||
|
final String currentStatsMap =
|
||||||
|
(config == STATS_SELECT_MAP_A) ? "SELECT_MAP_A" : "SELECT_MAP_B";
|
||||||
|
pw.println("current statsMap configuration: " + config + " " + currentStatsMap);
|
||||||
|
} catch (ErrnoException e) {
|
||||||
|
pw.println("Falied to read current statsMap configuration: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump BPF maps
|
* Dump BPF maps
|
||||||
*
|
*
|
||||||
@@ -1003,6 +1014,9 @@ public class BpfNetMaps {
|
|||||||
mDeps.nativeDump(fd, verbose);
|
mDeps.nativeDump(fd, verbose);
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
|
dumpCurrentStatsMapConfig(pw);
|
||||||
|
pw.println();
|
||||||
|
|
||||||
BpfDump.dumpMap(sUidOwnerMap, pw, "sUidOwnerMap",
|
BpfDump.dumpMap(sUidOwnerMap, pw, "sUidOwnerMap",
|
||||||
(uid, match) -> {
|
(uid, match) -> {
|
||||||
if ((match.rule & IIF_MATCH) != 0) {
|
if ((match.rule & IIF_MATCH) != 0) {
|
||||||
|
|||||||
@@ -146,6 +146,8 @@ public final class BpfNetMapsTest {
|
|||||||
doReturn(0).when(mDeps).synchronizeKernelRCU();
|
doReturn(0).when(mDeps).synchronizeKernelRCU();
|
||||||
BpfNetMaps.setEnableJavaBpfMapForTest(true /* enable */);
|
BpfNetMaps.setEnableJavaBpfMapForTest(true /* enable */);
|
||||||
BpfNetMaps.setConfigurationMapForTest(mConfigurationMap);
|
BpfNetMaps.setConfigurationMapForTest(mConfigurationMap);
|
||||||
|
mConfigurationMap.updateEntry(
|
||||||
|
CURRENT_STATS_MAP_CONFIGURATION_KEY, new U32(STATS_SELECT_MAP_A));
|
||||||
BpfNetMaps.setUidOwnerMapForTest(mUidOwnerMap);
|
BpfNetMaps.setUidOwnerMapForTest(mUidOwnerMap);
|
||||||
BpfNetMaps.setUidPermissionMapForTest(mUidPermissionMap);
|
BpfNetMaps.setUidPermissionMapForTest(mUidPermissionMap);
|
||||||
BpfNetMaps.setCookieTagMapForTest(mCookieTagMap);
|
BpfNetMaps.setCookieTagMapForTest(mCookieTagMap);
|
||||||
@@ -1017,4 +1019,16 @@ public final class BpfNetMapsTest {
|
|||||||
doTestDumpUidOwnerMap(DOZABLE_MATCH | invalid_match,
|
doTestDumpUidOwnerMap(DOZABLE_MATCH | invalid_match,
|
||||||
"DOZABLE_MATCH UNKNOWN_MATCH(" + invalid_match + ")");
|
"DOZABLE_MATCH UNKNOWN_MATCH(" + invalid_match + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@IgnoreUpTo(Build.VERSION_CODES.S_V2)
|
||||||
|
public void testDumpCurrentStatsMapConfig() throws Exception {
|
||||||
|
mConfigurationMap.updateEntry(
|
||||||
|
CURRENT_STATS_MAP_CONFIGURATION_KEY, new U32(STATS_SELECT_MAP_A));
|
||||||
|
assertDumpContains(getDump(), "current statsMap configuration: 0 SELECT_MAP_A");
|
||||||
|
|
||||||
|
mConfigurationMap.updateEntry(
|
||||||
|
CURRENT_STATS_MAP_CONFIGURATION_KEY, new U32(STATS_SELECT_MAP_B));
|
||||||
|
assertDumpContains(getDump(), "current statsMap configuration: 1 SELECT_MAP_B");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user