Merge "move bpf test map into a separate file" am: ab44322f9c

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/1554234

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Ic714fbc7a1f61b29d4967b85415c00c2700df51b
This commit is contained in:
Maciej Żenczykowski
2021-01-19 11:38:24 +00:00
committed by Automerger Merge Worker
5 changed files with 45 additions and 6 deletions

View File

@@ -27,7 +27,10 @@ apex {
jni_libs: [ jni_libs: [
"libservice-connectivity", "libservice-connectivity",
], ],
bpfs: ["offload.o"], bpfs: [
"offload.o",
"test.o",
],
apps: ["Tethering"], apps: ["Tethering"],
manifest: "manifest.json", manifest: "manifest.json",
key: "com.android.tethering.key", key: "com.android.tethering.key",

View File

@@ -31,3 +31,18 @@ bpf {
"system/netd/libnetdutils/include", // for UidConstants.h "system/netd/libnetdutils/include", // for UidConstants.h
], ],
} }
bpf {
name: "test.o",
srcs: ["test.c"],
cflags: [
"-Wall",
"-Werror",
],
include_dirs: [
// TODO: get rid of system/netd.
"system/netd/bpf_progs", // for bpf_net_helpers.h
"system/netd/libnetdbpf/include", // for bpf_shared.h
"system/netd/libnetdutils/include", // for UidConstants.h
],
}

View File

@@ -34,10 +34,6 @@ DEFINE_BPF_MAP_GRW(tether_stats_map, HASH, uint32_t, TetherStatsValue, 16, AID_N
// (tethering allowed when stats[iif].rxBytes + stats[iif].txBytes < limit[iif]) // (tethering allowed when stats[iif].rxBytes + stats[iif].txBytes < limit[iif])
DEFINE_BPF_MAP_GRW(tether_limit_map, HASH, uint32_t, uint64_t, 16, AID_NETWORK_STACK) DEFINE_BPF_MAP_GRW(tether_limit_map, HASH, uint32_t, uint64_t, 16, AID_NETWORK_STACK)
// Used only by TetheringPrivilegedTests, not by production code.
DEFINE_BPF_MAP_GRW(tether_ingress_map_TEST, HASH, TetherIngressKey, TetherIngressValue, 16,
AID_NETWORK_STACK)
static inline __always_inline int do_forward(struct __sk_buff* skb, bool is_ethernet) { static inline __always_inline int do_forward(struct __sk_buff* skb, bool is_ethernet) {
int l2_header_size = is_ethernet ? sizeof(struct ethhdr) : 0; int l2_header_size = is_ethernet ? sizeof(struct ethhdr) : 0;
void* data = (void*)(long)skb->data; void* data = (void*)(long)skb->data;

View File

@@ -0,0 +1,25 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "bpf_helpers.h"
#include "bpf_net_helpers.h"
#include "netdbpf/bpf_shared.h"
// Used only by TetheringPrivilegedTests, not by production code.
DEFINE_BPF_MAP_GRW(tether_ingress_map, HASH, TetherIngressKey, TetherIngressValue, 16,
AID_NETWORK_STACK)
LICENSE("Apache 2.0");

View File

@@ -52,7 +52,7 @@ public final class BpfMapTest {
// Sync from packages/modules/Connectivity/Tethering/bpf_progs/offload.c. // Sync from packages/modules/Connectivity/Tethering/bpf_progs/offload.c.
private static final int TEST_MAP_SIZE = 16; private static final int TEST_MAP_SIZE = 16;
private static final String TETHER_INGRESS_FS_PATH = private static final String TETHER_INGRESS_FS_PATH =
"/sys/fs/bpf/map_offload_tether_ingress_map_TEST"; "/sys/fs/bpf/map_test_tether_ingress_map";
private ArrayMap<TetherIngressKey, TetherIngressValue> mTestData; private ArrayMap<TetherIngressKey, TetherIngressValue> mTestData;