From 85d4a5e198ec038d68833618ffa62d31983451fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Sun, 20 Aug 2023 16:41:50 +0000 Subject: [PATCH] BpfHandler - remove use of getMap() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The FD number isn't actually useful debugging information, and I want to get rid of this fd leak out of BpfMap class. Test: TreeHugger Signed-off-by: Maciej Żenczykowski Change-Id: I981832b019b57f534bed1c1fbfedf6457abba6fa --- netd/BpfHandler.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/netd/BpfHandler.cpp b/netd/BpfHandler.cpp index d23927726e..73feee41d1 100644 --- a/netd/BpfHandler.cpp +++ b/netd/BpfHandler.cpp @@ -210,8 +210,8 @@ int BpfHandler::tagSocket(int sockFd, uint32_t tag, uid_t chargeUid, uid_t realU }; auto configuration = mConfigurationMap.readValue(CURRENT_STATS_MAP_CONFIGURATION_KEY); if (!configuration.ok()) { - ALOGE("Failed to get current configuration: %s, fd: %d", - strerror(configuration.error().code()), mConfigurationMap.getMap().get()); + ALOGE("Failed to get current configuration: %s", + strerror(configuration.error().code())); return -configuration.error().code(); } if (configuration.value() != SELECT_MAP_A && configuration.value() != SELECT_MAP_B) { @@ -224,7 +224,7 @@ int BpfHandler::tagSocket(int sockFd, uint32_t tag, uid_t chargeUid, uid_t realU // HACK: mStatsMapB becomes RW BpfMap here, but countUidStatsEntries doesn't modify so it works base::Result res = currentMap.iterate(countUidStatsEntries); if (!res.ok()) { - ALOGE("Failed to count the stats entry in map %d: %s", currentMap.getMap().get(), + ALOGE("Failed to count the stats entry in map: %s", strerror(res.error().code())); return -res.error().code(); } @@ -243,8 +243,7 @@ int BpfHandler::tagSocket(int sockFd, uint32_t tag, uid_t chargeUid, uid_t realU // should be fine to concurrently update the map while eBPF program is running. res = mCookieTagMap.writeValue(sock_cookie, newKey, BPF_ANY); if (!res.ok()) { - ALOGE("Failed to tag the socket: %s, fd: %d", strerror(res.error().code()), - mCookieTagMap.getMap().get()); + ALOGE("Failed to tag the socket: %s", strerror(res.error().code())); return -res.error().code(); } ALOGD("Socket with cookie %" PRIu64 " tagged successfully with tag %" PRIu32 " uid %u "