From 95c6fff6a22f541038bd3a397d68fed9a14e49eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Tue, 30 Apr 2024 22:45:24 -0700 Subject: [PATCH] BpfLoader: exec mainline netbpfload for finalization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move setting 'bpf.progs_loaded' property to 1 into mainline. This doesn't terribly matter, but it gives mainline bpf loading code a chance to run after platform and perform any required finalization. While at it also use distinctive error return values, as these are often the only thing that init reports about a bpfloader failure. Test: TreeHugger Signed-off-by: Maciej Żenczykowski Change-Id: If502cf07c8ceed306c18821075a92f99437da4dd --- loader/BpfLoader.cpp | 16 ++++++---------- loader/Loader.cpp | 1 - 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/loader/BpfLoader.cpp b/loader/BpfLoader.cpp index 9f61ba1..db86854 100644 --- a/loader/BpfLoader.cpp +++ b/loader/BpfLoader.cpp @@ -40,7 +40,6 @@ #include #include -#include #include #include #include @@ -147,8 +146,7 @@ int createSysFsBpfSubDir(const char* const prefix) { return 0; } -int main(int argc, char** argv) { - (void)argc; +int main(int __unused argc, char** argv, char * const envp[]) { android::base::InitLogging(argv, &android::base::KernelLogger); // Load all ELF objects, create programs and maps, and pin them @@ -160,14 +158,12 @@ int main(int argc, char** argv) { "problems or startup script race."); ALOGE("--- DO NOT EXPECT SYSTEM TO BOOT SUCCESSFULLY ---"); sleep(20); - return 2; + return 120; } } - if (!android::base::SetProperty("bpf.progs_loaded", "1")) { - ALOGE("Failed to set bpf.progs_loaded property"); - return 1; - } - - return 0; + const char * args[] = { "/apex/com.android.tethering/bin/netbpfload", "done", NULL, }; + execve(args[0], (char**)args, envp); + ALOGE("FATAL: execve(): %d[%s]", errno, strerror(errno)); + return 121; } diff --git a/loader/Loader.cpp b/loader/Loader.cpp index dd242e2..d3cfe81 100644 --- a/loader/Loader.cpp +++ b/loader/Loader.cpp @@ -46,7 +46,6 @@ #include #include -#include #include #include