introduce mapRetrieveLocklessRW() am: 0fff839ae6
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3134554 Change-Id: I865908cecfaa37dca1959e9174065fcda756b964 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
e64933fecc
2 changed files with 9 additions and 3 deletions
|
|
@ -80,7 +80,8 @@ static void verifyPerms(const char * const path,
|
|||
case VERIFY_BIN: return;
|
||||
case VERIFY_PROG: fd = bpf::retrieveProgram(path); break;
|
||||
case VERIFY_MAP_RO: fd = bpf::mapRetrieveRO(path); break;
|
||||
case VERIFY_MAP_RW: fd = bpf::mapRetrieveRW(path); break;
|
||||
// lockless: we're just checking access rights and will immediately close the fd
|
||||
case VERIFY_MAP_RW: fd = bpf::mapRetrieveLocklessRW(path); break;
|
||||
}
|
||||
|
||||
if (fd < 0) ALOGF("bpf_obj_get '%s' failed, errno=%d", path, errno);
|
||||
|
|
|
|||
|
|
@ -166,11 +166,16 @@ inline int bpfLock(int fd, short type) {
|
|||
return ret; // most likely -1 with errno == EAGAIN, due to already held lock
|
||||
}
|
||||
|
||||
inline int mapRetrieveExclusiveRW(const char* pathname) {
|
||||
return bpfLock(bpfFdGet(pathname, 0), F_WRLCK);
|
||||
inline int mapRetrieveLocklessRW(const char* pathname) {
|
||||
return bpfFdGet(pathname, 0);
|
||||
}
|
||||
|
||||
inline int mapRetrieveExclusiveRW(const char* pathname) {
|
||||
return bpfLock(mapRetrieveLocklessRW(pathname), F_WRLCK);
|
||||
}
|
||||
|
||||
inline int mapRetrieveRW(const char* pathname) {
|
||||
return bpfLock(bpfFdGet(pathname, 0), F_RDLCK);
|
||||
return bpfLock(mapRetrieveLocklessRW(pathname), F_RDLCK);
|
||||
}
|
||||
|
||||
inline int mapRetrieveRO(const char* pathname) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue