BpfHandler: U requires 4.14+, V requires 4.19+

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I3f6440dfe3eb71fbe845eb70c0a6c53110f8d46f
This commit is contained in:
Maciej Żenczykowski
2023-09-01 21:02:36 +00:00
parent 9cdea69732
commit c2dd01c739

View File

@@ -76,6 +76,19 @@ static Status checkProgramAccessible(const char* programPath) {
} }
static Status initPrograms(const char* cg2_path) { static Status initPrograms(const char* cg2_path) {
// This code was mainlined in T, so this should be trivially satisfied.
if (!modules::sdklevel::IsAtLeastT()) abort();
// S requires eBPF support which was only added in 4.9, so this should be satisfied.
if (!bpf::isAtLeastKernelVersion(4, 9, 0)) abort();
// U bumps the kernel requirement up to 4.14
if (modules::sdklevel::IsAtLeastU() && !bpf::isAtLeastKernelVersion(4, 14, 0)) abort();
// V bumps the kernel requirement up to 4.19
if (modules::sdklevel::IsAtLeastV() && !bpf::isAtLeastKernelVersion(4, 19, 0)) abort();
// U mandates this mount point (though it should also be the case on T)
if (modules::sdklevel::IsAtLeastU() && !!strcmp(cg2_path, "/sys/fs/cgroup")) abort(); if (modules::sdklevel::IsAtLeastU() && !!strcmp(cg2_path, "/sys/fs/cgroup")) abort();
unique_fd cg_fd(open(cg2_path, O_DIRECTORY | O_RDONLY | O_CLOEXEC)); unique_fd cg_fd(open(cg2_path, O_DIRECTORY | O_RDONLY | O_CLOEXEC));