add more precise bpf levels
This is to allow fixing a broken OffloadUtils netd test, but this will
also be useful for future support to make programs per kernel version.
We make the string versions of the enum more readable, because there
is exactly one user:
adb shell dumpsys netd | egrep -i bpf
BPF module status: enabled
BPF support level: Extended [4.14]
...
Test: build, atest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I843bd7355703a78acc8343ca7f647ce9366927eb
diff --git a/libbpf_android/include/bpf/BpfUtils.h b/libbpf_android/include/bpf/BpfUtils.h
index be3cc8f..06dcc47 100644
--- a/libbpf_android/include/bpf/BpfUtils.h
+++ b/libbpf_android/include/bpf/BpfUtils.h
@@ -40,10 +40,12 @@
NONE,
// Devices shipped in P with android 4.9 kernel only have the basic eBPF
// functionalities such as xt_bpf and cgroup skb filter.
- BASIC,
+ BASIC_4_9,
// For devices that have 4.14 kernel. It supports advanced features like
// map_in_map and cgroup socket filter.
- EXTENDED,
+ EXTENDED_4_14,
+ EXTENDED_4_19,
+ EXTENDED_5_4,
};
constexpr const int OVERFLOW_COUNTERSET = 2;
@@ -166,13 +168,13 @@
if (android::bpf::isBpfSupported()) return; \
} while (0)
-#define SKIP_IF_EXTENDED_BPF_NOT_SUPPORTED \
- do { \
- if (android::bpf::getBpfSupportLevel() < android::bpf::BpfLevel::EXTENDED) { \
- 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::getBpfSupportLevel() < android::bpf::BpfLevel::EXTENDED_4_14) { \
+ GTEST_LOG_(INFO) << "This test is skipped since extended bpf feature" \
+ << "not supported\n"; \
+ return; \
+ } \
} while (0)
} // namespace bpf