bpf.h (1bdd3e05a0a3b4a97ea88bc46fef8fb265c8b94c) bpf.h (2ab3d86ea1859d1a4b830ce3551cba725620593a)
1/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
2
3/*
4 * common eBPF ELF operations.
5 *
6 * Copyright (C) 2013-2015 Alexei Starovoitov <ast@kernel.org>
7 * Copyright (C) 2015 Wang Nan <wangnan0@huawei.com>
8 * Copyright (C) 2015 Huawei Inc.

--- 14 unchanged lines hidden (view full) ---

23#ifndef __LIBBPF_BPF_H
24#define __LIBBPF_BPF_H
25
26#include <linux/bpf.h>
27#include <stdbool.h>
28#include <stddef.h>
29#include <stdint.h>
30
1/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
2
3/*
4 * common eBPF ELF operations.
5 *
6 * Copyright (C) 2013-2015 Alexei Starovoitov <ast@kernel.org>
7 * Copyright (C) 2015 Wang Nan <wangnan0@huawei.com>
8 * Copyright (C) 2015 Huawei Inc.

--- 14 unchanged lines hidden (view full) ---

23#ifndef __LIBBPF_BPF_H
24#define __LIBBPF_BPF_H
25
26#include <linux/bpf.h>
27#include <stdbool.h>
28#include <stddef.h>
29#include <stdint.h>
30
31#include "libbpf_common.h"
32
31#ifdef __cplusplus
32extern "C" {
33#endif
34
33#ifdef __cplusplus
34extern "C" {
35#endif
36
35#ifndef LIBBPF_API
36#define LIBBPF_API __attribute__((visibility("default")))
37#endif
38
39struct bpf_create_map_attr {
40 const char *name;
41 enum bpf_map_type map_type;
42 __u32 map_flags;
43 __u32 key_size;
44 __u32 value_size;
45 __u32 max_entries;
46 __u32 numa_node;
47 __u32 btf_fd;
48 __u32 btf_key_type_id;
49 __u32 btf_value_type_id;
50 __u32 map_ifindex;
37struct bpf_create_map_attr {
38 const char *name;
39 enum bpf_map_type map_type;
40 __u32 map_flags;
41 __u32 key_size;
42 __u32 value_size;
43 __u32 max_entries;
44 __u32 numa_node;
45 __u32 btf_fd;
46 __u32 btf_key_type_id;
47 __u32 btf_value_type_id;
48 __u32 map_ifindex;
51 __u32 inner_map_fd;
49 union {
50 __u32 inner_map_fd;
51 __u32 btf_vmlinux_value_type_id;
52 };
52};
53
54LIBBPF_API int
55bpf_create_map_xattr(const struct bpf_create_map_attr *create_attr);
56LIBBPF_API int bpf_create_map_node(enum bpf_map_type map_type, const char *name,
57 int key_size, int value_size,
58 int max_entries, __u32 map_flags, int node);
59LIBBPF_API int bpf_create_map_name(enum bpf_map_type map_type, const char *name,

--- 61 unchanged lines hidden (view full) ---

121LIBBPF_API int bpf_map_lookup_elem(int fd, const void *key, void *value);
122LIBBPF_API int bpf_map_lookup_elem_flags(int fd, const void *key, void *value,
123 __u64 flags);
124LIBBPF_API int bpf_map_lookup_and_delete_elem(int fd, const void *key,
125 void *value);
126LIBBPF_API int bpf_map_delete_elem(int fd, const void *key);
127LIBBPF_API int bpf_map_get_next_key(int fd, const void *key, void *next_key);
128LIBBPF_API int bpf_map_freeze(int fd);
53};
54
55LIBBPF_API int
56bpf_create_map_xattr(const struct bpf_create_map_attr *create_attr);
57LIBBPF_API int bpf_create_map_node(enum bpf_map_type map_type, const char *name,
58 int key_size, int value_size,
59 int max_entries, __u32 map_flags, int node);
60LIBBPF_API int bpf_create_map_name(enum bpf_map_type map_type, const char *name,

--- 61 unchanged lines hidden (view full) ---

122LIBBPF_API int bpf_map_lookup_elem(int fd, const void *key, void *value);
123LIBBPF_API int bpf_map_lookup_elem_flags(int fd, const void *key, void *value,
124 __u64 flags);
125LIBBPF_API int bpf_map_lookup_and_delete_elem(int fd, const void *key,
126 void *value);
127LIBBPF_API int bpf_map_delete_elem(int fd, const void *key);
128LIBBPF_API int bpf_map_get_next_key(int fd, const void *key, void *next_key);
129LIBBPF_API int bpf_map_freeze(int fd);
130
131struct bpf_map_batch_opts {
132 size_t sz; /* size of this struct for forward/backward compatibility */
133 __u64 elem_flags;
134 __u64 flags;
135};
136#define bpf_map_batch_opts__last_field flags
137
138LIBBPF_API int bpf_map_delete_batch(int fd, void *keys,
139 __u32 *count,
140 const struct bpf_map_batch_opts *opts);
141LIBBPF_API int bpf_map_lookup_batch(int fd, void *in_batch, void *out_batch,
142 void *keys, void *values, __u32 *count,
143 const struct bpf_map_batch_opts *opts);
144LIBBPF_API int bpf_map_lookup_and_delete_batch(int fd, void *in_batch,
145 void *out_batch, void *keys,
146 void *values, __u32 *count,
147 const struct bpf_map_batch_opts *opts);
148LIBBPF_API int bpf_map_update_batch(int fd, void *keys, void *values,
149 __u32 *count,
150 const struct bpf_map_batch_opts *opts);
151
129LIBBPF_API int bpf_obj_pin(int fd, const char *pathname);
130LIBBPF_API int bpf_obj_get(const char *pathname);
152LIBBPF_API int bpf_obj_pin(int fd, const char *pathname);
153LIBBPF_API int bpf_obj_get(const char *pathname);
154
155struct bpf_prog_attach_opts {
156 size_t sz; /* size of this struct for forward/backward compatibility */
157 unsigned int flags;
158 int replace_prog_fd;
159};
160#define bpf_prog_attach_opts__last_field replace_prog_fd
161
131LIBBPF_API int bpf_prog_attach(int prog_fd, int attachable_fd,
132 enum bpf_attach_type type, unsigned int flags);
162LIBBPF_API int bpf_prog_attach(int prog_fd, int attachable_fd,
163 enum bpf_attach_type type, unsigned int flags);
164LIBBPF_API int bpf_prog_attach_xattr(int prog_fd, int attachable_fd,
165 enum bpf_attach_type type,
166 const struct bpf_prog_attach_opts *opts);
133LIBBPF_API int bpf_prog_detach(int attachable_fd, enum bpf_attach_type type);
134LIBBPF_API int bpf_prog_detach2(int prog_fd, int attachable_fd,
135 enum bpf_attach_type type);
136
137struct bpf_prog_test_run_attr {
138 int prog_fd;
139 int repeat;
140 const void *data_in;

--- 44 unchanged lines hidden ---
167LIBBPF_API int bpf_prog_detach(int attachable_fd, enum bpf_attach_type type);
168LIBBPF_API int bpf_prog_detach2(int prog_fd, int attachable_fd,
169 enum bpf_attach_type type);
170
171struct bpf_prog_test_run_attr {
172 int prog_fd;
173 int repeat;
174 const void *data_in;

--- 44 unchanged lines hidden ---