]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
71e5200f DM |
2 | #pragma once |
3 | ||
4 | /*** | |
5 | This file is part of systemd. | |
6 | ||
7 | Copyright 2016 Daniel Mack | |
8 | ||
9 | systemd is free software; you can redistribute it and/or modify it | |
10 | under the terms of the GNU Lesser General Public License as published by | |
11 | the Free Software Foundation; either version 2.1 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | systemd is distributed in the hope that it will be useful, but | |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | Lesser General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU Lesser General Public License | |
20 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
21 | ||
22 | [Except for the stuff copy/pasted from the kernel sources, see below] | |
23 | ***/ | |
24 | ||
25 | #include <linux/bpf.h> | |
26 | #include <stdint.h> | |
27 | #include <sys/syscall.h> | |
28 | ||
29 | #include "list.h" | |
30 | #include "macro.h" | |
31 | ||
32 | typedef struct BPFProgram BPFProgram; | |
33 | ||
34 | struct BPFProgram { | |
35 | int kernel_fd; | |
36 | uint32_t prog_type; | |
37 | ||
38 | size_t n_instructions; | |
39 | size_t allocated; | |
40 | struct bpf_insn *instructions; | |
41 | }; | |
42 | ||
43 | int bpf_program_new(uint32_t prog_type, BPFProgram **ret); | |
44 | BPFProgram *bpf_program_unref(BPFProgram *p); | |
45 | ||
46 | int bpf_program_add_instructions(BPFProgram *p, const struct bpf_insn *insn, size_t count); | |
47 | int bpf_program_load_kernel(BPFProgram *p, char *log_buf, size_t log_size); | |
48 | ||
9f2e6892 | 49 | int bpf_program_cgroup_attach(BPFProgram *p, int type, const char *path, uint32_t flags); |
71e5200f DM |
50 | int bpf_program_cgroup_detach(int type, const char *path); |
51 | ||
52 | int bpf_map_new(enum bpf_map_type type, size_t key_size, size_t value_size, size_t max_entries, uint32_t flags); | |
53 | int bpf_map_update_element(int fd, const void *key, void *value); | |
54 | int bpf_map_lookup_element(int fd, const void *key, void *value); | |
55 | ||
56 | DEFINE_TRIVIAL_CLEANUP_FUNC(BPFProgram*, bpf_program_unref); |