mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
samples/bpf: Get rid of deprecated libbpf API uses
Replace deprecated APIs with new ones. Also mute source code using deprecated AF_XDP (xsk.h). Figuring out what to do with all the AF_XDP stuff is a separate problem that should be solved with its own set of changes. Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20211201232824.3166325-9-andrii@kernel.org
This commit is contained in:
committed by
Alexei Starovoitov
parent
527024f7ae
commit
c58f9815ba
@@ -67,8 +67,8 @@ static bool test_finish;
|
|||||||
|
|
||||||
static void maps_create(void)
|
static void maps_create(void)
|
||||||
{
|
{
|
||||||
map_fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(uint32_t),
|
map_fd = bpf_map_create(BPF_MAP_TYPE_HASH, NULL, sizeof(uint32_t),
|
||||||
sizeof(struct stats), 100, 0);
|
sizeof(struct stats), 100, NULL);
|
||||||
if (map_fd < 0)
|
if (map_fd < 0)
|
||||||
error(1, errno, "map create failed!\n");
|
error(1, errno, "map create failed!\n");
|
||||||
}
|
}
|
||||||
@@ -157,9 +157,13 @@ static void prog_load(void)
|
|||||||
offsetof(struct __sk_buff, len)),
|
offsetof(struct __sk_buff, len)),
|
||||||
BPF_EXIT_INSN(),
|
BPF_EXIT_INSN(),
|
||||||
};
|
};
|
||||||
prog_fd = bpf_load_program(BPF_PROG_TYPE_SOCKET_FILTER, prog,
|
LIBBPF_OPTS(bpf_prog_load_opts, opts,
|
||||||
ARRAY_SIZE(prog), "GPL", 0,
|
.log_buf = log_buf,
|
||||||
log_buf, sizeof(log_buf));
|
.log_size = sizeof(log_buf),
|
||||||
|
);
|
||||||
|
|
||||||
|
prog_fd = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, NULL, "GPL",
|
||||||
|
prog, ARRAY_SIZE(prog), &opts);
|
||||||
if (prog_fd < 0)
|
if (prog_fd < 0)
|
||||||
error(1, errno, "failed to load prog\n%s\n", log_buf);
|
error(1, errno, "failed to load prog\n%s\n", log_buf);
|
||||||
}
|
}
|
||||||
|
@@ -54,16 +54,22 @@ static int bpf_prog_create(const char *object)
|
|||||||
};
|
};
|
||||||
size_t insns_cnt = sizeof(insns) / sizeof(struct bpf_insn);
|
size_t insns_cnt = sizeof(insns) / sizeof(struct bpf_insn);
|
||||||
struct bpf_object *obj;
|
struct bpf_object *obj;
|
||||||
int prog_fd;
|
int err;
|
||||||
|
|
||||||
if (object) {
|
if (object) {
|
||||||
assert(!bpf_prog_load(object, BPF_PROG_TYPE_UNSPEC,
|
obj = bpf_object__open_file(object, NULL);
|
||||||
&obj, &prog_fd));
|
assert(!libbpf_get_error(obj));
|
||||||
return prog_fd;
|
err = bpf_object__load(obj);
|
||||||
|
assert(!err);
|
||||||
|
return bpf_program__fd(bpf_object__next_program(obj, NULL));
|
||||||
} else {
|
} else {
|
||||||
return bpf_load_program(BPF_PROG_TYPE_SOCKET_FILTER,
|
LIBBPF_OPTS(bpf_prog_load_opts, opts,
|
||||||
insns, insns_cnt, "GPL", 0,
|
.log_buf = bpf_log_buf,
|
||||||
bpf_log_buf, BPF_LOG_BUF_SIZE);
|
.log_size = BPF_LOG_BUF_SIZE,
|
||||||
|
);
|
||||||
|
|
||||||
|
return bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, NULL, "GPL",
|
||||||
|
insns, insns_cnt, &opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,8 +79,8 @@ static int bpf_do_map(const char *file, uint32_t flags, uint32_t key,
|
|||||||
int fd, ret;
|
int fd, ret;
|
||||||
|
|
||||||
if (flags & BPF_F_PIN) {
|
if (flags & BPF_F_PIN) {
|
||||||
fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(uint32_t),
|
fd = bpf_map_create(BPF_MAP_TYPE_ARRAY, NULL, sizeof(uint32_t),
|
||||||
sizeof(uint32_t), 1024, 0);
|
sizeof(uint32_t), 1024, NULL);
|
||||||
printf("bpf: map fd:%d (%s)\n", fd, strerror(errno));
|
printf("bpf: map fd:%d (%s)\n", fd, strerror(errno));
|
||||||
assert(fd > 0);
|
assert(fd > 0);
|
||||||
|
|
||||||
|
@@ -134,19 +134,22 @@ static void do_test_lru(enum test_type test, int cpu)
|
|||||||
*/
|
*/
|
||||||
int outer_fd = map_fd[array_of_lru_hashs_idx];
|
int outer_fd = map_fd[array_of_lru_hashs_idx];
|
||||||
unsigned int mycpu, mynode;
|
unsigned int mycpu, mynode;
|
||||||
|
LIBBPF_OPTS(bpf_map_create_opts, opts,
|
||||||
|
.map_flags = BPF_F_NUMA_NODE,
|
||||||
|
);
|
||||||
|
|
||||||
assert(cpu < MAX_NR_CPUS);
|
assert(cpu < MAX_NR_CPUS);
|
||||||
|
|
||||||
ret = syscall(__NR_getcpu, &mycpu, &mynode, NULL);
|
ret = syscall(__NR_getcpu, &mycpu, &mynode, NULL);
|
||||||
assert(!ret);
|
assert(!ret);
|
||||||
|
|
||||||
|
opts.numa_node = mynode;
|
||||||
inner_lru_map_fds[cpu] =
|
inner_lru_map_fds[cpu] =
|
||||||
bpf_create_map_node(BPF_MAP_TYPE_LRU_HASH,
|
bpf_map_create(BPF_MAP_TYPE_LRU_HASH,
|
||||||
test_map_names[INNER_LRU_HASH_PREALLOC],
|
test_map_names[INNER_LRU_HASH_PREALLOC],
|
||||||
sizeof(uint32_t),
|
sizeof(uint32_t),
|
||||||
sizeof(long),
|
sizeof(long),
|
||||||
inner_lru_hash_size, 0,
|
inner_lru_hash_size, &opts);
|
||||||
mynode);
|
|
||||||
if (inner_lru_map_fds[cpu] == -1) {
|
if (inner_lru_map_fds[cpu] == -1) {
|
||||||
printf("cannot create BPF_MAP_TYPE_LRU_HASH %s(%d)\n",
|
printf("cannot create BPF_MAP_TYPE_LRU_HASH %s(%d)\n",
|
||||||
strerror(errno), errno);
|
strerror(errno), errno);
|
||||||
|
@@ -37,8 +37,8 @@ static int test_sock(void)
|
|||||||
int sock = -1, map_fd, prog_fd, i, key;
|
int sock = -1, map_fd, prog_fd, i, key;
|
||||||
long long value = 0, tcp_cnt, udp_cnt, icmp_cnt;
|
long long value = 0, tcp_cnt, udp_cnt, icmp_cnt;
|
||||||
|
|
||||||
map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(key), sizeof(value),
|
map_fd = bpf_map_create(BPF_MAP_TYPE_ARRAY, NULL, sizeof(key), sizeof(value),
|
||||||
256, 0);
|
256, NULL);
|
||||||
if (map_fd < 0) {
|
if (map_fd < 0) {
|
||||||
printf("failed to create map '%s'\n", strerror(errno));
|
printf("failed to create map '%s'\n", strerror(errno));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@@ -59,9 +59,13 @@ static int test_sock(void)
|
|||||||
BPF_EXIT_INSN(),
|
BPF_EXIT_INSN(),
|
||||||
};
|
};
|
||||||
size_t insns_cnt = sizeof(prog) / sizeof(struct bpf_insn);
|
size_t insns_cnt = sizeof(prog) / sizeof(struct bpf_insn);
|
||||||
|
LIBBPF_OPTS(bpf_prog_load_opts, opts,
|
||||||
|
.log_buf = bpf_log_buf,
|
||||||
|
.log_size = BPF_LOG_BUF_SIZE,
|
||||||
|
);
|
||||||
|
|
||||||
prog_fd = bpf_load_program(BPF_PROG_TYPE_SOCKET_FILTER, prog, insns_cnt,
|
prog_fd = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, NULL, "GPL",
|
||||||
"GPL", 0, bpf_log_buf, BPF_LOG_BUF_SIZE);
|
prog, insns_cnt, &opts);
|
||||||
if (prog_fd < 0) {
|
if (prog_fd < 0) {
|
||||||
printf("failed to load prog '%s'\n", strerror(errno));
|
printf("failed to load prog '%s'\n", strerror(errno));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
@@ -11,17 +11,26 @@
|
|||||||
int main(int ac, char **argv)
|
int main(int ac, char **argv)
|
||||||
{
|
{
|
||||||
struct bpf_object *obj;
|
struct bpf_object *obj;
|
||||||
|
struct bpf_program *prog;
|
||||||
int map_fd, prog_fd;
|
int map_fd, prog_fd;
|
||||||
char filename[256];
|
char filename[256];
|
||||||
int i, sock;
|
int i, sock, err;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
|
snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
|
||||||
|
|
||||||
if (bpf_prog_load(filename, BPF_PROG_TYPE_SOCKET_FILTER,
|
obj = bpf_object__open_file(filename, NULL);
|
||||||
&obj, &prog_fd))
|
if (libbpf_get_error(obj))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
prog = bpf_object__next_program(obj, NULL);
|
||||||
|
bpf_program__set_type(prog, BPF_PROG_TYPE_SOCKET_FILTER);
|
||||||
|
|
||||||
|
err = bpf_object__load(obj);
|
||||||
|
if (err)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
prog_fd = bpf_program__fd(prog);
|
||||||
map_fd = bpf_object__find_map_fd_by_name(obj, "my_map");
|
map_fd = bpf_object__find_map_fd_by_name(obj, "my_map");
|
||||||
|
|
||||||
sock = open_raw_sock("lo");
|
sock = open_raw_sock("lo");
|
||||||
|
@@ -16,18 +16,26 @@ struct pair {
|
|||||||
|
|
||||||
int main(int ac, char **argv)
|
int main(int ac, char **argv)
|
||||||
{
|
{
|
||||||
|
struct bpf_program *prog;
|
||||||
struct bpf_object *obj;
|
struct bpf_object *obj;
|
||||||
int map_fd, prog_fd;
|
int map_fd, prog_fd;
|
||||||
char filename[256];
|
char filename[256];
|
||||||
int i, sock;
|
int i, sock, err;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
|
snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
|
||||||
|
obj = bpf_object__open_file(filename, NULL);
|
||||||
if (bpf_prog_load(filename, BPF_PROG_TYPE_SOCKET_FILTER,
|
if (libbpf_get_error(obj))
|
||||||
&obj, &prog_fd))
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
prog = bpf_object__next_program(obj, NULL);
|
||||||
|
bpf_program__set_type(prog, BPF_PROG_TYPE_SOCKET_FILTER);
|
||||||
|
|
||||||
|
err = bpf_object__load(obj);
|
||||||
|
if (err)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
prog_fd = bpf_program__fd(prog);
|
||||||
map_fd = bpf_object__find_map_fd_by_name(obj, "hash_map");
|
map_fd = bpf_object__find_map_fd_by_name(obj, "hash_map");
|
||||||
|
|
||||||
sock = open_raw_sock("lo");
|
sock = open_raw_sock("lo");
|
||||||
|
@@ -64,9 +64,9 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (create_array) {
|
if (create_array) {
|
||||||
array_fd = bpf_create_map(BPF_MAP_TYPE_CGROUP_ARRAY,
|
array_fd = bpf_map_create(BPF_MAP_TYPE_CGROUP_ARRAY, NULL,
|
||||||
sizeof(uint32_t), sizeof(uint32_t),
|
sizeof(uint32_t), sizeof(uint32_t),
|
||||||
1, 0);
|
1, NULL);
|
||||||
if (array_fd < 0) {
|
if (array_fd < 0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"bpf_create_map(BPF_MAP_TYPE_CGROUP_ARRAY,...): %s(%d)\n",
|
"bpf_create_map(BPF_MAP_TYPE_CGROUP_ARRAY,...): %s(%d)\n",
|
||||||
|
@@ -71,10 +71,13 @@ static int prog_load(int map_fd, int verdict)
|
|||||||
BPF_EXIT_INSN(),
|
BPF_EXIT_INSN(),
|
||||||
};
|
};
|
||||||
size_t insns_cnt = sizeof(prog) / sizeof(struct bpf_insn);
|
size_t insns_cnt = sizeof(prog) / sizeof(struct bpf_insn);
|
||||||
|
LIBBPF_OPTS(bpf_prog_load_opts, opts,
|
||||||
|
.log_buf = bpf_log_buf,
|
||||||
|
.log_size = BPF_LOG_BUF_SIZE,
|
||||||
|
);
|
||||||
|
|
||||||
return bpf_load_program(BPF_PROG_TYPE_CGROUP_SKB,
|
return bpf_prog_load(BPF_PROG_TYPE_CGROUP_SKB, NULL, "GPL",
|
||||||
prog, insns_cnt, "GPL", 0,
|
prog, insns_cnt, &opts);
|
||||||
bpf_log_buf, BPF_LOG_BUF_SIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int usage(const char *argv0)
|
static int usage(const char *argv0)
|
||||||
@@ -90,9 +93,9 @@ static int attach_filter(int cg_fd, int type, int verdict)
|
|||||||
int prog_fd, map_fd, ret, key;
|
int prog_fd, map_fd, ret, key;
|
||||||
long long pkt_cnt, byte_cnt;
|
long long pkt_cnt, byte_cnt;
|
||||||
|
|
||||||
map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY,
|
map_fd = bpf_map_create(BPF_MAP_TYPE_ARRAY, NULL,
|
||||||
sizeof(key), sizeof(byte_cnt),
|
sizeof(key), sizeof(byte_cnt),
|
||||||
256, 0);
|
256, NULL);
|
||||||
if (map_fd < 0) {
|
if (map_fd < 0) {
|
||||||
printf("Failed to create map: '%s'\n", strerror(errno));
|
printf("Failed to create map: '%s'\n", strerror(errno));
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
@@ -70,6 +70,10 @@ static int prog_load(__u32 idx, __u32 mark, __u32 prio)
|
|||||||
BPF_MOV64_IMM(BPF_REG_2, offsetof(struct bpf_sock, priority)),
|
BPF_MOV64_IMM(BPF_REG_2, offsetof(struct bpf_sock, priority)),
|
||||||
BPF_STX_MEM(BPF_W, BPF_REG_1, BPF_REG_3, offsetof(struct bpf_sock, priority)),
|
BPF_STX_MEM(BPF_W, BPF_REG_1, BPF_REG_3, offsetof(struct bpf_sock, priority)),
|
||||||
};
|
};
|
||||||
|
LIBBPF_OPTS(bpf_prog_load_opts, opts,
|
||||||
|
.log_buf = bpf_log_buf,
|
||||||
|
.log_size = BPF_LOG_BUF_SIZE,
|
||||||
|
);
|
||||||
|
|
||||||
struct bpf_insn *prog;
|
struct bpf_insn *prog;
|
||||||
size_t insns_cnt;
|
size_t insns_cnt;
|
||||||
@@ -115,8 +119,8 @@ static int prog_load(__u32 idx, __u32 mark, __u32 prio)
|
|||||||
|
|
||||||
insns_cnt /= sizeof(struct bpf_insn);
|
insns_cnt /= sizeof(struct bpf_insn);
|
||||||
|
|
||||||
ret = bpf_load_program(BPF_PROG_TYPE_CGROUP_SOCK, prog, insns_cnt,
|
ret = bpf_prog_load(BPF_PROG_TYPE_CGROUP_SOCK, NULL, "GPL",
|
||||||
"GPL", 0, bpf_log_buf, BPF_LOG_BUF_SIZE);
|
prog, insns_cnt, &opts);
|
||||||
|
|
||||||
free(prog);
|
free(prog);
|
||||||
|
|
||||||
|
@@ -105,10 +105,10 @@ struct pfect_lru {
|
|||||||
static void pfect_lru_init(struct pfect_lru *lru, unsigned int lru_size,
|
static void pfect_lru_init(struct pfect_lru *lru, unsigned int lru_size,
|
||||||
unsigned int nr_possible_elems)
|
unsigned int nr_possible_elems)
|
||||||
{
|
{
|
||||||
lru->map_fd = bpf_create_map(BPF_MAP_TYPE_HASH,
|
lru->map_fd = bpf_map_create(BPF_MAP_TYPE_HASH, NULL,
|
||||||
sizeof(unsigned long long),
|
sizeof(unsigned long long),
|
||||||
sizeof(struct pfect_lru_node *),
|
sizeof(struct pfect_lru_node *),
|
||||||
nr_possible_elems, 0);
|
nr_possible_elems, NULL);
|
||||||
assert(lru->map_fd != -1);
|
assert(lru->map_fd != -1);
|
||||||
|
|
||||||
lru->free_nodes = malloc(lru_size * sizeof(struct pfect_lru_node));
|
lru->free_nodes = malloc(lru_size * sizeof(struct pfect_lru_node));
|
||||||
@@ -207,10 +207,13 @@ static unsigned int read_keys(const char *dist_file,
|
|||||||
|
|
||||||
static int create_map(int map_type, int map_flags, unsigned int size)
|
static int create_map(int map_type, int map_flags, unsigned int size)
|
||||||
{
|
{
|
||||||
|
LIBBPF_OPTS(bpf_map_create_opts, opts,
|
||||||
|
.map_flags = map_flags,
|
||||||
|
);
|
||||||
int map_fd;
|
int map_fd;
|
||||||
|
|
||||||
map_fd = bpf_create_map(map_type, sizeof(unsigned long long),
|
map_fd = bpf_map_create(map_type, NULL, sizeof(unsigned long long),
|
||||||
sizeof(unsigned long long), size, map_flags);
|
sizeof(unsigned long long), size, &opts);
|
||||||
|
|
||||||
if (map_fd == -1)
|
if (map_fd == -1)
|
||||||
perror("bpf_create_map");
|
perror("bpf_create_map");
|
||||||
|
@@ -43,7 +43,6 @@ static void print_bpf_output(void *ctx, int cpu, void *data, __u32 size)
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct perf_buffer_opts pb_opts = {};
|
|
||||||
struct bpf_link *link = NULL;
|
struct bpf_link *link = NULL;
|
||||||
struct bpf_program *prog;
|
struct bpf_program *prog;
|
||||||
struct perf_buffer *pb;
|
struct perf_buffer *pb;
|
||||||
@@ -84,8 +83,7 @@ int main(int argc, char **argv)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
pb_opts.sample_cb = print_bpf_output;
|
pb = perf_buffer__new(map_fd, 8, print_bpf_output, NULL, NULL, NULL);
|
||||||
pb = perf_buffer__new(map_fd, 8, &pb_opts);
|
|
||||||
ret = libbpf_get_error(pb);
|
ret = libbpf_get_error(pb);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("failed to setup perf_buffer: %d\n", ret);
|
printf("failed to setup perf_buffer: %d\n", ret);
|
||||||
|
@@ -110,12 +110,9 @@ static void usage(const char *prog)
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
struct bpf_prog_load_attr prog_load_attr = {
|
|
||||||
.prog_type = BPF_PROG_TYPE_XDP,
|
|
||||||
};
|
|
||||||
struct perf_buffer_opts pb_opts = {};
|
|
||||||
const char *optstr = "FS";
|
const char *optstr = "FS";
|
||||||
int prog_fd, map_fd, opt;
|
int prog_fd, map_fd, opt;
|
||||||
|
struct bpf_program *prog;
|
||||||
struct bpf_object *obj;
|
struct bpf_object *obj;
|
||||||
struct bpf_map *map;
|
struct bpf_map *map;
|
||||||
char filename[256];
|
char filename[256];
|
||||||
@@ -144,15 +141,19 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
|
snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
|
||||||
prog_load_attr.file = filename;
|
|
||||||
|
|
||||||
if (bpf_prog_load_xattr(&prog_load_attr, &obj, &prog_fd))
|
obj = bpf_object__open_file(filename, NULL);
|
||||||
|
if (libbpf_get_error(obj))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (!prog_fd) {
|
prog = bpf_object__next_program(obj, NULL);
|
||||||
printf("bpf_prog_load_xattr: %s\n", strerror(errno));
|
bpf_program__set_type(prog, BPF_PROG_TYPE_XDP);
|
||||||
|
|
||||||
|
err = bpf_object__load(obj);
|
||||||
|
if (err)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
|
prog_fd = bpf_program__fd(prog);
|
||||||
|
|
||||||
map = bpf_object__next_map(obj, NULL);
|
map = bpf_object__next_map(obj, NULL);
|
||||||
if (!map) {
|
if (!map) {
|
||||||
@@ -181,8 +182,7 @@ int main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pb_opts.sample_cb = print_bpf_output;
|
pb = perf_buffer__new(map_fd, 8, print_bpf_output, NULL, NULL, NULL);
|
||||||
pb = perf_buffer__new(map_fd, 8, &pb_opts);
|
|
||||||
err = libbpf_get_error(pb);
|
err = libbpf_get_error(pb);
|
||||||
if (err) {
|
if (err) {
|
||||||
perror("perf_buffer setup failed");
|
perror("perf_buffer setup failed");
|
||||||
|
@@ -15,6 +15,9 @@
|
|||||||
#include <bpf/xsk.h>
|
#include <bpf/xsk.h>
|
||||||
#include "xdpsock.h"
|
#include "xdpsock.h"
|
||||||
|
|
||||||
|
/* libbpf APIs for AF_XDP are deprecated starting from v0.7 */
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
|
||||||
static const char *opt_if = "";
|
static const char *opt_if = "";
|
||||||
|
|
||||||
static struct option long_options[] = {
|
static struct option long_options[] = {
|
||||||
|
@@ -36,6 +36,9 @@
|
|||||||
#include <bpf/bpf.h>
|
#include <bpf/bpf.h>
|
||||||
#include "xdpsock.h"
|
#include "xdpsock.h"
|
||||||
|
|
||||||
|
/* libbpf APIs for AF_XDP are deprecated starting from v0.7 */
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
|
||||||
#ifndef SOL_XDP
|
#ifndef SOL_XDP
|
||||||
#define SOL_XDP 283
|
#define SOL_XDP 283
|
||||||
#endif
|
#endif
|
||||||
|
@@ -27,6 +27,9 @@
|
|||||||
#include <bpf/xsk.h>
|
#include <bpf/xsk.h>
|
||||||
#include <bpf/bpf.h>
|
#include <bpf/bpf.h>
|
||||||
|
|
||||||
|
/* libbpf APIs for AF_XDP are deprecated starting from v0.7 */
|
||||||
|
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
|
||||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||||
|
|
||||||
typedef __u64 u64;
|
typedef __u64 u64;
|
||||||
|
Reference in New Issue
Block a user