diff --git a/netbpfload/NetBpfLoad.cpp b/netbpfload/NetBpfLoad.cpp index f353ec1b4d..029520282a 100644 --- a/netbpfload/NetBpfLoad.cpp +++ b/netbpfload/NetBpfLoad.cpp @@ -226,6 +226,11 @@ static int logTetheringApexVersion(void) { return 0; } +static bool isGSI() { + // From //system/gsid/libgsi.cpp IsGsiRunning() + return !access("/metadata/gsi/dsu/booted", F_OK); +} + static int main(char** argv, char * const envp[]) { base::InitLogging(argv, &base::KernelLogger); @@ -281,6 +286,34 @@ static int main(char** argv, char * const envp[]) { return 1; } + if (isAtLeastV) { + bool bad = false; + + if (!isLtsKernel()) { + ALOGW("Android V only supports LTS kernels."); + bad = true; + } + +#define REQUIRE(maj, min, sub) \ + if (isKernelVersion(maj, min) && !isAtLeastKernelVersion(maj, min, sub)) { \ + ALOGW("Android V requires %d.%d kernel to be %d.%d.%d+.", maj, min, maj, min, sub); \ + bad = true; \ + } + + REQUIRE(4, 19, 236) + REQUIRE(5, 4, 186) + REQUIRE(5, 10, 199) + REQUIRE(5, 15, 136) + REQUIRE(6, 1, 57) + REQUIRE(6, 6, 0) + +#undef REQUIRE + + if (bad && !isGSI()) { + ALOGE("Unsupported kernel version (%07x).", kernelVersion()); + } + } + if (isUserspace32bit() && isAtLeastKernelVersion(6, 2, 0)) { /* Android 14/U should only launch on 64-bit kernels * T launches on 5.10/5.15