bpfloader: pass whole struct Location to loadProg()
Simplify the loadProg() interface by passing struct Location instead
of passing its fields as separate arguments. Move struct Location into
libbpf_android.h to accommodate the change.
Change-Id: I39834b2645d38ba4c2eb5ea901a3da0f56a1912c
Signed-off-by: Connor O'Brien <connoro@google.com>
diff --git a/libbpf_android/Loader.cpp b/libbpf_android/Loader.cpp
index bc7ea76..5fe2e10 100644
--- a/libbpf_android/Loader.cpp
+++ b/libbpf_android/Loader.cpp
@@ -1137,9 +1137,7 @@
return 0;
}
-int loadProg(const char* elfPath, bool* isCritical, const char* prefix,
- const unsigned long long allowedDomainBitmask, const bpf_prog_type* allowed,
- size_t numAllowed) {
+int loadProg(const char* elfPath, bool* isCritical, const Location& location) {
vector<char> license;
vector<char> critical;
vector<codeSection> cs;
@@ -1212,7 +1210,8 @@
return -1;
}
- ret = readCodeSections(elfFile, cs, sizeOfBpfProgDef, allowed, numAllowed);
+ ret = readCodeSections(elfFile, cs, sizeOfBpfProgDef, location.allowedProgTypes,
+ location.allowedProgTypesLength);
if (ret) {
ALOGE("Couldn't read all code sections in %s", elfPath);
return ret;
@@ -1221,7 +1220,8 @@
/* Just for future debugging */
if (0) dumpAllCs(cs);
- ret = createMaps(elfPath, elfFile, mapFds, prefix, allowedDomainBitmask, sizeOfBpfMapDef);
+ ret = createMaps(elfPath, elfFile, mapFds, location.prefix, location.allowedDomainBitmask,
+ sizeOfBpfMapDef);
if (ret) {
ALOGE("Failed to create maps: (ret=%d) in %s", ret, elfPath);
return ret;
@@ -1232,7 +1232,8 @@
applyMapRelo(elfFile, mapFds, cs);
- ret = loadCodeSections(elfPath, cs, string(license.data()), prefix, allowedDomainBitmask);
+ ret = loadCodeSections(elfPath, cs, string(license.data()), location.prefix,
+ location.allowedDomainBitmask);
if (ret) ALOGE("Failed to load programs, loadCodeSections ret=%d", ret);
return ret;