diff --git a/netd/BpfHandler.cpp b/netd/BpfHandler.cpp index 2b773c9346..8081d12947 100644 --- a/netd/BpfHandler.cpp +++ b/netd/BpfHandler.cpp @@ -32,7 +32,6 @@ namespace android { namespace net { using base::unique_fd; -using bpf::NONEXISTENT_COOKIE; using bpf::getSocketCookie; using bpf::retrieveProgram; using netdutils::Status; @@ -185,7 +184,7 @@ int BpfHandler::tagSocket(int sockFd, uint32_t tag, uid_t chargeUid, uid_t realU } uint64_t sock_cookie = getSocketCookie(sockFd); - if (sock_cookie == NONEXISTENT_COOKIE) return -errno; + if (!sock_cookie) return -errno; UidTagValue newKey = {.uid = (uint32_t)chargeUid, .tag = tag}; @@ -249,7 +248,7 @@ int BpfHandler::tagSocket(int sockFd, uint32_t tag, uid_t chargeUid, uid_t realU int BpfHandler::untagSocket(int sockFd) { uint64_t sock_cookie = getSocketCookie(sockFd); - if (sock_cookie == NONEXISTENT_COOKIE) return -errno; + if (!sock_cookie) return -errno; if (!mCookieTagMap.isValid()) return -EPERM; base::Result res = mCookieTagMap.deleteValue(sock_cookie); diff --git a/service/jni/com_android_server_connectivity_ClatCoordinator.cpp b/service/jni/com_android_server_connectivity_ClatCoordinator.cpp index e63e4232d7..438963e172 100644 --- a/service/jni/com_android_server_connectivity_ClatCoordinator.cpp +++ b/service/jni/com_android_server_connectivity_ClatCoordinator.cpp @@ -538,7 +538,7 @@ static jlong com_android_server_connectivity_ClatCoordinator_getSocketCookie( } uint64_t sock_cookie = bpf::getSocketCookie(sockFd); - if (sock_cookie == bpf::NONEXISTENT_COOKIE) { + if (!sock_cookie) { throwIOException(env, "get socket cookie failed", errno); return -1; }