diff mbox series

[iproute2-next,1/3] libbpf: Use bpf_object__load instead of bpf_object__load_xattr

Message ID 20220423152300.16201-2-dsahern@kernel.org (mailing list archive)
State Accepted
Commit ba6519cbcb28ec8e78c5948fff580cdf5ce2df29
Delegated to: David Ahern
Headers show
Series Address more libbpf deprecations | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

David Ahern April 23, 2022, 3:22 p.m. UTC
bpf_object__load_xattr is deprecated as of v0.8+; remove it
in favor of bpf_object__load.

Signed-off-by: David Ahern <dsahern@kernel.org>
---
 lib/bpf_libbpf.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comments

Hangbin Liu April 24, 2022, 1:56 a.m. UTC | #1
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
On Sat, Apr 23, 2022 at 09:22:58AM -0600, David Ahern wrote:
> bpf_object__load_xattr is deprecated as of v0.8+; remove it
> in favor of bpf_object__load.
> 
> Signed-off-by: David Ahern <dsahern@kernel.org>
> ---
>  lib/bpf_libbpf.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
> 
> diff --git a/lib/bpf_libbpf.c b/lib/bpf_libbpf.c
> index f4f98caa1e58..f723f6310c28 100644
> --- a/lib/bpf_libbpf.c
> +++ b/lib/bpf_libbpf.c
> @@ -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;
>  
> -- 
> 2.24.3 (Apple Git-128)
>
David Ahern April 24, 2022, 4:10 p.m. UTC | #2
On 4/23/22 7:56 PM, Hangbin Liu wrote:
> 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?
> 

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.
Hangbin Liu April 26, 2022, 2:29 a.m. UTC | #3
On Sun, Apr 24, 2022 at 10:10:44AM -0600, David Ahern wrote:
> On 4/23/22 7:56 PM, Hangbin Liu wrote:
> > 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?
> > 
> 
> 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
diff mbox series

Patch

diff --git a/lib/bpf_libbpf.c b/lib/bpf_libbpf.c
index f4f98caa1e58..f723f6310c28 100644
--- a/lib/bpf_libbpf.c
+++ b/lib/bpf_libbpf.c
@@ -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;