Commit 080a70b2 authored by Alexei Starovoitov's avatar Alexei Starovoitov
Browse files

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: default avatarAlexei Starovoitov <ast@kernel.org>
parents 8b4ff5f8 c93faaaf
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -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))				\
+0 −11
Original line number Diff line number Diff line
@@ -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 $@ $<
+9 −5
Original line number Diff line number Diff line
@@ -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);
}
+15 −9
Original line number Diff line number Diff line
@@ -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);

+0 −2
Original line number Diff line number Diff line
@@ -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>
Loading