From 21ce721bc087d679686acedd06ec7d2b19cad164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Mon, 13 Jun 2022 17:28:41 -0700 Subject: [PATCH] BpfHandler.h - switch mStatsMapB from BpfMap to BpfMapRO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We'd like to switch more of these, but this is the only one where tests don't get in our way. We'll fix the rest later. This gives us an *example* for further testing. Test: TreeHugger Signed-off-by: Maciej Żenczykowski Change-Id: I9b280c7ba2d19644fc3cdd0c132de85f45df69b4 --- netd/BpfHandler.cpp | 1 + netd/BpfHandler.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/netd/BpfHandler.cpp b/netd/BpfHandler.cpp index 42d0de5666..5ae8ab6ee3 100644 --- a/netd/BpfHandler.cpp +++ b/netd/BpfHandler.cpp @@ -199,6 +199,7 @@ int BpfHandler::tagSocket(int sockFd, uint32_t tag, uid_t chargeUid, uid_t realU BpfMap& currentMap = (configuration.value() == SELECT_MAP_A) ? mStatsMapA : mStatsMapB; + // 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(), diff --git a/netd/BpfHandler.h b/netd/BpfHandler.h index 05b9ebc81d..7e3b94d6e8 100644 --- a/netd/BpfHandler.h +++ b/netd/BpfHandler.h @@ -23,6 +23,7 @@ #include "bpf_shared.h" using android::bpf::BpfMap; +using android::bpf::BpfMapRO; namespace android { namespace net { @@ -61,7 +62,7 @@ class BpfHandler { BpfMap mCookieTagMap; BpfMap mStatsMapA; - BpfMap mStatsMapB; + BpfMapRO mStatsMapB; BpfMap mConfigurationMap; BpfMap mUidPermissionMap;