Use bpf get first key to iterate the maps
With the newest kernel support from upstream. We can directly get the
first key of each map with a null pointer instead of using a nonexistent
key for each map. This patch replaced all related iteration process with
this new function and cleaned up all unecessary code.
Bug: 30950746
Test: ./libbpfTest ./netd_unit_test
Change-Id: Ie1fd617964d37d2a1c12b2f34457c1cc1d912571
diff --git a/server/TrafficControllerTest.cpp b/server/TrafficControllerTest.cpp
index 187014f..d5e0e42 100644
--- a/server/TrafficControllerTest.cpp
+++ b/server/TrafficControllerTest.cpp
@@ -197,9 +197,8 @@
EXPECT_NE(uidSet.end(), uidSet.find(uid));
return BPF_CONTINUE;
};
- uint32_t nonExistentKey = NONEXISTENT_UID;
- uint8_t dummyValue;
- EXPECT_EQ(0, bpfIterateMap(nonExistentKey, dummyValue, targetMap, checkNoOtherUid));
+ uint32_t dummyKey;
+ EXPECT_EQ(0, bpfIterateMap(dummyKey, targetMap, checkNoOtherUid));
}
void checkUidMapReplace(const std::string& name, const std::vector<int32_t>& uids,