All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2] lib/bpf: fix verbose flag when using libbpf
@ 2021-12-16 15:33 Paul Chaignon
  2021-12-17  7:15 ` Hangbin Liu
  0 siblings, 1 reply; 2+ messages in thread
From: Paul Chaignon @ 2021-12-16 15:33 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger, Hangbin Liu, David Ahern

Since commit 6d61a2b55799 ("lib: add libbpf support"), passing the
verbose flag to tc filter doesn't dump the verifier logs anymore in case
of successful loading.

This commit fixes it by setting the log_level attribute before loading.
To that end, we need to call bpf_object__load_xattr directly instead of
relying on bpf_object__load.

Fixes: 6d61a2b55799 ("lib: add libbpf support")
Signed-off-by: Paul Chaignon <paul@isovalent.com>
---
 lib/bpf_libbpf.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/bpf_libbpf.c b/lib/bpf_libbpf.c
index dbec2cb5..b992a62c 100644
--- a/lib/bpf_libbpf.c
+++ b/lib/bpf_libbpf.c
@@ -246,6 +246,7 @@ 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];
@@ -302,7 +303,11 @@ static int load_bpf_object(struct bpf_cfg_in *cfg)
 	if (ret)
 		goto unload_obj;
 
-	ret = bpf_object__load(obj);
+	attr.obj = obj;
+	if (cfg->verbose) {
+		attr.log_level = 2;
+	}
+	ret = bpf_object__load_xattr(&attr);
 	if (ret)
 		goto unload_obj;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH iproute2] lib/bpf: fix verbose flag when using libbpf
  2021-12-16 15:33 [PATCH iproute2] lib/bpf: fix verbose flag when using libbpf Paul Chaignon
@ 2021-12-17  7:15 ` Hangbin Liu
  0 siblings, 0 replies; 2+ messages in thread
From: Hangbin Liu @ 2021-12-17  7:15 UTC (permalink / raw)
  To: Paul Chaignon; +Cc: netdev, Stephen Hemminger, David Ahern

On Thu, Dec 16, 2021 at 04:33:36PM +0100, Paul Chaignon wrote:
> Since commit 6d61a2b55799 ("lib: add libbpf support"), passing the
> verbose flag to tc filter doesn't dump the verifier logs anymore in case
> of successful loading.
> 
> This commit fixes it by setting the log_level attribute before loading.
> To that end, we need to call bpf_object__load_xattr directly instead of
> relying on bpf_object__load.
> 
> Fixes: 6d61a2b55799 ("lib: add libbpf support")
> Signed-off-by: Paul Chaignon <paul@isovalent.com>
> ---
>  lib/bpf_libbpf.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/bpf_libbpf.c b/lib/bpf_libbpf.c
> index dbec2cb5..b992a62c 100644
> --- a/lib/bpf_libbpf.c
> +++ b/lib/bpf_libbpf.c
> @@ -246,6 +246,7 @@ 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];
> @@ -302,7 +303,11 @@ static int load_bpf_object(struct bpf_cfg_in *cfg)
>  	if (ret)
>  		goto unload_obj;
>  
> -	ret = bpf_object__load(obj);
> +	attr.obj = obj;
> +	if (cfg->verbose) {
> +		attr.log_level = 2;
> +	}

nit: no need the curly braces when this is only 1 line

> +	ret = bpf_object__load_xattr(&attr);
>  	if (ret)
>  		goto unload_obj;
>  

Thanks for the fixes.

Acked-by: Hangbin Liu <haliu@redhat.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-17  7:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-16 15:33 [PATCH iproute2] lib/bpf: fix verbose flag when using libbpf Paul Chaignon
2021-12-17  7:15 ` Hangbin Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.