BpfNetMaps.java - array index U32 -> S32
This converts the key, which is an index in an array, of sConfigurationMap from U32 to S32. Since the array has exactly 2 elements, there's no real difference. In addition while the kernel does indeed index arrays with U32s, it doesn't matter, because you'd need to have over 2 billion elements in the bpf map (at which point you'd need GBs of ram for the bpf map itself)... Test: TreeHugger Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: If17efc25d910af642e519f9ecb6d0e8695c38d42
This commit is contained in:
@@ -106,13 +106,13 @@ public class BpfNetMaps {
|
||||
"/sys/fs/bpf/netd_shared/map_netd_uid_permission_map";
|
||||
private static final String COOKIE_TAG_MAP_PATH =
|
||||
"/sys/fs/bpf/netd_shared/map_netd_cookie_tag_map";
|
||||
private static final U32 UID_RULES_CONFIGURATION_KEY = new U32(0);
|
||||
private static final U32 CURRENT_STATS_MAP_CONFIGURATION_KEY = new U32(1);
|
||||
private static final S32 UID_RULES_CONFIGURATION_KEY = new S32(0);
|
||||
private static final S32 CURRENT_STATS_MAP_CONFIGURATION_KEY = new S32(1);
|
||||
private static final long UID_RULES_DEFAULT_CONFIGURATION = 0;
|
||||
private static final long STATS_SELECT_MAP_A = 0;
|
||||
private static final long STATS_SELECT_MAP_B = 1;
|
||||
|
||||
private static IBpfMap<U32, U32> sConfigurationMap = null;
|
||||
private static IBpfMap<S32, U32> sConfigurationMap = null;
|
||||
// BpfMap for UID_OWNER_MAP_PATH. This map is not accessed by others.
|
||||
private static IBpfMap<S32, UidOwnerValue> sUidOwnerMap = null;
|
||||
private static IBpfMap<S32, U8> sUidPermissionMap = null;
|
||||
@@ -146,7 +146,7 @@ public class BpfNetMaps {
|
||||
* Set configurationMap for test.
|
||||
*/
|
||||
@VisibleForTesting
|
||||
public static void setConfigurationMapForTest(IBpfMap<U32, U32> configurationMap) {
|
||||
public static void setConfigurationMapForTest(IBpfMap<S32, U32> configurationMap) {
|
||||
sConfigurationMap = configurationMap;
|
||||
}
|
||||
|
||||
@@ -175,10 +175,10 @@ public class BpfNetMaps {
|
||||
sCookieTagMap = cookieTagMap;
|
||||
}
|
||||
|
||||
private static IBpfMap<U32, U32> getConfigurationMap() {
|
||||
private static IBpfMap<S32, U32> getConfigurationMap() {
|
||||
try {
|
||||
return new BpfMap<>(
|
||||
CONFIGURATION_MAP_PATH, BpfMap.BPF_F_RDWR, U32.class, U32.class);
|
||||
CONFIGURATION_MAP_PATH, BpfMap.BPF_F_RDWR, S32.class, U32.class);
|
||||
} catch (ErrnoException e) {
|
||||
throw new IllegalStateException("Cannot open netd configuration map", e);
|
||||
}
|
||||
|
||||
@@ -103,8 +103,8 @@ public final class BpfNetMapsTest {
|
||||
private static final int NO_IIF = 0;
|
||||
private static final int NULL_IIF = 0;
|
||||
private static final String CHAINNAME = "fw_dozable";
|
||||
private static final U32 UID_RULES_CONFIGURATION_KEY = new U32(0);
|
||||
private static final U32 CURRENT_STATS_MAP_CONFIGURATION_KEY = new U32(1);
|
||||
private static final S32 UID_RULES_CONFIGURATION_KEY = new S32(0);
|
||||
private static final S32 CURRENT_STATS_MAP_CONFIGURATION_KEY = new S32(1);
|
||||
private static final List<Integer> FIREWALL_CHAINS = List.of(
|
||||
FIREWALL_CHAIN_DOZABLE,
|
||||
FIREWALL_CHAIN_STANDBY,
|
||||
@@ -124,7 +124,7 @@ public final class BpfNetMapsTest {
|
||||
@Mock INetd mNetd;
|
||||
@Mock BpfNetMaps.Dependencies mDeps;
|
||||
@Mock Context mContext;
|
||||
private final IBpfMap<U32, U32> mConfigurationMap = new TestBpfMap<>(U32.class, U32.class);
|
||||
private final IBpfMap<S32, U32> mConfigurationMap = new TestBpfMap<>(S32.class, U32.class);
|
||||
private final IBpfMap<S32, UidOwnerValue> mUidOwnerMap =
|
||||
new TestBpfMap<>(S32.class, UidOwnerValue.class);
|
||||
private final IBpfMap<S32, U8> mUidPermissionMap = new TestBpfMap<>(S32.class, U8.class);
|
||||
|
||||
Reference in New Issue
Block a user