Add BPF_MAP_LOCKLESS_FOR_TEST hack for root resolver tests
Per commit description of https://android-review.git.corp.google.com/c/platform/packages/modules/Connectivity/+/3109108 "Use SingleWriterBpfMap in BpfNetMaps": - firewall.cpp writes to sConfigurationMap, sUidOwnerMap, and sDataSaverEnabledMap, but that code only runs in tests because it requires root privileges. So either those maps need to not use SingleWriterBpfMap in the BpfNetMaps (which would affect performance), or we need to prevent the tests from grabbing the locks, or the tests will (presumably) fail. This avoids grabbing the locks from the test, even though this is absolutely terrible and likely breaks things... But in general the entire firewall.cpp file (and libconnectivity_native_test_utils target) are just one large modularization violation in need of major escalation... Test via: atest resolv_{gold,stress,integration,unit}_test Without this patch: resolv_gold_test: Passed: 16 resolv_integration_test: Passed: 53, Failed: 2, Ignored: 118, Assumption Failed: 0 (Completed With ERRORS) resolv_stress_test: Passed: 2 resolv_unit_test: Passed: 124, Failed: 2 4 tests failed -------------- ResolverMultinetworkTest#DnsWithVpn PrivateDns/TransportParameterizedTest#BlockDnsQuery/DoT CallbackTest#tagSocketCallback ResolvGetAddrInfoTest#InvalidParameters With this patch: resolv_gold_test: Passed: 16 resolv_integration_test: Passed: 178 resolv_stress_test: Passed: 2 resolv_unit_test: Passed: 126 Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ie97d015ef66c3864a23484e7ed190fe7d091af5c
This commit is contained in:
parent
9eca02a8fa
commit
04fb3862a9
2 changed files with 4 additions and 0 deletions
|
|
@ -135,6 +135,9 @@ int bpfGetFdMapId(const BPF_FD_TYPE map_fd);
|
|||
|
||||
inline int bpfLock(int fd, short type) {
|
||||
if (fd < 0) return fd; // pass any errors straight through
|
||||
#ifdef BPF_MAP_LOCKLESS_FOR_TEST
|
||||
return fd;
|
||||
#endif
|
||||
#ifdef BPF_FD_JUST_USE_INT
|
||||
int mapId = bpfGetFdMapId(fd);
|
||||
int saved_errno = errno;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <android-base/thread_annotations.h>
|
||||
#define BPF_MAP_LOCKLESS_FOR_TEST
|
||||
#include <bpf/BpfMap.h>
|
||||
#include "netd.h"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue