Merge branch 'Deprecate bpf_prog_load_xattr() API'
Andrii Nakryiko says: ==================== Few lines in the last patch to mark bpf_prog_load_xattr() deprecated required a decent amount of clean ups in all the other patches. samples/bpf is big part of the clean up. This patch set also bumps libbpf version to 0.7, as libbpf v0.6 release will be cut shortly. ==================== Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
commit
080a70b21f
@ -328,7 +328,7 @@ $(BPF_SAMPLES_PATH)/*.c: verify_target_bpf $(LIBBPF)
|
||||
$(src)/*.c: verify_target_bpf $(LIBBPF)
|
||||
|
||||
libbpf_hdrs: $(LIBBPF)
|
||||
$(obj)/$(TRACE_HELPERS): | libbpf_hdrs
|
||||
$(obj)/$(TRACE_HELPERS) $(obj)/$(CGROUP_HELPERS) $(obj)/$(XDP_SAMPLE): | libbpf_hdrs
|
||||
|
||||
.PHONY: libbpf_hdrs
|
||||
|
||||
@ -343,6 +343,17 @@ $(obj)/hbm_out_kern.o: $(src)/hbm.h $(src)/hbm_kern.h
|
||||
$(obj)/hbm.o: $(src)/hbm.h
|
||||
$(obj)/hbm_edt_kern.o: $(src)/hbm.h $(src)/hbm_kern.h
|
||||
|
||||
# Override includes for xdp_sample_user.o because $(srctree)/usr/include in
|
||||
# TPROGS_CFLAGS causes conflicts
|
||||
XDP_SAMPLE_CFLAGS += -Wall -O2 -lm \
|
||||
-I$(src)/../../tools/include \
|
||||
-I$(src)/../../tools/include/uapi \
|
||||
-I$(LIBBPF_INCLUDE) \
|
||||
-I$(src)/../../tools/testing/selftests/bpf
|
||||
|
||||
$(obj)/$(XDP_SAMPLE): TPROGS_CFLAGS = $(XDP_SAMPLE_CFLAGS)
|
||||
$(obj)/$(XDP_SAMPLE): $(src)/xdp_sample_user.h $(src)/xdp_sample_shared.h
|
||||
|
||||
-include $(BPF_SAMPLES_PATH)/Makefile.target
|
||||
|
||||
VMLINUX_BTF_PATHS ?= $(abspath $(if $(O),$(O)/vmlinux)) \
|
||||
|
@ -73,14 +73,3 @@ quiet_cmd_tprog-cobjs = CC $@
|
||||
cmd_tprog-cobjs = $(CC) $(tprogc_flags) -c -o $@ $<
|
||||
$(tprog-cobjs): $(obj)/%.o: $(src)/%.c FORCE
|
||||
$(call if_changed_dep,tprog-cobjs)
|
||||
|
||||
# Override includes for xdp_sample_user.o because $(srctree)/usr/include in
|
||||
# TPROGS_CFLAGS causes conflicts
|
||||
XDP_SAMPLE_CFLAGS += -Wall -O2 -lm \
|
||||
-I./tools/include \
|
||||
-I./tools/include/uapi \
|
||||
-I./tools/lib \
|
||||
-I./tools/testing/selftests/bpf
|
||||
$(obj)/xdp_sample_user.o: $(src)/xdp_sample_user.c \
|
||||
$(src)/xdp_sample_user.h $(src)/xdp_sample_shared.h
|
||||
$(CC) $(XDP_SAMPLE_CFLAGS) -c -o $@ $<
|
||||
|
@ -67,8 +67,8 @@ static bool test_finish;
|
||||
|
||||
static void maps_create(void)
|
||||
{
|
||||
map_fd = bpf_create_map(BPF_MAP_TYPE_HASH, sizeof(uint32_t),
|
||||
sizeof(struct stats), 100, 0);
|
||||
map_fd = bpf_map_create(BPF_MAP_TYPE_HASH, NULL, sizeof(uint32_t),
|
||||
sizeof(struct stats), 100, NULL);
|
||||
if (map_fd < 0)
|
||||
error(1, errno, "map create failed!\n");
|
||||
}
|
||||
@ -157,9 +157,13 @@ static void prog_load(void)
|
||||
offsetof(struct __sk_buff, len)),
|
||||
BPF_EXIT_INSN(),
|
||||
};
|
||||
prog_fd = bpf_load_program(BPF_PROG_TYPE_SOCKET_FILTER, prog,
|
||||
ARRAY_SIZE(prog), "GPL", 0,
|
||||
log_buf, sizeof(log_buf));
|
||||
LIBBPF_OPTS(bpf_prog_load_opts, opts,
|
||||
.log_buf = 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)
|
||||
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);
|
||||
struct bpf_object *obj;
|
||||
int prog_fd;
|
||||
int err;
|
||||
|
||||
if (object) {
|
||||
assert(!bpf_prog_load(object, BPF_PROG_TYPE_UNSPEC,
|
||||
&obj, &prog_fd));
|
||||
return prog_fd;
|
||||
obj = bpf_object__open_file(object, NULL);
|
||||
assert(!libbpf_get_error(obj));
|
||||
err = bpf_object__load(obj);
|
||||
assert(!err);
|
||||
return bpf_program__fd(bpf_object__next_program(obj, NULL));
|
||||
} else {
|
||||
return bpf_load_program(BPF_PROG_TYPE_SOCKET_FILTER,
|
||||
insns, insns_cnt, "GPL", 0,
|
||||
bpf_log_buf, BPF_LOG_BUF_SIZE);
|
||||
LIBBPF_OPTS(bpf_prog_load_opts, opts,
|
||||
.log_buf = bpf_log_buf,
|
||||
.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;
|
||||
|
||||
if (flags & BPF_F_PIN) {
|
||||
fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(uint32_t),
|
||||
sizeof(uint32_t), 1024, 0);
|
||||
fd = bpf_map_create(BPF_MAP_TYPE_ARRAY, NULL, sizeof(uint32_t),
|
||||
sizeof(uint32_t), 1024, NULL);
|
||||
printf("bpf: map fd:%d (%s)\n", fd, strerror(errno));
|
||||
assert(fd > 0);
|
||||
|
||||
|
@ -9,8 +9,6 @@
|
||||
* Include file for sample Host Bandwidth Manager (HBM) BPF programs
|
||||
*/
|
||||
#define KBUILD_MODNAME "foo"
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <uapi/linux/bpf.h>
|
||||
#include <uapi/linux/if_ether.h>
|
||||
#include <uapi/linux/if_packet.h>
|
||||
|
@ -16,13 +16,6 @@
|
||||
#include <uapi/linux/in.h>
|
||||
#include <bpf/bpf_helpers.h>
|
||||
|
||||
# define printk(fmt, ...) \
|
||||
({ \
|
||||
char ____fmt[] = fmt; \
|
||||
bpf_trace_printk(____fmt, sizeof(____fmt), \
|
||||
##__VA_ARGS__); \
|
||||
})
|
||||
|
||||
struct bpf_elf_map {
|
||||
__u32 type;
|
||||
__u32 size_key;
|
||||
|
@ -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];
|
||||
unsigned int mycpu, mynode;
|
||||
LIBBPF_OPTS(bpf_map_create_opts, opts,
|
||||
.map_flags = BPF_F_NUMA_NODE,
|
||||
);
|
||||
|
||||
assert(cpu < MAX_NR_CPUS);
|
||||
|
||||
ret = syscall(__NR_getcpu, &mycpu, &mynode, NULL);
|
||||
assert(!ret);
|
||||
|
||||
opts.numa_node = mynode;
|
||||
inner_lru_map_fds[cpu] =
|
||||
bpf_create_map_node(BPF_MAP_TYPE_LRU_HASH,
|
||||
test_map_names[INNER_LRU_HASH_PREALLOC],
|
||||
sizeof(uint32_t),
|
||||
sizeof(long),
|
||||
inner_lru_hash_size, 0,
|
||||
mynode);
|
||||
bpf_map_create(BPF_MAP_TYPE_LRU_HASH,
|
||||
test_map_names[INNER_LRU_HASH_PREALLOC],
|
||||
sizeof(uint32_t),
|
||||
sizeof(long),
|
||||
inner_lru_hash_size, &opts);
|
||||
if (inner_lru_map_fds[cpu] == -1) {
|
||||
printf("cannot create BPF_MAP_TYPE_LRU_HASH %s(%d)\n",
|
||||
strerror(errno), errno);
|
||||
|
@ -37,8 +37,8 @@ static int test_sock(void)
|
||||
int sock = -1, map_fd, prog_fd, i, key;
|
||||
long long value = 0, tcp_cnt, udp_cnt, icmp_cnt;
|
||||
|
||||
map_fd = bpf_create_map(BPF_MAP_TYPE_ARRAY, sizeof(key), sizeof(value),
|
||||
256, 0);
|
||||
map_fd = bpf_map_create(BPF_MAP_TYPE_ARRAY, NULL, sizeof(key), sizeof(value),
|
||||
256, NULL);
|
||||
if (map_fd < 0) {
|
||||
printf("failed to create map '%s'\n", strerror(errno));
|
||||
goto cleanup;
|
||||
@ -59,9 +59,13 @@ static int test_sock(void)
|
||||
BPF_EXIT_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,
|
||||
"GPL", 0, bpf_log_buf, BPF_LOG_BUF_SIZE);
|
||||
prog_fd = bpf_prog_load(BPF_PROG_TYPE_SOCKET_FILTER, NULL, "GPL",
|
||||
prog, insns_cnt, &opts);
|
||||
if (prog_fd < 0) {
|
||||
printf("failed to load prog '%s'\n", strerror(errno));
|
||||
goto cleanup;
|
||||
|
@ -11,17 +11,26 @@
|
||||
int main(int ac, char **argv)
|
||||
{
|
||||
struct bpf_object *obj;
|
||||
struct bpf_program *prog;
|
||||
int map_fd, prog_fd;
|
||||
char filename[256];
|
||||
int i, sock;
|
||||
int i, sock, err;
|
||||
FILE *f;
|
||||
|
||||
snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
|
||||
|
||||
if (bpf_prog_load(filename, BPF_PROG_TYPE_SOCKET_FILTER,
|
||||
&obj, &prog_fd))
|
||||
obj = bpf_object__open_file(filename, NULL);
|
||||
if (libbpf_get_error(obj))
|
||||
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");
|
||||
|
||||
sock = open_raw_sock("lo");
|
||||
|
@ -16,18 +16,26 @@ struct pair {
|
||||
|
||||
int main(int ac, char **argv)
|
||||
{
|
||||
struct bpf_program *prog;
|
||||
struct bpf_object *obj;
|
||||
int map_fd, prog_fd;
|
||||
char filename[256];
|
||||
int i, sock;
|
||||
int i, sock, err;
|
||||
FILE *f;
|
||||
|
||||
snprintf(filename, sizeof(filename), "%s_kern.o", argv[0]);
|
||||
|
||||
if (bpf_prog_load(filename, BPF_PROG_TYPE_SOCKET_FILTER,
|
||||
&obj, &prog_fd))
|
||||
obj = bpf_object__open_file(filename, NULL);
|
||||
if (libbpf_get_error(obj))
|
||||
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");
|
||||
|
||||
sock = open_raw_sock("lo");
|
||||
|
@ -64,9 +64,9 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
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),
|
||||
1, 0);
|
||||
1, NULL);
|
||||
if (array_fd < 0) {
|
||||
fprintf(stderr,
|
||||
"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(),
|
||||
};
|
||||
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,
|
||||
prog, insns_cnt, "GPL", 0,
|
||||
bpf_log_buf, BPF_LOG_BUF_SIZE);
|
||||
return bpf_prog_load(BPF_PROG_TYPE_CGROUP_SKB, NULL, "GPL",
|
||||
prog, insns_cnt, &opts);
|
||||
}
|
||||
|
||||
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;
|
||||
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),
|
||||
256, 0);
|
||||
256, NULL);
|
||||
if (map_fd < 0) {
|
||||
printf("Failed to create map: '%s'\n", strerror(errno));
|
||||
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_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;
|
||||
size_t insns_cnt;
|
||||
@ -115,8 +119,8 @@ static int prog_load(__u32 idx, __u32 mark, __u32 prio)
|
||||
|
||||
insns_cnt /= sizeof(struct bpf_insn);
|
||||
|
||||
ret = bpf_load_program(BPF_PROG_TYPE_CGROUP_SOCK, prog, insns_cnt,
|
||||
"GPL", 0, bpf_log_buf, BPF_LOG_BUF_SIZE);
|
||||
ret = bpf_prog_load(BPF_PROG_TYPE_CGROUP_SOCK, NULL, "GPL",
|
||||
prog, insns_cnt, &opts);
|
||||
|
||||
free(prog);
|
||||
|
||||
|
@ -105,10 +105,10 @@ struct pfect_lru {
|
||||
static void pfect_lru_init(struct pfect_lru *lru, unsigned int lru_size,
|
||||
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(struct pfect_lru_node *),
|
||||
nr_possible_elems, 0);
|
||||
nr_possible_elems, NULL);
|
||||
assert(lru->map_fd != -1);
|
||||
|
||||
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)
|
||||
{
|
||||
LIBBPF_OPTS(bpf_map_create_opts, opts,
|
||||
.map_flags = map_flags,
|
||||
);
|
||||
int map_fd;
|
||||
|
||||
map_fd = bpf_create_map(map_type, sizeof(unsigned long long),
|
||||
sizeof(unsigned long long), size, map_flags);
|
||||
map_fd = bpf_map_create(map_type, NULL, sizeof(unsigned long long),
|
||||
sizeof(unsigned long long), size, &opts);
|
||||
|
||||
if (map_fd == -1)
|
||||
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)
|
||||
{
|
||||
struct perf_buffer_opts pb_opts = {};
|
||||
struct bpf_link *link = NULL;
|
||||
struct bpf_program *prog;
|
||||
struct perf_buffer *pb;
|
||||
@ -84,8 +83,7 @@ int main(int argc, char **argv)
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
pb_opts.sample_cb = print_bpf_output;
|
||||
pb = perf_buffer__new(map_fd, 8, &pb_opts);
|
||||
pb = perf_buffer__new(map_fd, 8, print_bpf_output, NULL, NULL, NULL);
|
||||
ret = libbpf_get_error(pb);
|
||||
if (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)
|
||||
{
|
||||
struct bpf_prog_load_attr prog_load_attr = {
|
||||
.prog_type = BPF_PROG_TYPE_XDP,
|
||||
};
|
||||
struct perf_buffer_opts pb_opts = {};
|
||||
const char *optstr = "FS";
|
||||
int prog_fd, map_fd, opt;
|
||||
struct bpf_program *prog;
|
||||
struct bpf_object *obj;
|
||||
struct bpf_map *map;
|
||||
char filename[256];
|
||||
@ -144,15 +141,19 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if (!prog_fd) {
|
||||
printf("bpf_prog_load_xattr: %s\n", strerror(errno));
|
||||
prog = bpf_object__next_program(obj, NULL);
|
||||
bpf_program__set_type(prog, BPF_PROG_TYPE_XDP);
|
||||
|
||||
err = bpf_object__load(obj);
|
||||
if (err)
|
||||
return 1;
|
||||
}
|
||||
|
||||
prog_fd = bpf_program__fd(prog);
|
||||
|
||||
map = bpf_object__next_map(obj, NULL);
|
||||
if (!map) {
|
||||
@ -181,8 +182,7 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
pb_opts.sample_cb = print_bpf_output;
|
||||
pb = perf_buffer__new(map_fd, 8, &pb_opts);
|
||||
pb = perf_buffer__new(map_fd, 8, print_bpf_output, NULL, NULL, NULL);
|
||||
err = libbpf_get_error(pb);
|
||||
if (err) {
|
||||
perror("perf_buffer setup failed");
|
||||
|
@ -15,6 +15,9 @@
|
||||
#include <bpf/xsk.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 struct option long_options[] = {
|
||||
|
@ -36,6 +36,9 @@
|
||||
#include <bpf/bpf.h>
|
||||
#include "xdpsock.h"
|
||||
|
||||
/* libbpf APIs for AF_XDP are deprecated starting from v0.7 */
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
#ifndef SOL_XDP
|
||||
#define SOL_XDP 283
|
||||
#endif
|
||||
|
@ -27,6 +27,9 @@
|
||||
#include <bpf/xsk.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]))
|
||||
|
||||
typedef __u64 u64;
|
||||
|
@ -1261,7 +1261,10 @@ static int do_pin(int argc, char **argv)
|
||||
|
||||
static int do_create(int argc, char **argv)
|
||||
{
|
||||
struct bpf_create_map_attr attr = { NULL, };
|
||||
LIBBPF_OPTS(bpf_map_create_opts, attr);
|
||||
enum bpf_map_type map_type = BPF_MAP_TYPE_UNSPEC;
|
||||
__u32 key_size = 0, value_size = 0, max_entries = 0;
|
||||
const char *map_name = NULL;
|
||||
const char *pinfile;
|
||||
int err = -1, fd;
|
||||
|
||||
@ -1276,30 +1279,30 @@ static int do_create(int argc, char **argv)
|
||||
if (is_prefix(*argv, "type")) {
|
||||
NEXT_ARG();
|
||||
|
||||
if (attr.map_type) {
|
||||
if (map_type) {
|
||||
p_err("map type already specified");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
attr.map_type = map_type_from_str(*argv);
|
||||
if ((int)attr.map_type < 0) {
|
||||
map_type = map_type_from_str(*argv);
|
||||
if ((int)map_type < 0) {
|
||||
p_err("unrecognized map type: %s", *argv);
|
||||
goto exit;
|
||||
}
|
||||
NEXT_ARG();
|
||||
} else if (is_prefix(*argv, "name")) {
|
||||
NEXT_ARG();
|
||||
attr.name = GET_ARG();
|
||||
map_name = GET_ARG();
|
||||
} else if (is_prefix(*argv, "key")) {
|
||||
if (parse_u32_arg(&argc, &argv, &attr.key_size,
|
||||
if (parse_u32_arg(&argc, &argv, &key_size,
|
||||
"key size"))
|
||||
goto exit;
|
||||
} else if (is_prefix(*argv, "value")) {
|
||||
if (parse_u32_arg(&argc, &argv, &attr.value_size,
|
||||
if (parse_u32_arg(&argc, &argv, &value_size,
|
||||
"value size"))
|
||||
goto exit;
|
||||
} else if (is_prefix(*argv, "entries")) {
|
||||
if (parse_u32_arg(&argc, &argv, &attr.max_entries,
|
||||
if (parse_u32_arg(&argc, &argv, &max_entries,
|
||||
"max entries"))
|
||||
goto exit;
|
||||
} else if (is_prefix(*argv, "flags")) {
|
||||
@ -1340,14 +1343,14 @@ static int do_create(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (!attr.name) {
|
||||
if (!map_name) {
|
||||
p_err("map name not specified");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
set_max_rlimit();
|
||||
|
||||
fd = bpf_create_map_xattr(&attr);
|
||||
fd = bpf_map_create(map_type, map_name, key_size, value_size, max_entries, &attr);
|
||||
if (fd < 0) {
|
||||
p_err("map create failed: %s", strerror(errno));
|
||||
goto exit;
|
||||
|
@ -43,12 +43,12 @@ struct bpf_map_create_opts {
|
||||
__u32 btf_value_type_id;
|
||||
__u32 btf_vmlinux_value_type_id;
|
||||
|
||||
int inner_map_fd;
|
||||
int map_flags;
|
||||
__u32 inner_map_fd;
|
||||
__u32 map_flags;
|
||||
__u64 map_extra;
|
||||
|
||||
int numa_node;
|
||||
int map_ifindex;
|
||||
__u32 numa_node;
|
||||
__u32 map_ifindex;
|
||||
};
|
||||
#define bpf_map_create_opts__last_field map_ifindex
|
||||
|
||||
|
@ -8475,6 +8475,20 @@ int bpf_program__set_flags(struct bpf_program *prog, __u32 flags)
|
||||
return 0;
|
||||
}
|
||||
|
||||
__u32 bpf_program__log_level(const struct bpf_program *prog)
|
||||
{
|
||||
return prog->log_level;
|
||||
}
|
||||
|
||||
int bpf_program__set_log_level(struct bpf_program *prog, __u32 log_level)
|
||||
{
|
||||
if (prog->obj->loaded)
|
||||
return libbpf_err(-EBUSY);
|
||||
|
||||
prog->log_level = log_level;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define SEC_DEF(sec_pfx, ptype, atype, flags, ...) { \
|
||||
.sec = sec_pfx, \
|
||||
.prog_type = BPF_PROG_TYPE_##ptype, \
|
||||
|
@ -499,6 +499,8 @@ bpf_program__set_expected_attach_type(struct bpf_program *prog,
|
||||
|
||||
LIBBPF_API __u32 bpf_program__flags(const struct bpf_program *prog);
|
||||
LIBBPF_API int bpf_program__set_flags(struct bpf_program *prog, __u32 flags);
|
||||
LIBBPF_API __u32 bpf_program__log_level(const struct bpf_program *prog);
|
||||
LIBBPF_API int bpf_program__set_log_level(struct bpf_program *prog, __u32 log_level);
|
||||
|
||||
LIBBPF_API int
|
||||
bpf_program__set_attach_target(struct bpf_program *prog, int attach_prog_fd,
|
||||
@ -680,6 +682,7 @@ struct bpf_prog_load_attr {
|
||||
int prog_flags;
|
||||
};
|
||||
|
||||
LIBBPF_DEPRECATED_SINCE(0, 8, "use bpf_object__open() and bpf_object__load() instead")
|
||||
LIBBPF_API int bpf_prog_load_xattr(const struct bpf_prog_load_attr *attr,
|
||||
struct bpf_object **pobj, int *prog_fd);
|
||||
LIBBPF_DEPRECATED_SINCE(0, 7, "use bpf_object__open() and bpf_object__load() instead")
|
||||
|
@ -419,3 +419,9 @@ LIBBPF_0.6.0 {
|
||||
perf_buffer__new_raw;
|
||||
perf_buffer__new_raw_deprecated;
|
||||
} LIBBPF_0.5.0;
|
||||
|
||||
LIBBPF_0.7.0 {
|
||||
global:
|
||||
bpf_program__log_level;
|
||||
bpf_program__set_log_level;
|
||||
};
|
||||
|
@ -40,6 +40,11 @@
|
||||
#else
|
||||
#define __LIBBPF_MARK_DEPRECATED_0_7(X)
|
||||
#endif
|
||||
#if __LIBBPF_CURRENT_VERSION_GEQ(0, 8)
|
||||
#define __LIBBPF_MARK_DEPRECATED_0_8(X) X
|
||||
#else
|
||||
#define __LIBBPF_MARK_DEPRECATED_0_8(X)
|
||||
#endif
|
||||
|
||||
/* This set of internal macros allows to do "function overloading" based on
|
||||
* number of arguments provided by used in backwards-compatible way during the
|
||||
|
@ -4,6 +4,6 @@
|
||||
#define __LIBBPF_VERSION_H
|
||||
|
||||
#define LIBBPF_MAJOR_VERSION 0
|
||||
#define LIBBPF_MINOR_VERSION 6
|
||||
#define LIBBPF_MINOR_VERSION 7
|
||||
|
||||
#endif /* __LIBBPF_VERSION_H */
|
||||
|
@ -19,16 +19,28 @@ extern int extra_prog_load_log_flags;
|
||||
|
||||
static int check_load(const char *file, enum bpf_prog_type type)
|
||||
{
|
||||
struct bpf_prog_load_attr attr;
|
||||
struct bpf_object *obj = NULL;
|
||||
int err, prog_fd;
|
||||
struct bpf_program *prog;
|
||||
int err;
|
||||
|
||||
memset(&attr, 0, sizeof(struct bpf_prog_load_attr));
|
||||
attr.file = file;
|
||||
attr.prog_type = type;
|
||||
attr.log_level = 4 | extra_prog_load_log_flags;
|
||||
attr.prog_flags = BPF_F_TEST_RND_HI32;
|
||||
err = bpf_prog_load_xattr(&attr, &obj, &prog_fd);
|
||||
obj = bpf_object__open_file(file, NULL);
|
||||
err = libbpf_get_error(obj);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
prog = bpf_object__next_program(obj, NULL);
|
||||
if (!prog) {
|
||||
err = -ENOENT;
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
bpf_program__set_type(prog, type);
|
||||
bpf_program__set_flags(prog, BPF_F_TEST_RND_HI32);
|
||||
bpf_program__set_log_level(prog, 4 | extra_prog_load_log_flags);
|
||||
|
||||
err = bpf_object__load(obj);
|
||||
|
||||
err_out:
|
||||
bpf_object__close(obj);
|
||||
return err;
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ static void test_split_dup_struct_in_cu()
|
||||
"\t'f2' type_id=1 bits_offset=32");
|
||||
|
||||
/* ..dedup them... */
|
||||
err = btf__dedup(btf1, NULL, NULL);
|
||||
err = btf__dedup(btf1, NULL);
|
||||
if (!ASSERT_OK(err, "btf_dedup"))
|
||||
goto cleanup;
|
||||
|
||||
@ -405,7 +405,7 @@ static void test_split_dup_struct_in_cu()
|
||||
"\t'f1' type_id=4 bits_offset=0\n"
|
||||
"\t'f2' type_id=4 bits_offset=32");
|
||||
|
||||
err = btf__dedup(btf2, NULL, NULL);
|
||||
err = btf__dedup(btf2, NULL);
|
||||
if (!ASSERT_OK(err, "btf_dedup"))
|
||||
goto cleanup;
|
||||
|
||||
|
@ -51,19 +51,20 @@ static int run_test(int cgroup_fd, int server_fd, int family, int type)
|
||||
bool v4 = family == AF_INET;
|
||||
__u16 expected_local_port = v4 ? 22222 : 22223;
|
||||
__u16 expected_peer_port = 60000;
|
||||
struct bpf_prog_load_attr attr = {
|
||||
.file = v4 ? "./connect_force_port4.o" :
|
||||
"./connect_force_port6.o",
|
||||
};
|
||||
struct bpf_program *prog;
|
||||
struct bpf_object *obj;
|
||||
int xlate_fd, fd, err;
|
||||
const char *obj_file = v4 ? "connect_force_port4.o" : "connect_force_port6.o";
|
||||
int fd, err;
|
||||
__u32 duration = 0;
|
||||
|
||||
err = bpf_prog_load_xattr(&attr, &obj, &xlate_fd);
|
||||
if (err) {
|
||||
log_err("Failed to load BPF object");
|
||||
obj = bpf_object__open_file(obj_file, NULL);
|
||||
if (!ASSERT_OK_PTR(obj, "bpf_obj_open"))
|
||||
return -1;
|
||||
|
||||
err = bpf_object__load(obj);
|
||||
if (!ASSERT_OK(err, "bpf_obj_load")) {
|
||||
err = -EIO;
|
||||
goto close_bpf_object;
|
||||
}
|
||||
|
||||
prog = bpf_object__find_program_by_title(obj, v4 ?
|
||||
|
@ -1,6 +1,7 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include <test_progs.h>
|
||||
#include <network_helpers.h>
|
||||
#include "kfree_skb.skel.h"
|
||||
|
||||
struct meta {
|
||||
int ifindex;
|
||||
@ -58,16 +59,11 @@ void serial_test_kfree_skb(void)
|
||||
.ctx_in = &skb,
|
||||
.ctx_size_in = sizeof(skb),
|
||||
};
|
||||
struct bpf_prog_load_attr attr = {
|
||||
.file = "./kfree_skb.o",
|
||||
};
|
||||
|
||||
struct bpf_link *link = NULL, *link_fentry = NULL, *link_fexit = NULL;
|
||||
struct bpf_map *perf_buf_map, *global_data;
|
||||
struct bpf_program *prog, *fentry, *fexit;
|
||||
struct bpf_object *obj, *obj2 = NULL;
|
||||
struct kfree_skb *skel = NULL;
|
||||
struct bpf_link *link;
|
||||
struct bpf_object *obj;
|
||||
struct perf_buffer *pb = NULL;
|
||||
int err, kfree_skb_fd;
|
||||
int err;
|
||||
bool passed = false;
|
||||
__u32 duration = 0;
|
||||
const int zero = 0;
|
||||
@ -78,40 +74,27 @@ void serial_test_kfree_skb(void)
|
||||
if (CHECK(err, "prog_load sched cls", "err %d errno %d\n", err, errno))
|
||||
return;
|
||||
|
||||
err = bpf_prog_load_xattr(&attr, &obj2, &kfree_skb_fd);
|
||||
if (CHECK(err, "prog_load raw tp", "err %d errno %d\n", err, errno))
|
||||
skel = kfree_skb__open_and_load();
|
||||
if (!ASSERT_OK_PTR(skel, "kfree_skb_skel"))
|
||||
goto close_prog;
|
||||
|
||||
prog = bpf_object__find_program_by_title(obj2, "tp_btf/kfree_skb");
|
||||
if (CHECK(!prog, "find_prog", "prog kfree_skb not found\n"))
|
||||
goto close_prog;
|
||||
fentry = bpf_object__find_program_by_title(obj2, "fentry/eth_type_trans");
|
||||
if (CHECK(!fentry, "find_prog", "prog eth_type_trans not found\n"))
|
||||
goto close_prog;
|
||||
fexit = bpf_object__find_program_by_title(obj2, "fexit/eth_type_trans");
|
||||
if (CHECK(!fexit, "find_prog", "prog eth_type_trans not found\n"))
|
||||
goto close_prog;
|
||||
|
||||
global_data = bpf_object__find_map_by_name(obj2, ".bss");
|
||||
if (CHECK(!global_data, "find global data", "not found\n"))
|
||||
goto close_prog;
|
||||
|
||||
link = bpf_program__attach_raw_tracepoint(prog, NULL);
|
||||
link = bpf_program__attach_raw_tracepoint(skel->progs.trace_kfree_skb, NULL);
|
||||
if (!ASSERT_OK_PTR(link, "attach_raw_tp"))
|
||||
goto close_prog;
|
||||
link_fentry = bpf_program__attach_trace(fentry);
|
||||
if (!ASSERT_OK_PTR(link_fentry, "attach fentry"))
|
||||
goto close_prog;
|
||||
link_fexit = bpf_program__attach_trace(fexit);
|
||||
if (!ASSERT_OK_PTR(link_fexit, "attach fexit"))
|
||||
goto close_prog;
|
||||
skel->links.trace_kfree_skb = link;
|
||||
|
||||
perf_buf_map = bpf_object__find_map_by_name(obj2, "perf_buf_map");
|
||||
if (CHECK(!perf_buf_map, "find_perf_buf_map", "not found\n"))
|
||||
link = bpf_program__attach_trace(skel->progs.fentry_eth_type_trans);
|
||||
if (!ASSERT_OK_PTR(link, "attach fentry"))
|
||||
goto close_prog;
|
||||
skel->links.fentry_eth_type_trans = link;
|
||||
|
||||
link = bpf_program__attach_trace(skel->progs.fexit_eth_type_trans);
|
||||
if (!ASSERT_OK_PTR(link, "attach fexit"))
|
||||
goto close_prog;
|
||||
skel->links.fexit_eth_type_trans = link;
|
||||
|
||||
/* set up perf buffer */
|
||||
pb = perf_buffer__new(bpf_map__fd(perf_buf_map), 1,
|
||||
pb = perf_buffer__new(bpf_map__fd(skel->maps.perf_buf_map), 1,
|
||||
on_sample, NULL, &passed, NULL);
|
||||
if (!ASSERT_OK_PTR(pb, "perf_buf__new"))
|
||||
goto close_prog;
|
||||
@ -133,7 +116,7 @@ void serial_test_kfree_skb(void)
|
||||
*/
|
||||
ASSERT_TRUE(passed, "passed");
|
||||
|
||||
err = bpf_map_lookup_elem(bpf_map__fd(global_data), &zero, test_ok);
|
||||
err = bpf_map_lookup_elem(bpf_map__fd(skel->maps.bss), &zero, test_ok);
|
||||
if (CHECK(err, "get_result",
|
||||
"failed to get output data: %d\n", err))
|
||||
goto close_prog;
|
||||
@ -141,9 +124,6 @@ void serial_test_kfree_skb(void)
|
||||
CHECK_FAIL(!test_ok[0] || !test_ok[1]);
|
||||
close_prog:
|
||||
perf_buffer__free(pb);
|
||||
bpf_link__destroy(link);
|
||||
bpf_link__destroy(link_fentry);
|
||||
bpf_link__destroy(link_fexit);
|
||||
bpf_object__close(obj);
|
||||
bpf_object__close(obj2);
|
||||
kfree_skb__destroy(skel);
|
||||
}
|
||||
|
@ -167,20 +167,20 @@ static int prog_attach(struct bpf_object *obj, int cgroup_fd, const char *title)
|
||||
|
||||
static void run_test(int cgroup_fd)
|
||||
{
|
||||
struct bpf_prog_load_attr attr = {
|
||||
.file = "./sockopt_inherit.o",
|
||||
};
|
||||
int server_fd = -1, client_fd;
|
||||
struct bpf_object *obj;
|
||||
void *server_err;
|
||||
pthread_t tid;
|
||||
int ignored;
|
||||
int err;
|
||||
|
||||
err = bpf_prog_load_xattr(&attr, &obj, &ignored);
|
||||
if (CHECK_FAIL(err))
|
||||
obj = bpf_object__open_file("sockopt_inherit.o", NULL);
|
||||
if (!ASSERT_OK_PTR(obj, "obj_open"))
|
||||
return;
|
||||
|
||||
err = bpf_object__load(obj);
|
||||
if (!ASSERT_OK(err, "obj_load"))
|
||||
goto close_bpf_object;
|
||||
|
||||
err = prog_attach(obj, cgroup_fd, "cgroup/getsockopt");
|
||||
if (CHECK_FAIL(err))
|
||||
goto close_bpf_object;
|
||||
|
@ -297,14 +297,10 @@ detach:
|
||||
|
||||
void test_sockopt_multi(void)
|
||||
{
|
||||
struct bpf_prog_load_attr attr = {
|
||||
.file = "./sockopt_multi.o",
|
||||
};
|
||||
int cg_parent = -1, cg_child = -1;
|
||||
struct bpf_object *obj = NULL;
|
||||
int sock_fd = -1;
|
||||
int err = -1;
|
||||
int ignored;
|
||||
|
||||
cg_parent = test__join_cgroup("/parent");
|
||||
if (CHECK_FAIL(cg_parent < 0))
|
||||
@ -314,8 +310,12 @@ void test_sockopt_multi(void)
|
||||
if (CHECK_FAIL(cg_child < 0))
|
||||
goto out;
|
||||
|
||||
err = bpf_prog_load_xattr(&attr, &obj, &ignored);
|
||||
if (CHECK_FAIL(err))
|
||||
obj = bpf_object__open_file("sockopt_multi.o", NULL);
|
||||
if (!ASSERT_OK_PTR(obj, "obj_load"))
|
||||
goto out;
|
||||
|
||||
err = bpf_object__load(obj);
|
||||
if (!ASSERT_OK(err, "obj_load"))
|
||||
goto out;
|
||||
|
||||
sock_fd = socket(AF_INET, SOCK_STREAM, 0);
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <test_progs.h>
|
||||
#include "cgroup_helpers.h"
|
||||
#include "network_helpers.h"
|
||||
#include "tcp_rtt.skel.h"
|
||||
|
||||
struct tcp_rtt_storage {
|
||||
__u32 invoked;
|
||||
@ -91,26 +92,18 @@ static int verify_sk(int map_fd, int client_fd, const char *msg, __u32 invoked,
|
||||
|
||||
static int run_test(int cgroup_fd, int server_fd)
|
||||
{
|
||||
struct bpf_prog_load_attr attr = {
|
||||
.prog_type = BPF_PROG_TYPE_SOCK_OPS,
|
||||
.file = "./tcp_rtt.o",
|
||||
.expected_attach_type = BPF_CGROUP_SOCK_OPS,
|
||||
};
|
||||
struct bpf_object *obj;
|
||||
struct bpf_map *map;
|
||||
struct tcp_rtt *skel;
|
||||
int client_fd;
|
||||
int prog_fd;
|
||||
int map_fd;
|
||||
int err;
|
||||
|
||||
err = bpf_prog_load_xattr(&attr, &obj, &prog_fd);
|
||||
if (err) {
|
||||
log_err("Failed to load BPF object");
|
||||
skel = tcp_rtt__open_and_load();
|
||||
if (!ASSERT_OK_PTR(skel, "skel_open_load"))
|
||||
return -1;
|
||||
}
|
||||
|
||||
map = bpf_object__next_map(obj, NULL);
|
||||
map_fd = bpf_map__fd(map);
|
||||
map_fd = bpf_map__fd(skel->maps.socket_storage_map);
|
||||
prog_fd = bpf_program__fd(skel->progs._sockops);
|
||||
|
||||
err = bpf_prog_attach(prog_fd, cgroup_fd, BPF_CGROUP_SOCK_OPS, 0);
|
||||
if (err) {
|
||||
@ -149,7 +142,7 @@ close_client_fd:
|
||||
close(client_fd);
|
||||
|
||||
close_bpf_object:
|
||||
bpf_object__close(obj);
|
||||
tcp_rtt__destroy(skel);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -30,17 +30,29 @@ extern int extra_prog_load_log_flags;
|
||||
|
||||
static int check_load(const char *file)
|
||||
{
|
||||
struct bpf_prog_load_attr attr;
|
||||
struct bpf_object *obj = NULL;
|
||||
int err, prog_fd;
|
||||
struct bpf_program *prog;
|
||||
int err;
|
||||
|
||||
memset(&attr, 0, sizeof(struct bpf_prog_load_attr));
|
||||
attr.file = file;
|
||||
attr.prog_type = BPF_PROG_TYPE_UNSPEC;
|
||||
attr.log_level = extra_prog_load_log_flags;
|
||||
attr.prog_flags = BPF_F_TEST_RND_HI32;
|
||||
found = false;
|
||||
err = bpf_prog_load_xattr(&attr, &obj, &prog_fd);
|
||||
|
||||
obj = bpf_object__open_file(file, NULL);
|
||||
err = libbpf_get_error(obj);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
prog = bpf_object__next_program(obj, NULL);
|
||||
if (!prog) {
|
||||
err = -ENOENT;
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
bpf_program__set_flags(prog, BPF_F_TEST_RND_HI32);
|
||||
bpf_program__set_log_level(prog, extra_prog_load_log_flags);
|
||||
|
||||
err = bpf_object__load(obj);
|
||||
|
||||
err_out:
|
||||
bpf_object__close(obj);
|
||||
return err;
|
||||
}
|
||||
|
@ -663,23 +663,36 @@ static int load_insns(const struct sock_addr_test *test,
|
||||
|
||||
static int load_path(const struct sock_addr_test *test, const char *path)
|
||||
{
|
||||
struct bpf_prog_load_attr attr;
|
||||
struct bpf_object *obj;
|
||||
int prog_fd;
|
||||
struct bpf_program *prog;
|
||||
int err;
|
||||
|
||||
memset(&attr, 0, sizeof(struct bpf_prog_load_attr));
|
||||
attr.file = path;
|
||||
attr.prog_type = BPF_PROG_TYPE_CGROUP_SOCK_ADDR;
|
||||
attr.expected_attach_type = test->expected_attach_type;
|
||||
attr.prog_flags = BPF_F_TEST_RND_HI32;
|
||||
|
||||
if (bpf_prog_load_xattr(&attr, &obj, &prog_fd)) {
|
||||
if (test->expected_result != LOAD_REJECT)
|
||||
log_err(">>> Loading program (%s) error.\n", path);
|
||||
obj = bpf_object__open_file(path, NULL);
|
||||
err = libbpf_get_error(obj);
|
||||
if (err) {
|
||||
log_err(">>> Opening BPF object (%s) error.\n", path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return prog_fd;
|
||||
prog = bpf_object__next_program(obj, NULL);
|
||||
if (!prog)
|
||||
goto err_out;
|
||||
|
||||
bpf_program__set_type(prog, BPF_PROG_TYPE_CGROUP_SOCK_ADDR);
|
||||
bpf_program__set_expected_attach_type(prog, test->expected_attach_type);
|
||||
bpf_program__set_flags(prog, BPF_F_TEST_RND_HI32);
|
||||
|
||||
err = bpf_object__load(obj);
|
||||
if (err) {
|
||||
if (test->expected_result != LOAD_REJECT)
|
||||
log_err(">>> Loading program (%s) error.\n", path);
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
return bpf_program__fd(prog);
|
||||
err_out:
|
||||
bpf_object__close(obj);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int bind4_prog_load(const struct sock_addr_test *test)
|
||||
|
@ -85,10 +85,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
int prog_fd, group_all, mac_map;
|
||||
struct bpf_program *ingress_prog, *egress_prog;
|
||||
struct bpf_prog_load_attr prog_load_attr = {
|
||||
.prog_type = BPF_PROG_TYPE_UNSPEC,
|
||||
};
|
||||
int i, ret, opt, egress_prog_fd = 0;
|
||||
int i, err, ret, opt, egress_prog_fd = 0;
|
||||
struct bpf_devmap_val devmap_val;
|
||||
bool attach_egress_prog = false;
|
||||
unsigned char mac_addr[6];
|
||||
@ -147,10 +144,14 @@ int main(int argc, char **argv)
|
||||
printf("\n");
|
||||
|
||||
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);
|
||||
err = libbpf_get_error(obj);
|
||||
if (err)
|
||||
goto err_out;
|
||||
err = bpf_object__load(obj);
|
||||
if (err)
|
||||
goto err_out;
|
||||
prog_fd = bpf_program__fd(bpf_object__next_program(obj, NULL));
|
||||
|
||||
if (attach_egress_prog)
|
||||
group_all = bpf_object__find_map_fd_by_name(obj, "map_egress");
|
||||
|
@ -100,6 +100,12 @@
|
||||
#include "xdpxceiver.h"
|
||||
#include "../kselftest.h"
|
||||
|
||||
/* AF_XDP APIs were moved into libxdp and marked as deprecated in libbpf.
|
||||
* Until xdpxceiver is either moved or re-writed into libxdp, suppress
|
||||
* deprecation warnings in this file
|
||||
*/
|
||||
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
|
||||
|
||||
static const char *MAC1 = "\x00\x0A\x56\x9E\xEE\x62";
|
||||
static const char *MAC2 = "\x00\x0A\x56\x9E\xEE\x61";
|
||||
static const char *IP1 = "192.168.100.162";
|
||||
|
Loading…
Reference in New Issue
Block a user