Merge "libbpf_android: waitForProgsLoaded"

This commit is contained in:
Steven Moreland 2020-01-13 22:12:06 +00:00 • committed by Gerrit Code Review
commit 1362229a2e
3 changed files with 13 additions and 0 deletions

View file

@ -54,6 +54,7 @@ cc_library {
"libbpf_android_headers"
],
export_header_lib_headers: ["libbpf_android_headers"],
export_shared_lib_headers: ["libbpf"],
local_include_dirs: ["include"],
defaults: ["bpf_defaults"],

View file

@ -36,6 +36,7 @@
#include <string>
#include <vector>
#include <android-base/properties.h>
#include <android-base/strings.h>
#include <android-base/unique_fd.h>
@ -589,5 +590,11 @@ int loadProg(const char* elfPath) {
return ret;
}
void waitForProgsLoaded() {
while (!android::base::WaitForProperty("bpf.progs_loaded", "1", std::chrono::seconds(5))) {
ALOGW("Waited 5s for bpf.progs_loaded, still waiting...");
}
}
} // namespace bpf
} // namespace android

View file

@ -23,8 +23,13 @@
namespace android {
namespace bpf {
// BPF loader implementation. Loads an eBPF ELF object
int loadProg(const char* elfpath);
// Wait for bpfloader to load BPF programs.
void waitForProgsLoaded();
} // namespace bpf
} // namespace android