fix libbpf 0.7 deprecated warnings
v2 cover fix libbpf 0.7 deprecated warnings
v2:
- update the Makefile as Mat suggested.
Geliang Tang (2):
bpf: examples: static library link to libbpf
bpf: examples: fix libbpf 0.7 deprecated warnings
bpf/examples/Makefile | 4 ++-- bpf/examples/loader.c | 4 ++-- bpf/examples/mptcp_set_sf_sockopt_kern.c | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/2 bpf: examples: static library link to libbpf
Change the dynamic libbpf function library link of this BPF examples into a static function library link, so that it no longer depends on the libbpf installed systemwide, but on the latest version of libbpf in a given kernel tree.
--- bpf/examples/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
bpf/examples/Makefile +2 -2
@@ -5,7 +5,7 @@ CFLAGS += -I${MPTCP}/tools/lib CFLAGS += -I${MPTCP}/tools/include CFLAGS += -I${MPTCP}/tools/perf -LOADER_FLAGS := -lelf -lbpf +LOADER_FLAGS := -lelf -lz ${MPTCP}/tools/lib/bpf/libbpf.a LOADER_FLAGS += -DHAVE_ATTR_TEST=0 BPF_FLAGS := -O2 -target bpf -g
@@ -13,7 +13,7 @@ BPF_FLAGS := -O2 -target bpf -g all: loader mptcp_set_sf_sockopt_kern.o loader: - @clang $(CFLAGS) $(LOADER_FLAGS) -o loader loader.c + @clang $(CFLAGS) -o loader loader.c $(LOADER_FLAGS) mptcp_set_sf_sockopt_kern.o: @clang $(BPF_FLAGS) -c mptcp_set_sf_sockopt_kern.c \
Signature · 1 line
2.34.1
PATCH v2 2/2 bpf: examples: fix libbpf 0.7 deprecated warnings
In reply to Geliang TangThis patch fixed the following deprecated warnings:
loader.c:136:10: warning: 'bpf_program__next' is deprecated: libbpf v0.7+: use bpf_object__next_program() instead [-Wdeprecated-declarations]
prog = bpf_program__next(prog, object_file);
^
tools/lib/bpf/libbpf.h:265:12: note: 'bpf_program__next' has been explicitly marked deprecated here
LIBBPF_API LIBBPF_DEPRECATED_SINCE(0, 7, "use bpf_object__next_program() instead")
^
tools/lib/bpf/libbpf_common.h:24:4: note: expanded from macro 'LIBBPF_DEPRECATED_SINCE'
(LIBBPF_DEPRECATED("libbpf v" # major "." # minor "+: " msg))
^
tools/lib/bpf/libbpf_common.h:19:47: note: expanded from macro 'LIBBPF_DEPRECATED'
^
loader.c:139:18: warning: 'bpf_program__title' is deprecated: BPF program title is confusing term; please use bpf_program__section_name() instead [-Wdeprecated-declarations]
name = (char*) bpf_program__title(prog, false);
^
tools/lib/bpf/libbpf.h:294:12: note: 'bpf_program__title' has been explicitly marked deprecated here
LIBBPF_API LIBBPF_DEPRECATED("BPF program title is confusing term; please use bpf_program__section_name() instead")
^
tools/lib/bpf/libbpf_common.h:19:47: note: expanded from macro 'LIBBPF_DEPRECATED'
^
2 warnings generated.
mptcp_set_sf_sockopt_kern.c:19:8: warning: 'bpf_map_def' is deprecated: use BTF-defined maps in .maps section [-Wdeprecated-declarations]
struct bpf_map_def SEC("maps") mptcp_sf = {
^
tools/lib/bpf/bpf_helpers.h:136:18: note: 'bpf_map_def' has been explicitly marked deprecated here
} __attribute__((deprecated("use BTF-defined maps in .maps section")));
^1 warning generated.
--- bpf/examples/loader.c | 4 ++-- bpf/examples/mptcp_set_sf_sockopt_kern.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-)
bpf/examples/loader.c +2 -2
@@ -133,10 +133,10 @@ int main(int argc, const char **argv)LIBBPF_ERROR_WRAPPER (ret,"failed to load programs from object file" ); do { - prog = bpf_program__next(prog, object_file); + prog = bpf_object__next_program(object_file, prog); if (!prog) break; - name = (char*) bpf_program__title(prog, false); + name = (char *)bpf_program__section_name(prog); switch(bpf_program__get_expected_attach_type(prog)) { case BPF_CGROUP_SOCK_OPS:
bpf/examples/mptcp_set_sf_sockopt_kern.c +6 -6
@@ -16,12 +16,12 @@ char _license[] SEC("license") = "GPL";char cc [TCP_CA_NAME_MAX ] ="vegas" ;/* Associate a subflow counter to each token */ -struct bpf_map_def SEC("maps") mptcp_sf = { - .type = BPF_MAP_TYPE_HASH, - .key_size = sizeof(__u32), - .value_size = sizeof(__u32), - .max_entries =100 -}; +struct { + __uint(type, BPF_MAP_TYPE_HASH); + __uint(key_size, sizeof(__u32)); + __uint(value_size, sizeof(__u32)); + __uint(max_entries, 100); +} mptcp_sf SEC(".maps");#define DEBUG 1
Signature · 1 line
2.34.1
Hi Geliang,
Quoted 6 lines · Geliang Tang
v2:
- update theMakefileas Mat suggested.Geliang Tang (2):
bpf: examples: static library link to libbpf
bpf: examples: fix libbpf 0.7 deprecated warnings
Thank you for these two patches!
Just applied in our repo ("scripts" branch)!
While at it, I added a few other small patches cleaning up the Makefile.
For patches in this "scripts" branch and if it is easier for you, you can also propose a PR on GitHub.
If you prefer continuing sending patches by email, please use 'mptcp-scripts' instead of 'mptcp-next' to avoid confusions ;-)
Cheers,
Matt
Signature · 2 lines
Tessares | Belgium | Hybrid Access Solutions www.tessares.net