From 45e9372733ac1cd599e1e6bbc22f6b86659f9cdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Sat, 15 Jun 2024 11:47:26 -0700 Subject: [PATCH] use a second map for SingleWriterBpfMap test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit because the shared r/w lock on the first conflicts with the exclusive r/w lock on the second This fixes roughly *half* the BpfMapTest tests. Test: TreeHugger, atest BpfMapTest less broken Signed-off-by: Maciej Żenczykowski Change-Id: I9d500597cad16bb7756df3e6feb9a7aa762e59d9 --- .../src/com/android/networkstack/tethering/BpfMapTest.java | 4 +++- bpf_progs/test.c | 2 ++ tests/mts/bpf_existence_test.cpp | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Tethering/tests/privileged/src/com/android/networkstack/tethering/BpfMapTest.java b/Tethering/tests/privileged/src/com/android/networkstack/tethering/BpfMapTest.java index f8aa69f849..d5d941a2b2 100644 --- a/Tethering/tests/privileged/src/com/android/networkstack/tethering/BpfMapTest.java +++ b/Tethering/tests/privileged/src/com/android/networkstack/tethering/BpfMapTest.java @@ -69,6 +69,8 @@ public final class BpfMapTest { private static final int TEST_MAP_SIZE = 16; private static final String TETHER_DOWNSTREAM6_FS_PATH = "/sys/fs/bpf/tethering/map_test_tether_downstream6_map"; + private static final String TETHER2_DOWNSTREAM6_FS_PATH = + "/sys/fs/bpf/tethering/map_test_tether2_downstream6_map"; private ArrayMap mTestData; @@ -108,7 +110,7 @@ public final class BpfMapTest { private BpfMap openTestMap() throws Exception { return mShouldTestSingleWriterMap - ? new SingleWriterBpfMap<>(TETHER_DOWNSTREAM6_FS_PATH, TetherDownstream6Key.class, + ? new SingleWriterBpfMap<>(TETHER2_DOWNSTREAM6_FS_PATH, TetherDownstream6Key.class, Tether6Value.class) : new BpfMap<>(TETHER_DOWNSTREAM6_FS_PATH, TetherDownstream6Key.class, Tether6Value.class); diff --git a/bpf_progs/test.c b/bpf_progs/test.c index fff3512333..fd6f9b5c00 100644 --- a/bpf_progs/test.c +++ b/bpf_progs/test.c @@ -45,6 +45,8 @@ // Used only by TetheringPrivilegedTests, not by production code. DEFINE_BPF_MAP_GRW(tether_downstream6_map, HASH, TetherDownstream6Key, Tether6Value, 16, TETHERING_GID) +DEFINE_BPF_MAP_GRW(tether2_downstream6_map, HASH, TetherDownstream6Key, Tether6Value, 16, + TETHERING_GID) // Used only by BpfBitmapTest, not by production code. DEFINE_BPF_MAP_GRW(bitmap, ARRAY, int, uint64_t, 2, TETHERING_GID) diff --git a/tests/mts/bpf_existence_test.cpp b/tests/mts/bpf_existence_test.cpp index dca9dd725b..1dc2e90218 100644 --- a/tests/mts/bpf_existence_test.cpp +++ b/tests/mts/bpf_existence_test.cpp @@ -68,6 +68,7 @@ static const set MAINLINE_FOR_S_PLUS = { TETHERING "map_offload_tether_upstream6_map", TETHERING "map_test_bitmap", TETHERING "map_test_tether_downstream6_map", + TETHERING "map_test_tether2_downstream6_map", TETHERING "prog_offload_schedcls_tether_downstream4_ether", TETHERING "prog_offload_schedcls_tether_downstream4_rawip", TETHERING "prog_offload_schedcls_tether_downstream6_ether",