Simplify the traffic stats entry struct
Since the framework API no longer support traffic stats detail such as
rxTcpPacket number or rxTcpBytes, The eBPF program and the native helper
functions no longer need to store those information as well. Removing
them from the struct StatsValue can save some space per stats entry and
reduce the total size of stats map.
Bug: 30950746
Test: run cts -m CtsNetTestCases -t android.net.cts.TrafficStatsTest
Change-Id: I70c24b762ecc9d58fc4a3ac48a7944416eff7c81
diff --git a/server/TrafficControllerTest.cpp b/server/TrafficControllerTest.cpp
index 6818f43..1ad3915 100644
--- a/server/TrafficControllerTest.cpp
+++ b/server/TrafficControllerTest.cpp
@@ -130,7 +130,7 @@
UidTag cookieMapkey = {.uid = (uint32_t)uid, .tag = tag};
EXPECT_EQ(0, writeToMapEntry(mFakeCookieTagMap, &cookie, &cookieMapkey, BPF_ANY));
*key = {.uid = uid, .tag = tag, .counterSet = TEST_COUNTERSET, .ifaceIndex = 1};
- StatsValue statsMapValue = {.rxTcpPackets = 1, .rxTcpBytes = 100};
+ StatsValue statsMapValue = {.rxPackets = 1, .rxBytes = 100};
int counterSet = TEST_COUNTERSET;
EXPECT_EQ(0, writeToMapEntry(mFakeUidCounterSetMap, &uid, &counterSet, BPF_ANY));
EXPECT_EQ(0, writeToMapEntry(mFakeTagStatsMap, key, &statsMapValue, BPF_ANY));
@@ -257,8 +257,8 @@
ASSERT_EQ(-1, findMapEntry(mFakeTagStatsMap, &tagStatsMapKey, &statsMapResult));
tagStatsMapKey.tag = 0;
ASSERT_EQ(0, findMapEntry(mFakeUidStatsMap, &tagStatsMapKey, &statsMapResult));
- ASSERT_EQ((uint64_t)1, statsMapResult.rxTcpPackets);
- ASSERT_EQ((uint64_t)100, statsMapResult.rxTcpBytes);
+ ASSERT_EQ((uint64_t)1, statsMapResult.rxPackets);
+ ASSERT_EQ((uint64_t)100, statsMapResult.rxBytes);
}
TEST_F(TrafficControllerTest, TestDeleteAllUidData) {
@@ -280,8 +280,8 @@
StatsKey removedStatsKey= {.uid = 0, .tag = 0, .counterSet = COUNTERSETS_LIMIT,
.ifaceIndex = 0};
ASSERT_EQ(0, findMapEntry(mFakeUidStatsMap, &removedStatsKey, &statsMapResult));
- ASSERT_EQ((uint64_t)1, statsMapResult.rxTcpPackets);
- ASSERT_EQ((uint64_t)100, statsMapResult.rxTcpBytes);
+ ASSERT_EQ((uint64_t)1, statsMapResult.rxPackets);
+ ASSERT_EQ((uint64_t)100, statsMapResult.rxBytes);
}
TEST_F(TrafficControllerTest, TestDeleteDataWithTwoTags) {
@@ -308,8 +308,8 @@
StatsValue statsMapResult;
ASSERT_EQ(-1, findMapEntry(mFakeTagStatsMap, &tagStatsMapKey1, &statsMapResult));
ASSERT_EQ(0, findMapEntry(mFakeTagStatsMap, &tagStatsMapKey2, &statsMapResult));
- ASSERT_EQ((uint64_t)1, statsMapResult.rxTcpPackets);
- ASSERT_EQ((uint64_t)100, statsMapResult.rxTcpBytes);
+ ASSERT_EQ((uint64_t)1, statsMapResult.rxPackets);
+ ASSERT_EQ((uint64_t)100, statsMapResult.rxBytes);
}
TEST_F(TrafficControllerTest, TestDeleteDataWithTwoUids) {
@@ -340,21 +340,21 @@
ASSERT_EQ(-1, findMapEntry(mFakeUidStatsMap, &tagStatsMapKey2, &statsMapResult));
tagStatsMapKey1.tag = 0;
ASSERT_EQ(0, findMapEntry(mFakeUidStatsMap, &tagStatsMapKey1, &statsMapResult));
- ASSERT_EQ((uint64_t)1, statsMapResult.rxTcpPackets);
- ASSERT_EQ((uint64_t)100, statsMapResult.rxTcpBytes);
+ ASSERT_EQ((uint64_t)1, statsMapResult.rxPackets);
+ ASSERT_EQ((uint64_t)100, statsMapResult.rxBytes);
StatsKey removedStatsKey= {.uid = 0, .tag = 0, .counterSet = COUNTERSETS_LIMIT,
.ifaceIndex = 0};
ASSERT_EQ(0, findMapEntry(mFakeUidStatsMap, &removedStatsKey, &statsMapResult));
- ASSERT_EQ((uint64_t)1, statsMapResult.rxTcpPackets);
- ASSERT_EQ((uint64_t)100, statsMapResult.rxTcpBytes);
+ ASSERT_EQ((uint64_t)1, statsMapResult.rxPackets);
+ ASSERT_EQ((uint64_t)100, statsMapResult.rxBytes);
// Delete the stats of the other uid. Check if it is properly added on the
// previous removedStats data.
ASSERT_EQ(0, mTc.deleteTagData(0, uid1));
ASSERT_EQ(-1, findMapEntry(mFakeUidStatsMap, &tagStatsMapKey1, &statsMapResult));
ASSERT_EQ(0, findMapEntry(mFakeUidStatsMap, &removedStatsKey, &statsMapResult));
- ASSERT_EQ((uint64_t)2, statsMapResult.rxTcpPackets);
- ASSERT_EQ((uint64_t)200, statsMapResult.rxTcpBytes);
+ ASSERT_EQ((uint64_t)2, statsMapResult.rxPackets);
+ ASSERT_EQ((uint64_t)200, statsMapResult.rxBytes);
}
} // namespace net