blob: b233dc9bfffba0a047db3974baab2e2fe23b2ecf [file] [log] [blame]
Maciej Żenczykowski730a3862020-01-27 01:10:48 -08001/*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19/* This file is separate because it's included both by eBPF programs (via include
20 * in bpf_helpers.h) and directly by the boot time bpfloader (Loader.cpp).
21 */
22
23#include <linux/bpf.h>
24
Maciej Żenczykowski6f878962020-01-27 02:58:29 -080025// These AID_* constants are permanent constants pulled from:
26// system/core/libcutils/include/private/android_filesystem_config.h
27//
28// We need access to them from ebpf C code for map definitions
29// and thus don't want to pull in the entire header file.
30//
31// TODO(149434314) - switch to including some appropriate header portion
32#define AID_ROOT 0
33#define AID_SYSTEM 1000
34#define AID_NETWORK_STACK 1073
35#define AID_NET_BT_ADMIN 3001
36#define AID_NET_BT 3002
37#define AID_INET 3003
38#define AID_NET_RAW 3004
39#define AID_NET_ADMIN 3005
40#define AID_NET_BW_STATS 3006
41#define AID_NET_BW_ACCT 3007
42
Maciej Żenczykowski730a3862020-01-27 01:10:48 -080043/*
44 * Map structure to be used by Android eBPF C programs. The Android eBPF loader
45 * uses this structure from eBPF object to create maps at boot time.
46 *
47 * The eBPF C program should define structure in the maps section using
48 * SEC("maps") otherwise it will be ignored by the eBPF loader.
49 *
50 * For example:
51 * const struct bpf_map_def SEC("maps") mymap { .type=... , .key_size=... }
52 *
53 * See 'bpf_helpers.h' for helpful macros for eBPF program use.
54 */
55struct bpf_map_def {
56 enum bpf_map_type type;
57 unsigned int key_size;
58 unsigned int value_size;
59 unsigned int max_entries;
60 unsigned int map_flags;
61
62 // The following are not supported by the Android bpfloader:
63 // unsigned int inner_map_idx;
64 // unsigned int numa_node;
Maciej Żenczykowski83f29772020-01-27 03:11:51 -080065
66 unsigned int uid; // uid_t
67 unsigned int gid; // gid_t
68 unsigned int mode; // mode_t
Maciej Żenczykowski730a3862020-01-27 01:10:48 -080069};