Merge "libbpf_android/BpfUtils - remove unused bpfProgLoad"
diff --git a/OWNERS b/OWNERS
index 9d84f37..094de96 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,5 +1,5 @@
-fengc@google.com
-joelaf@google.com
+connoro@google.com
 lorenzo@google.com
 maze@google.com
+smoreland@google.com
 sspatil@google.com
diff --git a/libbpf_android/Android.bp b/libbpf_android/Android.bp
index c369c8c..956fd93 100644
--- a/libbpf_android/Android.bp
+++ b/libbpf_android/Android.bp
@@ -54,6 +54,7 @@
         "libbpf_android_headers"
     ],
     export_header_lib_headers: ["libbpf_android_headers"],
+    export_shared_lib_headers: ["libbpf"],
     local_include_dirs: ["include"],
 
     defaults: ["bpf_defaults"],
diff --git a/libbpf_android/Loader.cpp b/libbpf_android/Loader.cpp
index fb4e36c..f4533cb 100644
--- a/libbpf_android/Loader.cpp
+++ b/libbpf_android/Loader.cpp
@@ -36,6 +36,7 @@
 #include <string>
 #include <vector>
 
+#include <android-base/properties.h>
 #include <android-base/strings.h>
 #include <android-base/unique_fd.h>
 
@@ -390,6 +391,7 @@
     string fname = pathToFilename(string(elfPath), true);
 
     ret = readSectionByName("maps", elfFile, mdData);
+    if (ret == -2) return 0;  // no maps to read
     if (ret) return ret;
     md.resize(mdData.size() / sizeof(struct bpf_map_def));
     memcpy(md.data(), mdData.data(), mdData.size());
@@ -589,5 +591,11 @@
     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
diff --git a/libbpf_android/include/bpf/BpfUtils.h b/libbpf_android/include/bpf/BpfUtils.h
index f2b2c84..e94f9e1 100644
--- a/libbpf_android/include/bpf/BpfUtils.h
+++ b/libbpf_android/include/bpf/BpfUtils.h
@@ -43,38 +43,6 @@
 namespace android {
 namespace bpf {
 
-struct UidTag {
-    uint32_t uid;
-    uint32_t tag;
-};
-
-struct StatsKey {
-    uint32_t uid;
-    uint32_t tag;
-    uint32_t counterSet;
-    uint32_t ifaceIndex;
-};
-
-struct StatsValue {
-    uint64_t rxPackets;
-    uint64_t rxBytes;
-    uint64_t txPackets;
-    uint64_t txBytes;
-};
-
-struct Stats {
-    uint64_t rxBytes;
-    uint64_t rxPackets;
-    uint64_t txBytes;
-    uint64_t txPackets;
-    uint64_t tcpRxPackets;
-    uint64_t tcpTxPackets;
-};
-
-struct IfaceValue {
-    char name[IFNAMSIZ];
-};
-
 int mapRetrieve(const char* pathname, uint32_t flags);
 
 enum class BpfLevel {
diff --git a/libbpf_android/include/libbpf_android.h b/libbpf_android/include/libbpf_android.h
index cea707c..0a01c85 100644
--- a/libbpf_android/include/libbpf_android.h
+++ b/libbpf_android/include/libbpf_android.h
@@ -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