Merge "make failure on map creation returns -errno"
This commit is contained in:
commit
e5b8aa240b
1 changed files with 4 additions and 2 deletions
|
|
@ -434,6 +434,7 @@ static int createMaps(const char* elfPath, ifstream& elfFile, vector<unique_fd>&
|
|||
|
||||
for (int i = 0; i < (int)mapNames.size(); i++) {
|
||||
unique_fd fd;
|
||||
int saved_errno;
|
||||
// Format of pin location is /sys/fs/bpf/<prefix>map_<filename>_<mapname>
|
||||
string mapPinLoc;
|
||||
bool reuse = false;
|
||||
|
|
@ -441,16 +442,17 @@ static int createMaps(const char* elfPath, ifstream& elfFile, vector<unique_fd>&
|
|||
mapPinLoc = string(BPF_FS_PATH) + prefix + "map_" + fname + "_" + string(mapNames[i]);
|
||||
if (access(mapPinLoc.c_str(), F_OK) == 0) {
|
||||
fd.reset(bpf_obj_get(mapPinLoc.c_str()));
|
||||
saved_errno = errno;
|
||||
ALOGD("bpf_create_map reusing map %s, ret: %d\n", mapNames[i].c_str(), fd.get());
|
||||
reuse = true;
|
||||
} else {
|
||||
fd.reset(bpf_create_map(md[i].type, mapNames[i].c_str(), md[i].key_size, md[i].value_size,
|
||||
md[i].max_entries, md[i].map_flags));
|
||||
saved_errno = errno;
|
||||
ALOGD("bpf_create_map name %s, ret: %d\n", mapNames[i].c_str(), fd.get());
|
||||
}
|
||||
|
||||
if (fd < 0) return fd;
|
||||
if (fd == 0) return -EINVAL;
|
||||
if (fd < 0) return -saved_errno;
|
||||
|
||||
if (!reuse) {
|
||||
ret = bpf_obj_pin(fd, mapPinLoc.c_str());
|
||||
|
|
|
|||
Loading…
Reference in a new issue