Commit 710f6c38 authored by Christy Lee's avatar Christy Lee Committed by Arnaldo Carvalho de Melo
Browse files

perf bpf: Stop using deprecated bpf_load_program() API



bpf_load_program() API is deprecated, remove perf's usage of the
deprecated function. Add a __weak function declaration for libbpf
version compatibility.

Signed-off-by: default avatarChristy Lee <christylee@fb.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: bpf@vger.kernel.org
Cc: kernel-team@fb.com
Link: https://lore.kernel.org/bpf/20220212073054.1052880-2-andrii@kernel.org


Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent bcaf0a97
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -281,8 +281,8 @@ static int __test__bpf(int idx)

static int check_env(void)
{
	LIBBPF_OPTS(bpf_prog_load_opts, opts);
	int err;
	unsigned int kver_int;
	char license[] = "GPL";

	struct bpf_insn insns[] = {
@@ -290,19 +290,13 @@ static int check_env(void)
		BPF_EXIT_INSN(),
	};

	err = fetch_kernel_version(&kver_int, NULL, 0);
	err = fetch_kernel_version(&opts.kern_version, NULL, 0);
	if (err) {
		pr_debug("Unable to get kernel version\n");
		return err;
	}

/* temporarily disable libbpf deprecation warnings */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
	err = bpf_load_program(BPF_PROG_TYPE_KPROBE, insns,
			       ARRAY_SIZE(insns),
			       license, kver_int, NULL, 0);
#pragma GCC diagnostic pop
	err = bpf_prog_load(BPF_PROG_TYPE_KPROBE, NULL, license, insns,
			    ARRAY_SIZE(insns), &opts);
	if (err < 0) {
		pr_err("Missing basic BPF support, skip this test: %s\n",
		       strerror(errno));
+13 −0
Original line number Diff line number Diff line
@@ -33,6 +33,19 @@ struct btf * __weak btf__load_from_kernel_by_id(__u32 id)
       return err ? ERR_PTR(err) : btf;
}

int __weak bpf_prog_load(enum bpf_prog_type prog_type,
			 const char *prog_name __maybe_unused,
			 const char *license,
			 const struct bpf_insn *insns, size_t insn_cnt,
			 const struct bpf_prog_load_opts *opts)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
	return bpf_load_program(prog_type, insns, insn_cnt, license,
				opts->kern_version, opts->log_buf, opts->log_size);
#pragma GCC diagnostic pop
}

struct bpf_program * __weak
bpf_object__next_program(const struct bpf_object *obj, struct bpf_program *prev)
{