]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/basic/bpf-program.h
basic/bpf-program: drop obsolete comment
[thirdparty/systemd.git] / src / basic / bpf-program.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
71e5200f
DM
2#pragma once
3
71e5200f
DM
4#include <linux/bpf.h>
5#include <stdint.h>
6#include <sys/syscall.h>
7
8#include "list.h"
9#include "macro.h"
10
11typedef struct BPFProgram BPFProgram;
12
13struct BPFProgram {
aa2b6f1d
LP
14 unsigned n_ref;
15
71e5200f
DM
16 int kernel_fd;
17 uint32_t prog_type;
18
19 size_t n_instructions;
20 size_t allocated;
21 struct bpf_insn *instructions;
aa2b6f1d
LP
22
23 char *attached_path;
24 int attached_type;
25 uint32_t attached_flags;
71e5200f
DM
26};
27
28int bpf_program_new(uint32_t prog_type, BPFProgram **ret);
29BPFProgram *bpf_program_unref(BPFProgram *p);
aa2b6f1d 30BPFProgram *bpf_program_ref(BPFProgram *p);
71e5200f
DM
31
32int bpf_program_add_instructions(BPFProgram *p, const struct bpf_insn *insn, size_t count);
33int bpf_program_load_kernel(BPFProgram *p, char *log_buf, size_t log_size);
34
9f2e6892 35int bpf_program_cgroup_attach(BPFProgram *p, int type, const char *path, uint32_t flags);
aa2b6f1d 36int bpf_program_cgroup_detach(BPFProgram *p);
71e5200f
DM
37
38int bpf_map_new(enum bpf_map_type type, size_t key_size, size_t value_size, size_t max_entries, uint32_t flags);
39int bpf_map_update_element(int fd, const void *key, void *value);
40int bpf_map_lookup_element(int fd, const void *key, void *value);
41
42DEFINE_TRIVIAL_CLEANUP_FUNC(BPFProgram*, bpf_program_unref);