From 3a085154c54621bbef7dbeb072715a554d8bac3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Wed, 18 Sep 2024 23:45:52 +0000 Subject: [PATCH] NetBpfLoad: noop - all programs are critical MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All 6 .c files under bpf/progs are flagged CRITICAL(), and as such we can simplify this logic. Test: TreeHugger Signed-off-by: Maciej Żenczykowski Change-Id: I884705e1f0fdb20c992499aa2c83d5953a24fd9e --- bpf/loader/NetBpfLoad.cpp | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/bpf/loader/NetBpfLoad.cpp b/bpf/loader/NetBpfLoad.cpp index 69f1cb5b58..f36945891b 100644 --- a/bpf/loader/NetBpfLoad.cpp +++ b/bpf/loader/NetBpfLoad.cpp @@ -215,7 +215,7 @@ typedef struct { * is the name of the program, and tracepoint is the type. * * However, be aware that you should not be directly using the SECTION() macro. - * Instead use the DEFINE_(BPF|XDP)_(PROG|MAP)... & LICENSE/CRITICAL macros. + * Instead use the DEFINE_(BPF|XDP)_(PROG|MAP)... & LICENSE macros. * * Programs shipped inside the tethering apex should be limited to networking stuff, * as KPROBE, PERF_EVENT, TRACEPOINT are dangerous to use from mainline updatable code, @@ -1105,30 +1105,22 @@ static int loadCodeSections(const char* elfPath, vector& cs, const return 0; } -int loadProg(const char* const elfPath, bool* const isCritical, const unsigned int bpfloader_ver, +int loadProg(const char* const elfPath, const unsigned int bpfloader_ver, const char* const prefix) { vector license; - vector critical; vector cs; vector mapFds; int ret; - if (!isCritical) return -1; - *isCritical = false; - ifstream elfFile(elfPath, ios::in | ios::binary); if (!elfFile.is_open()) return -1; - ret = readSectionByName("critical", elfFile, critical); - *isCritical = !ret; - ret = readSectionByName("license", elfFile, license); if (ret) { ALOGE("Couldn't find license in %s", elfPath); return ret; } else { - ALOGD("Loading %s%s ELF object %s with license %s", - *isCritical ? "critical for " : "optional", *isCritical ? (char*)critical.data() : "", + ALOGD("Loading ELF object %s with license %s", elfPath, (char*)license.data()); } @@ -1230,10 +1222,9 @@ static int loadAllElfObjects(const unsigned int bpfloader_ver, const Location& l string progPath(location.dir); progPath += s; - bool critical; - int ret = loadProg(progPath.c_str(), &critical, bpfloader_ver, location.prefix); + int ret = loadProg(progPath.c_str(), bpfloader_ver, location.prefix); if (ret) { - if (critical) retVal = ret; + retVal = ret; ALOGE("Failed to load object: %s, ret: %s", progPath.c_str(), std::strerror(-ret)); } else { ALOGD("Loaded object: %s", progPath.c_str());