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
diff --git a/service/native/TrafficController.cpp b/service/native/TrafficController.cpp
index 8320a8a..912c048 100644
--- a/service/native/TrafficController.cpp
+++ b/service/native/TrafficController.cpp
@@ -677,26 +677,6 @@
dw.println("mConfigurationMap read ownerMatch configure failed with error: %s",
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
diff --git a/service/native/TrafficControllerTest.cpp b/service/native/TrafficControllerTest.cpp
index 6e45ef3..8f31452 100644
--- a/service/native/TrafficControllerTest.cpp
+++ b/service/native/TrafficControllerTest.cpp
@@ -803,14 +803,11 @@
"Bad file descriptor";
const std::string kErrReadRulesConfig = "read ownerMatch configure failed with error: "
"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 = {
fmt::format("mCookieTagMap {}", kErrIterate),
fmt::format("mIfaceStatsMap {}", kErrIterate),
- fmt::format("mConfigurationMap {}", kErrReadRulesConfig),
- fmt::format("mConfigurationMap {}", kErrReadStatsMapConfig)};
+ fmt::format("mConfigurationMap {}", kErrReadRulesConfig)};
EXPECT_TRUE(expectDumpsysContains(expectedLines));
}
diff --git a/service/src/com/android/server/BpfNetMaps.java b/service/src/com/android/server/BpfNetMaps.java
index e571415..e53bce1 100644
--- a/service/src/com/android/server/BpfNetMaps.java
+++ b/service/src/com/android/server/BpfNetMaps.java
@@ -984,6 +984,17 @@
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
*
@@ -1003,6 +1014,9 @@
mDeps.nativeDump(fd, verbose);
if (verbose) {
+ dumpCurrentStatsMapConfig(pw);
+ pw.println();
+
BpfDump.dumpMap(sUidOwnerMap, pw, "sUidOwnerMap",
(uid, match) -> {
if ((match.rule & IIF_MATCH) != 0) {