From 23c02b0b7f17a1765aca1f56e772efe7a3dd495d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Wed, 2 Oct 2024 22:48:19 +0000 Subject: [PATCH] netd_updatable: only wait for bpf on <=V MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit netd is after synchronous start of bpfloader, so we don't actually need to wait for it at all. Test: TreeHugger Signed-off-by: Maciej Żenczykowski Change-Id: Ia1bcf8ac7d6756be44a1382581e6f2b5188bcb58 --- bpf/netd/BpfHandler.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/bpf/netd/BpfHandler.cpp b/bpf/netd/BpfHandler.cpp index 5dea851b7f..9131933f7a 100644 --- a/bpf/netd/BpfHandler.cpp +++ b/bpf/netd/BpfHandler.cpp @@ -201,7 +201,7 @@ static inline void waitForNetProgsLoaded() { } } -Status BpfHandler::init(const char* cg2_path) { +static inline void waitForBpf() { // Note: netd *can* be restarted, so this might get called a second time after boot is complete // at which point we don't need to (and shouldn't) wait for (more importantly start) loading bpf @@ -229,6 +229,21 @@ Status BpfHandler::init(const char* cg2_path) { } ALOGI("BPF programs are loaded"); +} + +Status BpfHandler::init(const char* cg2_path) { + // This wait is effectively a no-op on U QPR3+ devices (as netd starts + // *after* the synchronous exec_startbpfloader which calls NetBpfLoad) + // but checking for U QPR3 is hard. + // + // Waiting should not be required on U QPR3+ devices, + // ... + // + // ...unless someone changed 'exec_start bpfloader' to 'start bpfloader' + // in the rc file. + // + // TODO: should be: if (!modules::sdklevel::IsAtLeastW()) + if (android_get_device_api_level() <= __ANDROID_API_V__) waitForBpf(); RETURN_IF_NOT_OK(initPrograms(cg2_path)); RETURN_IF_NOT_OK(initMaps());