Merge "NetBpfLoad: create/populate/pin kernel bugs bpf array" into main
This commit is contained in:
commit
8accc1234f
2 changed files with 25 additions and 7 deletions
|
|
@ -1910,13 +1910,30 @@ static int doLoad(char** argv, char * const envp[]) {
|
|||
return 2;
|
||||
}
|
||||
|
||||
int key = 1;
|
||||
int value = 123;
|
||||
unique_fd map(
|
||||
createMap(BPF_MAP_TYPE_ARRAY, sizeof(key), sizeof(value), 2, 0));
|
||||
if (writeToMapEntry(map, &key, &value, BPF_ANY)) {
|
||||
ALOGE("Critical kernel bug - failure to write into index 1 of 2 element bpf map array.");
|
||||
if (isAtLeastT) return 1;
|
||||
{
|
||||
// Create a trivial bpf map: a two element array [int->int]
|
||||
unique_fd map(createMap(BPF_MAP_TYPE_ARRAY, sizeof(int), sizeof(int), 2, 0));
|
||||
|
||||
int zero = 0;
|
||||
int kernel_bugs = bpfCmdFixupIsNeeded;
|
||||
if (writeToMapEntry(map, &zero, &kernel_bugs, BPF_ANY)) {
|
||||
ALOGE("Failure to write into index 0 of kernel bugs array.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int one = 1;
|
||||
int value = 123;
|
||||
if (writeToMapEntry(map, &one, &value, BPF_ANY)) {
|
||||
ALOGE("Critical kernel bug - failure to write into index 1 of 2 element bpf map array.");
|
||||
if (isAtLeastT) return 1;
|
||||
}
|
||||
|
||||
int ret = bpfFdPin(map, "/sys/fs/bpf/tethering/map_kernel_bugs");
|
||||
if (ret) {
|
||||
const int err = errno;
|
||||
ALOGE("pin -> %d [%d:%s]", ret, err, strerror(err));
|
||||
return -err;
|
||||
}
|
||||
}
|
||||
|
||||
// leave a flag that we're done
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ static const set<string> PLATFORM_ONLY_IN_R = {
|
|||
|
||||
// Provided by *current* mainline module for S+ devices
|
||||
static const set<string> MAINLINE_FOR_S_PLUS = {
|
||||
TETHERING "map_kernel_bugs",
|
||||
TETHERING "map_offload_tether_dev_map",
|
||||
TETHERING "map_offload_tether_downstream4_map",
|
||||
TETHERING "map_offload_tether_downstream64_map",
|
||||
|
|
|
|||
Loading…
Reference in a new issue