diff options
| author | Maciej Żenczykowski <maze@google.com> | 2022-06-08 06:46:19 +0000 |
|---|---|---|
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-06-08 06:46:19 +0000 |
| commit | a42ee4d17cdde71b65456d3569ed0004aebc34af (patch) | |
| tree | 3a51a3e916b289ae5f3190376846d1689209db99 | |
| parent | 8991bd3b422944ebb6cd1a85f0078fb074f4196e (diff) | |
| parent | 7f63f0ff8055f0ec0cbd949fa1f2c40537b9b1e3 (diff) | |
BpfMap: introduce resetMap(type, entries, flags) am: 7f63f0ff80
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/libs/net/+/18694820
Change-Id: I0621c1824c40d53335dd560bb22a3cf92583a033
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | common/native/bpf_headers/include/bpf/BpfMap.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/common/native/bpf_headers/include/bpf/BpfMap.h b/common/native/bpf_headers/include/bpf/BpfMap.h index bdffc0f..d07d610 100644 --- a/common/native/bpf_headers/include/bpf/BpfMap.h +++ b/common/native/bpf_headers/include/bpf/BpfMap.h @@ -102,6 +102,23 @@ class BpfMap { // Function that tries to get map from a pinned path. base::Result<void> init(const char* path); +#ifdef TEST_BPF_MAP + // due to Android SELinux limitations which prevent map creation by anyone besides the bpfloader + // this should only ever be used by test code, it is equivalent to: + // .reset(createMap(type, keysize, valuesize, max_entries, map_flags) + // TODO: derive map_flags from BpfMap vs BpfMapRO + base::Result<void> resetMap(bpf_map_type map_type, uint32_t max_entries, uint32_t map_flags = 0) { + int map_fd = createMap(map_type, sizeof(Key), sizeof(Value), max_entries, map_flags); + if (map_fd < 0) { + auto err = ErrnoErrorf("Unable to create map."); + mMapFd.reset(); + return err; + }; + mMapFd.reset(map_fd); + return {}; + } +#endif + // Iterate through the map and handle each key retrieved based on the filter // without modification of map content. base::Result<void> iterate( |
