remove BpfLevel and getBpfSupportLevel in favour of isAtLeastKernelVersion
Test: builds, atest, TreeHugger Bug: 167500195 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: I50dbed1843a8c2802e1b416281e193ae7d282a99
This commit is contained in:
parent
d8a4578f30
commit
dcb5228f2c
2 changed files with 14 additions and 37 deletions
|
|
@ -94,8 +94,6 @@ int setrlimitForTest() {
|
|||
return res;
|
||||
}
|
||||
|
||||
#define KVER(a, b, c) ((a)*65536 + (b)*256 + (c))
|
||||
|
||||
unsigned kernelVersion() {
|
||||
struct utsname buf;
|
||||
int ret = uname(&buf);
|
||||
|
|
@ -112,21 +110,5 @@ unsigned kernelVersion() {
|
|||
return KVER(kver_major, kver_minor, kver_sub);
|
||||
}
|
||||
|
||||
static BpfLevel getUncachedBpfSupportLevel() {
|
||||
unsigned kver = kernelVersion();
|
||||
|
||||
if (kver >= KVER(5, 4, 0)) return BpfLevel::EXTENDED_5_4;
|
||||
if (kver >= KVER(4, 19, 0)) return BpfLevel::EXTENDED_4_19;
|
||||
if (kver >= KVER(4, 14, 0)) return BpfLevel::EXTENDED_4_14;
|
||||
|
||||
// Basic BPF support is required on all devices.
|
||||
return BpfLevel::BASIC_4_9;
|
||||
}
|
||||
|
||||
BpfLevel getBpfSupportLevel() {
|
||||
static BpfLevel cache = getUncachedBpfSupportLevel();
|
||||
return cache;
|
||||
}
|
||||
|
||||
} // namespace bpf
|
||||
} // namespace android
|
||||
|
|
|
|||
|
|
@ -30,17 +30,6 @@
|
|||
namespace android {
|
||||
namespace bpf {
|
||||
|
||||
enum class BpfLevel {
|
||||
// Devices shipped in P with android 4.9 kernel only have the basic eBPF
|
||||
// functionalities such as xt_bpf and cgroup skb filter.
|
||||
BASIC_4_9,
|
||||
// For devices that have 4.14 kernel. It supports advanced features like
|
||||
// map_in_map and cgroup socket filter.
|
||||
EXTENDED_4_14,
|
||||
EXTENDED_4_19,
|
||||
EXTENDED_5_4,
|
||||
};
|
||||
|
||||
constexpr const int OVERFLOW_COUNTERSET = 2;
|
||||
|
||||
constexpr const uint64_t NONEXISTENT_COOKIE = 0;
|
||||
|
|
@ -50,20 +39,26 @@ constexpr const int MINIMUM_API_REQUIRED = 28;
|
|||
uint64_t getSocketCookie(int sockFd);
|
||||
int synchronizeKernelRCU();
|
||||
int setrlimitForTest();
|
||||
|
||||
#define KVER(a, b, c) ((a)*65536 + (b)*256 + (c))
|
||||
|
||||
unsigned kernelVersion();
|
||||
BpfLevel getBpfSupportLevel();
|
||||
|
||||
static inline bool isAtLeastKernelVersion(unsigned major, unsigned minor, unsigned sub) {
|
||||
return kernelVersion() >= KVER(major, minor, sub);
|
||||
}
|
||||
|
||||
inline bool isBpfSupported() {
|
||||
return true;
|
||||
}
|
||||
|
||||
#define SKIP_IF_EXTENDED_BPF_NOT_SUPPORTED \
|
||||
do { \
|
||||
if (android::bpf::getBpfSupportLevel() < android::bpf::BpfLevel::EXTENDED_4_14) { \
|
||||
GTEST_LOG_(INFO) << "This test is skipped since extended bpf feature" \
|
||||
<< "not supported\n"; \
|
||||
return; \
|
||||
} \
|
||||
#define SKIP_IF_EXTENDED_BPF_NOT_SUPPORTED \
|
||||
do { \
|
||||
if (!android::bpf::isAtLeastKernelVersion(4, 14, 0)) { \
|
||||
GTEST_LOG_(INFO) << "This test is skipped since extended bpf feature" \
|
||||
<< "not supported\n"; \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
} // namespace bpf
|
||||
|
|
|
|||
Loading…
Reference in a new issue