Move ownerMatch config dump to BpfNetMaps
Information in the dump does not change .... current ownerMatch configuration: 516 DOZABLE_MATCH OEM_DENY_1_MATCH .... Bug: 217624062 Test: dumpsys connectivity trafficcontroller, atest BpfNetMapsTest Change-Id: I5f7b56e4ba03256414f49d0e82d65477fb97f05a
This commit is contained in:
@@ -667,16 +667,6 @@ void TrafficController::dump(int fd, bool verbose) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dw.blankline();
|
dw.blankline();
|
||||||
|
|
||||||
uint32_t key = UID_RULES_CONFIGURATION_KEY;
|
|
||||||
auto configuration = mConfigurationMap.readValue(key);
|
|
||||||
if (configuration.ok()) {
|
|
||||||
dw.println("current ownerMatch configuration: %d%s", configuration.value(),
|
|
||||||
uidMatchTypeToString(configuration.value()).c_str());
|
|
||||||
} else {
|
|
||||||
dw.println("mConfigurationMap read ownerMatch configure failed with error: %s",
|
|
||||||
configuration.error().message().c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace net
|
} // namespace net
|
||||||
|
|||||||
@@ -806,8 +806,7 @@ TEST_F(TrafficControllerTest, dumpsysInvalidMaps) {
|
|||||||
|
|
||||||
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)};
|
|
||||||
EXPECT_TRUE(expectDumpsysContains(expectedLines));
|
EXPECT_TRUE(expectDumpsysContains(expectedLines));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -984,6 +984,15 @@ public class BpfNetMaps {
|
|||||||
return sj.toString();
|
return sj.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void dumpOwnerMatchConfig(final IndentingPrintWriter pw) {
|
||||||
|
try {
|
||||||
|
final long match = sConfigurationMap.getValue(UID_RULES_CONFIGURATION_KEY).val;
|
||||||
|
pw.println("current ownerMatch configuration: " + match + " " + matchToString(match));
|
||||||
|
} catch (ErrnoException e) {
|
||||||
|
pw.println("Failed to read ownerMatch configuration: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void dumpCurrentStatsMapConfig(final IndentingPrintWriter pw) {
|
private void dumpCurrentStatsMapConfig(final IndentingPrintWriter pw) {
|
||||||
try {
|
try {
|
||||||
final long config = sConfigurationMap.getValue(CURRENT_STATS_MAP_CONFIGURATION_KEY).val;
|
final long config = sConfigurationMap.getValue(CURRENT_STATS_MAP_CONFIGURATION_KEY).val;
|
||||||
@@ -1014,6 +1023,7 @@ public class BpfNetMaps {
|
|||||||
mDeps.nativeDump(fd, verbose);
|
mDeps.nativeDump(fd, verbose);
|
||||||
|
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
|
dumpOwnerMatchConfig(pw);
|
||||||
dumpCurrentStatsMapConfig(pw);
|
dumpCurrentStatsMapConfig(pw);
|
||||||
pw.println();
|
pw.println();
|
||||||
|
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ 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(UID_RULES_CONFIGURATION_KEY, new U32(0));
|
||||||
mConfigurationMap.updateEntry(
|
mConfigurationMap.updateEntry(
|
||||||
CURRENT_STATS_MAP_CONFIGURATION_KEY, new U32(STATS_SELECT_MAP_A));
|
CURRENT_STATS_MAP_CONFIGURATION_KEY, new U32(STATS_SELECT_MAP_A));
|
||||||
BpfNetMaps.setUidOwnerMapForTest(mUidOwnerMap);
|
BpfNetMaps.setUidOwnerMapForTest(mUidOwnerMap);
|
||||||
@@ -1031,4 +1032,42 @@ public final class BpfNetMapsTest {
|
|||||||
CURRENT_STATS_MAP_CONFIGURATION_KEY, new U32(STATS_SELECT_MAP_B));
|
CURRENT_STATS_MAP_CONFIGURATION_KEY, new U32(STATS_SELECT_MAP_B));
|
||||||
assertDumpContains(getDump(), "current statsMap configuration: 1 SELECT_MAP_B");
|
assertDumpContains(getDump(), "current statsMap configuration: 1 SELECT_MAP_B");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void doTestDumpOwnerMatchConfig(final long match, final String matchString)
|
||||||
|
throws Exception {
|
||||||
|
mConfigurationMap.updateEntry(UID_RULES_CONFIGURATION_KEY, new U32(match));
|
||||||
|
assertDumpContains(getDump(),
|
||||||
|
"current ownerMatch configuration: " + match + " " + matchString);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@IgnoreUpTo(Build.VERSION_CODES.S_V2)
|
||||||
|
public void testDumpUidOwnerMapConfig() throws Exception {
|
||||||
|
doTestDumpOwnerMatchConfig(HAPPY_BOX_MATCH, "HAPPY_BOX_MATCH");
|
||||||
|
doTestDumpOwnerMatchConfig(PENALTY_BOX_MATCH, "PENALTY_BOX_MATCH");
|
||||||
|
doTestDumpOwnerMatchConfig(DOZABLE_MATCH, "DOZABLE_MATCH");
|
||||||
|
doTestDumpOwnerMatchConfig(STANDBY_MATCH, "STANDBY_MATCH");
|
||||||
|
doTestDumpOwnerMatchConfig(POWERSAVE_MATCH, "POWERSAVE_MATCH");
|
||||||
|
doTestDumpOwnerMatchConfig(RESTRICTED_MATCH, "RESTRICTED_MATCH");
|
||||||
|
doTestDumpOwnerMatchConfig(LOW_POWER_STANDBY_MATCH, "LOW_POWER_STANDBY_MATCH");
|
||||||
|
doTestDumpOwnerMatchConfig(IIF_MATCH, "IIF_MATCH");
|
||||||
|
doTestDumpOwnerMatchConfig(LOCKDOWN_VPN_MATCH, "LOCKDOWN_VPN_MATCH");
|
||||||
|
doTestDumpOwnerMatchConfig(OEM_DENY_1_MATCH, "OEM_DENY_1_MATCH");
|
||||||
|
doTestDumpOwnerMatchConfig(OEM_DENY_2_MATCH, "OEM_DENY_2_MATCH");
|
||||||
|
doTestDumpOwnerMatchConfig(OEM_DENY_3_MATCH, "OEM_DENY_3_MATCH");
|
||||||
|
|
||||||
|
doTestDumpOwnerMatchConfig(HAPPY_BOX_MATCH | POWERSAVE_MATCH,
|
||||||
|
"HAPPY_BOX_MATCH POWERSAVE_MATCH");
|
||||||
|
doTestDumpOwnerMatchConfig(DOZABLE_MATCH | LOCKDOWN_VPN_MATCH | OEM_DENY_1_MATCH,
|
||||||
|
"DOZABLE_MATCH LOCKDOWN_VPN_MATCH OEM_DENY_1_MATCH");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@IgnoreUpTo(Build.VERSION_CODES.S_V2)
|
||||||
|
public void testDumpUidOwnerMapConfigWithInvalidMatch() throws Exception {
|
||||||
|
final long invalid_match = 1L << 31;
|
||||||
|
doTestDumpOwnerMatchConfig(invalid_match, "UNKNOWN_MATCH(" + invalid_match + ")");
|
||||||
|
doTestDumpOwnerMatchConfig(DOZABLE_MATCH | invalid_match,
|
||||||
|
"DOZABLE_MATCH UNKNOWN_MATCH(" + invalid_match + ")");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user