Deprecate bpf_object__open() in favor of bpf_object__open_file(). Signed-off-by: Christy Lee <christylee@xxxxxx> --- Documentation/bpf/prog_lsm.rst | 2 +- tools/bpf/bpftool/Documentation/bpftool-gen.rst | 2 +- tools/bpf/bpftool/iter.c | 2 +- tools/build/feature/test-libbpf.c | 2 +- tools/lib/bpf/libbpf.h | 5 +++-- tools/perf/util/bpf-loader.c | 2 +- tools/testing/selftests/bpf/prog_tests/btf.c | 2 +- tools/testing/selftests/bpf/prog_tests/select_reuseport.c | 2 +- tools/testing/selftests/bpf/test_maps.c | 4 ++-- tools/testing/selftests/bpf/test_sockmap.c | 2 +- 10 files changed, 13 insertions(+), 12 deletions(-) diff --git a/Documentation/bpf/prog_lsm.rst b/Documentation/bpf/prog_lsm.rst index 0dc3fb0d9544..9217f5373951 100644 --- a/Documentation/bpf/prog_lsm.rst +++ b/Documentation/bpf/prog_lsm.rst @@ -102,7 +102,7 @@ eBPF programs can be loaded with the :manpage:`bpf(2)` syscall's struct bpf_object *obj; - obj = bpf_object__open("./my_prog.o"); + obj = bpf_object__open_file("./my_prog.o", NULL); bpf_object__load(obj); This can be simplified by using a skeleton header generated by ``bpftool``: diff --git a/tools/bpf/bpftool/Documentation/bpftool-gen.rst b/tools/bpf/bpftool/Documentation/bpftool-gen.rst index bc276388f432..036c6ec0cc48 100644 --- a/tools/bpf/bpftool/Documentation/bpftool-gen.rst +++ b/tools/bpf/bpftool/Documentation/bpftool-gen.rst @@ -46,7 +46,7 @@ DESCRIPTION individually compiled files that are then linked into a single resulting BPF object file, which can be used to generated BPF skeleton (with **gen skeleton** command) or - passed directly into **libbpf** (using **bpf_object__open()** + passed directly into **libbpf** (using **bpf_object__open_file()** family of APIs). **bpftool gen skeleton** *FILE* diff --git a/tools/bpf/bpftool/iter.c b/tools/bpf/bpftool/iter.c index f88fdc820d23..94a0ac1e176c 100644 --- a/tools/bpf/bpftool/iter.c +++ b/tools/bpf/bpftool/iter.c @@ -45,7 +45,7 @@ static int do_pin(int argc, char **argv) } } - obj = bpf_object__open(objfile); + obj = bpf_object__open_file(objfile, NULL); err = libbpf_get_error(obj); if (err) { p_err("can't open objfile %s", objfile); diff --git a/tools/build/feature/test-libbpf.c b/tools/build/feature/test-libbpf.c index a508756cf4cc..113d5be747f1 100644 --- a/tools/build/feature/test-libbpf.c +++ b/tools/build/feature/test-libbpf.c @@ -3,5 +3,5 @@ int main(void) { - return bpf_object__open("test") ? 0 : -1; + return bpf_object__open_file("test", NULL) ? 0 : -1; } diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h index 85dfef88b3d2..2c8767706f8e 100644 --- a/tools/lib/bpf/libbpf.h +++ b/tools/lib/bpf/libbpf.h @@ -150,6 +150,7 @@ struct bpf_object_open_opts { }; #define bpf_object_open_opts__last_field kernel_log_level +LIBBPF_DEPRECATED_SINCE(0, 8, "use bpf_object__open_file() instead") LIBBPF_API struct bpf_object *bpf_object__open(const char *path); /** @@ -807,10 +808,10 @@ struct bpf_prog_load_attr { int prog_flags; }; -LIBBPF_DEPRECATED_SINCE(0, 8, "use bpf_object__open() and bpf_object__load() instead") +LIBBPF_DEPRECATED_SINCE(0, 8, "use bpf_object__open_file() 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") +LIBBPF_DEPRECATED_SINCE(0, 7, "use bpf_object__open_file() and bpf_object__load() instead") LIBBPF_API int bpf_prog_load_deprecated(const char *file, enum bpf_prog_type type, struct bpf_object **pobj, int *prog_fd); diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c index 528aeb0ab79d..75694703d638 100644 --- a/tools/perf/util/bpf-loader.c +++ b/tools/perf/util/bpf-loader.c @@ -101,7 +101,7 @@ struct bpf_object *bpf__prepare_load(const char *filename, bool source) free(obj_buf); } else - obj = bpf_object__open(filename); + obj = bpf_object__open_file(filename, NULL); if (IS_ERR_OR_NULL(obj)) { pr_debug("bpf: failed to load %s\n", filename); diff --git a/tools/testing/selftests/bpf/prog_tests/btf.c b/tools/testing/selftests/bpf/prog_tests/btf.c index 8ba53acf9eb4..4bcc441fea21 100644 --- a/tools/testing/selftests/bpf/prog_tests/btf.c +++ b/tools/testing/selftests/bpf/prog_tests/btf.c @@ -4560,7 +4560,7 @@ static void do_test_file(unsigned int test_num) has_btf_ext = btf_ext != NULL; btf_ext__free(btf_ext); - obj = bpf_object__open(test->file); + obj = bpf_object__open_file(test->file, NULL); err = libbpf_get_error(obj); if (CHECK(err, "obj: %d", err)) return; diff --git a/tools/testing/selftests/bpf/prog_tests/select_reuseport.c b/tools/testing/selftests/bpf/prog_tests/select_reuseport.c index 1cbd8cd64044..83472eda46b5 100644 --- a/tools/testing/selftests/bpf/prog_tests/select_reuseport.c +++ b/tools/testing/selftests/bpf/prog_tests/select_reuseport.c @@ -91,7 +91,7 @@ static int prepare_bpf_obj(void) struct bpf_map *map; int err; - obj = bpf_object__open("test_select_reuseport_kern.o"); + obj = bpf_object__open_file("test_select_reuseport_kern.o", NULL); err = libbpf_get_error(obj); RET_ERR(err, "open test_select_reuseport_kern.o", "obj:%p PTR_ERR(obj):%d\n", obj, err); diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c index 50f7e74ca0b9..241b14f25ef5 100644 --- a/tools/testing/selftests/bpf/test_maps.c +++ b/tools/testing/selftests/bpf/test_maps.c @@ -1156,7 +1156,7 @@ static void test_map_in_map(void) __u32 id = 0; libbpf_print_fn_t old_print_fn; - obj = bpf_object__open(MAPINMAP_PROG); + obj = bpf_object__open_file(MAPINMAP_PROG, NULL); fd = bpf_map_create(BPF_MAP_TYPE_HASH, NULL, sizeof(int), sizeof(int), 2, NULL); if (fd < 0) { @@ -1227,7 +1227,7 @@ static void test_map_in_map(void) bpf_object__close(obj); /* Test that failing bpf_object__create_map() destroys the inner map */ - obj = bpf_object__open(MAPINMAP_INVALID_PROG); + obj = bpf_object__open_file(MAPINMAP_INVALID_PROG, NULL); err = libbpf_get_error(obj); if (err) { printf("Failed to load %s program: %d %d", diff --git a/tools/testing/selftests/bpf/test_sockmap.c b/tools/testing/selftests/bpf/test_sockmap.c index 1ba7e7346afb..521b4e0c0852 100644 --- a/tools/testing/selftests/bpf/test_sockmap.c +++ b/tools/testing/selftests/bpf/test_sockmap.c @@ -1761,7 +1761,7 @@ static int populate_progs(char *bpf_file) int i = 0; long err; - obj = bpf_object__open(bpf_file); + obj = bpf_object__open_file(bpf_file, NULL); err = libbpf_get_error(obj); if (err) { char err_buf[256]; -- 2.30.2