ease debugging - print pinned bpf prog & map ids am: 57412c2a27 am: 665c49f370

Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/2103404

Change-Id: Ifcdff47ee0f9b7b32e5ffe936221caf0ace5d1e9
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Maciej Żenczykowski 2022-05-23 20:02:10 +00:00 committed by Automerger Merge Worker
commit 18e62eb9c0

View file

@ -30,9 +30,9 @@
#include <sys/wait.h>
#include <unistd.h>
// This is BpfLoader v0.13
// This is BpfLoader v0.14
#define BPFLOADER_VERSION_MAJOR 0u
#define BPFLOADER_VERSION_MINOR 13u
#define BPFLOADER_VERSION_MINOR 14u
#define BPFLOADER_VERSION ((BPFLOADER_VERSION_MAJOR << 16) | BPFLOADER_VERSION_MINOR)
#include "bpf/BpfUtils.h"
@ -713,6 +713,15 @@ static int createMaps(const char* elfPath, ifstream& elfFile, vector<unique_fd>&
if (ret) return -errno;
}
struct bpf_map_info map_info = {};
__u32 map_info_len = sizeof(map_info);
int rv = bpf_obj_get_info_by_fd(fd, &map_info, &map_info_len);
if (rv) {
ALOGE("bpf_obj_get_info_by_fd failed, ret: %d [%d]\n", rv, errno);
} else {
ALOGI("map %s id %d\n", mapPinLoc.c_str(), map_info.id);
}
mapFds.push_back(std::move(fd));
}
@ -890,6 +899,15 @@ static int loadCodeSections(const char* elfPath, vector<codeSection>& cs, const
}
}
struct bpf_prog_info prog_info = {};
__u32 prog_info_len = sizeof(prog_info);
int rv = bpf_obj_get_info_by_fd(fd, &prog_info, &prog_info_len);
if (rv) {
ALOGE("bpf_obj_get_info_by_fd failed, ret: %d [%d]\n", rv, errno);
} else {
ALOGI("prog %s id %d\n", progPinLoc.c_str(), prog_info.id);
}
cs[i].prog_fd.reset(fd);
}