Set bpf.progs_loaded property when programs finish loading
The property bpf.progs_loaded will be used by services expecting BPF programs to be loaded and wait before they are loaded. Bug: 112334572 Change-Id: I19daa0caa84e2659e8790f0dd551d95ab824e13b Signed-off-by: Joel Fernandes <joelaf@google.com>
This commit is contained in:
parent
6e1341ef20
commit
d3ec871017
1 changed files with 14 additions and 0 deletions
|
@ -38,6 +38,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <android-base/properties.h>
|
||||
#include <android-base/stringprintf.h>
|
||||
#include <android-base/strings.h>
|
||||
#include <android-base/unique_fd.h>
|
||||
|
@ -86,6 +87,19 @@ void loadAllElfObjects(void) {
|
|||
}
|
||||
|
||||
int main() {
|
||||
std::string value = android::base::GetProperty("bpf.progs_loaded", "");
|
||||
if (value == "1") {
|
||||
ALOGI("Property bpf.progs_loaded is set, progs already loaded.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Load all ELF objects, create programs and maps, and pin them
|
||||
loadAllElfObjects();
|
||||
|
||||
if (android::base::SetProperty("bpf.progs_loaded", "1") == false) {
|
||||
ALOGE("Failed to set bpf.progs_loaded property\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue