NetBpfLoad: log on non-LTS or too old LTS kernel version

minimum versions chosen to match:
  //system/netd/tests/kernel_test.cpp
  //kernel/tests/net/test/kernel_feature_test.py

Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ife6900333d97181765460c16676172bf05f8fd5f
This commit is contained in:
Maciej Żenczykowski 2024-04-25 23:04:09 -07:00
commit c982a4be64

View file

@ -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