Address more libbpf deprecations
Subsystems (3)
cover Address more libbpf deprecations
Another round of changes to handle libbpf deprecations. Compiles are clean as of libbpf commit 533c7666eb72 ("Fix downloads formats").
David Ahern (3):
libbpf: Use bpf_object__load instead of bpf_object__load_xattr
libbpf: Remove use of bpf_program__set_priv and bpf_program__priv
libbpf: Remove use of bpf_map_is_offload_neutral
lib/bpf_libbpf.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH 1/3 libbpf: Use bpf_object__load instead of bpf_object__load_xattr
bpf_object__load_xattr is deprecated as of v0.8+; remove it in favor of bpf_object__load.
--- lib/bpf_libbpf.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
lib/bpf_libbpf.c +1 -6
@@ -248,7 +248,6 @@ static int handle_legacy_maps(struct bpf_object *obj)static int load_bpf_object (struct bpf_cfg_in *cfg) { -struct bpf_object_load_attr attr = {};struct bpf_program *p, *prog =NULL ;struct bpf_object *obj;char root_path[PATH_MAX ];
@@ -305,11 +304,7 @@ static int load_bpf_object(struct bpf_cfg_in *cfg)if (ret) goto unload_obj; - attr.obj = obj; -if (cfg->verbose) - attr.log_level =2 ; - - ret =bpf_object__load_xattr (&attr); + ret =bpf_object__load (obj);if (ret) goto unload_obj;
Signature · 1 line
2.24.3 (Apple Git-128)
Re: [PATCH iproute2-next 1/3] libbpf: Use bpf_object__load instead of bpf_object__load_xattr
Hi David,
This patch revert c04e45d0 lib/bpf: fix verbose flag when using libbpf, Should we set prog->log_level directly before it loaded, like bpf_program__set_log_level() does?
Thanks
Hangbin
Quoted 36 lines · David Ahern
bpf_object__load_xattris deprecated as of v0.8+; remove it in favor ofbpf_object__load.Signed-off-by David Ahern <[email protected]>--- lib/bpf_libbpf.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)lib/bpf_libbpf.c +1
-6@@ -248,7 +248,6 @@ static int handle_legacy_maps(struct bpf_object *obj)static int load_bpf_object (struct bpf_cfg_in *cfg) { -struct bpf_object_load_attr attr = {};struct bpf_program *p, *prog =NULL ;struct bpf_object *obj;char root_path[PATH_MAX ];@@ -305,11 +304,7 @@ static int load_bpf_object(struct bpf_cfg_in *cfg)if (ret) goto unload_obj; - attr.obj = obj; -if (cfg->verbose) - attr.log_level =2 ; - - ret =bpf_object__load_xattr (&attr); + ret =bpf_object__load (obj);if (ret) goto unload_obj;Signature · 1 line
2.24.3 (Apple Git-128)
Re: [PATCH iproute2-next 1/3] libbpf: Use bpf_object__load instead of bpf_object__load_xattr
Quoted 6 lines · Hangbin Liu
Hi David,
This patch revert
c04e45d0lib/bpf: fix verbose flag when using libbpf, Should we setprog->log_leveldirectly before it loaded, likebpf_program__set_log_level()does?
that API is new - Dec 2021 so it will not be present across relevant libbpf versions. Detecting what exists in a libbpf version and adding compat wrappers needs to be added. That's an undertaking I do not have time for at the moment. If you or someone else does it would be appreciated.
Re: [PATCH iproute2-next 1/3] libbpf: Use bpf_object__load instead of bpf_object__load_xattr
Quoted 8 lines · David Ahern
Quoted 6 lines · Hangbin Liu
Hi David,
This patch revert
c04e45d0lib/bpf: fix verbose flag when using libbpf, Should we setprog->log_leveldirectly before it loaded, likebpf_program__set_log_level()does?
Quoted 5 lines
that API is new - Dec 2021 so it will not be present across relevant libbpf versions. Detecting what exists in a libbpf version and adding compat wrappers needs to be added. That's an undertaking I do not have time for at the moment. If you or someone else does it would be appreciated.
Ah, yes, I forgot we can't set prog log_level directly. Looks we need to add a new flag similar with HAVE_LIBBPF_SECTION_NAME... It's really a pain to add more flags for libbfp...
Hi Paul, will you do that?
Thanks
Hangbin
PATCH 2/3 libbpf: Remove use of bpf_program__set_priv and bpf_program__priv
In reply to David Ahernbpf_program__set_priv and bpf_program__priv are deprecated as of libbpf v0.7+. Rather than store the map as priv on the program, change find_legacy_tail_calls to take an argument to return a reference to the map.
find_legacy_tail_calls is invoked twice from load_bpf_object - the first time to check for programs that should be loaded. In this case a reference to the map is not needed, but it does validate the map exists. The second is invoked from update_legacy_tail_call_maps where the map pointer is needed.
--- lib/bpf_libbpf.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
lib/bpf_libbpf.c +10 -6
@@ -151,7 +151,8 @@ handle_legacy_map_in_map(struct bpf_object *obj, struct bpf_map *inner_map,return ret; } -static int find_legacy_tail_calls (struct bpf_program *prog,struct bpf_object *obj) +static int find_legacy_tail_calls (struct bpf_program *prog,struct bpf_object *obj, +struct bpf_map **pmap) {unsigned int map_id, key_id;const char *sec_name;
@@ -175,8 +176,8 @@ static int find_legacy_tail_calls(struct bpf_program *prog, struct bpf_object *oif (!map)return -1 ; -/* Save the map here for later updating */ -bpf_program__set_priv (prog, map,NULL ); +if (pmap) + *pmap = map;return 0 ; }
@@ -190,8 +191,10 @@ static int update_legacy_tail_call_maps(struct bpf_object *obj)struct bpf_map *map;bpf_object__for_each_program (prog, obj) { - map =bpf_program__priv (prog); -if (!map) +/* load_bpf_object has already verified find_legacy_tail_calls +* succeeds when it should +*/ +if (find_legacy_tail_calls (prog, obj, &map) <0 )continue ; prog_fd =bpf_program__fd (prog);
@@ -275,7 +278,8 @@ static int load_bpf_object(struct bpf_cfg_in *cfg)/* Only load the programs that will either be subsequently * attached or inserted into a tail call map */ -if (find_legacy_tail_calls (p, obj) <0 && !prog_to_attach) { +if (find_legacy_tail_calls (p, obj,NULL ) <0 && + !prog_to_attach) { ret =bpf_program__set_autoload (p, false);if (ret)return -EINVAL ;
Signature · 1 line
2.24.3 (Apple Git-128)
PATCH 3/3 libbpf: Remove use of bpf_map_is_offload_neutral
In reply to David Ahernbpf_map_is_offload_neutral is deprecated as of v0.8+; import definition to maintain backwards compatibility.
--- lib/bpf_libbpf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
lib/bpf_libbpf.c +6 -1
@@ -249,6 +249,11 @@ static int handle_legacy_maps(struct bpf_object *obj)return ret; } +static bool bpf_map_is_offload_neutral (const struct bpf_map *map) +{ +return bpf_map__type (map) ==BPF_MAP_TYPE_PERF_EVENT_ARRAY ; +} +static int load_bpf_object (struct bpf_cfg_in *cfg) {struct bpf_program *p, *prog =NULL ;
@@ -294,7 +299,7 @@ static int load_bpf_object(struct bpf_cfg_in *cfg) }bpf_object__for_each_map (map, obj) { -if (!bpf_map__is_offload_neutral (map)) +if (!bpf_map_is_offload_neutral (map))bpf_map__set_ifindex (map, cfg->ifindex); }
Signature · 1 line
2.24.3 (Apple Git-128)
Quoted 10 lines · David Ahern
Another round of changes to handle libbpf deprecations. Compiles are clean as of libbpf commit
533c7666eb72("Fix downloads formats").David Ahern (3):
libbpf: Usebpf_object__loadinstead ofbpf_object__load_xattr
libbpf: Remove use ofbpf_program__set_privandbpf_program__priv
libbpf: Remove use ofbpf_map_is_offload_neutrallib/bpf_libbpf.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
For the series:
This series was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:
Hello:
This series was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:
Quoted 9 lines · On Sat, 23 Apr 2022 09:22:57 -0600 you wrote:
Another round of changes to handle libbpf deprecations. Compiles are clean as of libbpf commit
533c7666eb72("Fix downloads formats").David Ahern (3):
libbpf: Usebpf_object__loadinstead ofbpf_object__load_xattr
libbpf: Remove use ofbpf_program__set_privandbpf_program__priv
libbpf: Remove use ofbpf_map_is_offload_neutral[...]
Here is the summary with links:
- [iproute2-next,1/3] libbpf: Use bpf_object__load instead of bpf_object__load_xattr
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=ba6519cbcb28 - [iproute2-next,2/3] libbpf: Remove use of bpf_program__set_priv and bpf_program__priv https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=64e5ed779f5d - [iproute2-next,3/3] libbpf: Remove use of bpf_map_is_offload_neutral https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=837294e45252
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html