All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH iproute2-next 0/3] Address more libbpf deprecations
@ 2022-04-23 15:22 David Ahern
  2022-04-23 15:22 ` [PATCH iproute2-next 1/3] libbpf: Use bpf_object__load instead of bpf_object__load_xattr David Ahern
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: David Ahern @ 2022-04-23 15:22 UTC (permalink / raw)
  To: netdev; +Cc: stephen, toke, haliu, 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: 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(-)

-- 
2.24.3 (Apple Git-128)


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

* [PATCH iproute2-next 1/3] libbpf: Use bpf_object__load instead of bpf_object__load_xattr
  2022-04-23 15:22 [PATCH iproute2-next 0/3] Address more libbpf deprecations David Ahern
@ 2022-04-23 15:22 ` David Ahern
  2022-04-24  1:56   ` Hangbin Liu
  2022-04-23 15:22 ` [PATCH iproute2-next 2/3] libbpf: Remove use of bpf_program__set_priv and bpf_program__priv David Ahern
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: David Ahern @ 2022-04-23 15:22 UTC (permalink / raw)
  To: netdev; +Cc: stephen, toke, haliu, David Ahern

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)


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

* [PATCH iproute2-next 2/3] libbpf: Remove use of bpf_program__set_priv and bpf_program__priv
  2022-04-23 15:22 [PATCH iproute2-next 0/3] Address more libbpf deprecations David Ahern
  2022-04-23 15:22 ` [PATCH iproute2-next 1/3] libbpf: Use bpf_object__load instead of bpf_object__load_xattr David Ahern
@ 2022-04-23 15:22 ` David Ahern
  2022-04-23 15:23 ` [PATCH iproute2-next 3/3] libbpf: Remove use of bpf_map_is_offload_neutral David Ahern
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: David Ahern @ 2022-04-23 15:22 UTC (permalink / raw)
  To: netdev; +Cc: stephen, toke, haliu, David Ahern

bpf_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.

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

diff --git a/lib/bpf_libbpf.c b/lib/bpf_libbpf.c
index f723f6310c28..7dd1faf536f4 100644
--- a/lib/bpf_libbpf.c
+++ b/lib/bpf_libbpf.c
@@ -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 *o
 	if (!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;
-- 
2.24.3 (Apple Git-128)


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

* [PATCH iproute2-next 3/3] libbpf: Remove use of bpf_map_is_offload_neutral
  2022-04-23 15:22 [PATCH iproute2-next 0/3] Address more libbpf deprecations David Ahern
  2022-04-23 15:22 ` [PATCH iproute2-next 1/3] libbpf: Use bpf_object__load instead of bpf_object__load_xattr David Ahern
  2022-04-23 15:22 ` [PATCH iproute2-next 2/3] libbpf: Remove use of bpf_program__set_priv and bpf_program__priv David Ahern
@ 2022-04-23 15:23 ` David Ahern
  2022-04-23 21:35 ` [PATCH iproute2-next 0/3] Address more libbpf deprecations Toke Høiland-Jørgensen
  2022-05-02 21:50 ` patchwork-bot+netdevbpf
  4 siblings, 0 replies; 9+ messages in thread
From: David Ahern @ 2022-04-23 15:23 UTC (permalink / raw)
  To: netdev; +Cc: stephen, toke, haliu, David Ahern

bpf_map_is_offload_neutral is deprecated as of v0.8+;
import definition to maintain backwards compatibility.

Signed-off-by: David Ahern <dsahern@kernel.org>
---
 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 7dd1faf536f4..7b16ee71589d 100644
--- a/lib/bpf_libbpf.c
+++ b/lib/bpf_libbpf.c
@@ -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);
 	}
 
-- 
2.24.3 (Apple Git-128)


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

* Re: [PATCH iproute2-next 0/3] Address more libbpf deprecations
  2022-04-23 15:22 [PATCH iproute2-next 0/3] Address more libbpf deprecations David Ahern
                   ` (2 preceding siblings ...)
  2022-04-23 15:23 ` [PATCH iproute2-next 3/3] libbpf: Remove use of bpf_map_is_offload_neutral David Ahern
@ 2022-04-23 21:35 ` Toke Høiland-Jørgensen
  2022-05-02 21:50 ` patchwork-bot+netdevbpf
  4 siblings, 0 replies; 9+ messages in thread
From: Toke Høiland-Jørgensen @ 2022-04-23 21:35 UTC (permalink / raw)
  To: David Ahern, netdev; +Cc: stephen, haliu, David Ahern

David Ahern <dsahern@kernel.org> writes:

> 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(-)

For the series:

Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>


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

* Re: [PATCH iproute2-next 1/3] libbpf: Use bpf_object__load instead of bpf_object__load_xattr
  2022-04-23 15:22 ` [PATCH iproute2-next 1/3] libbpf: Use bpf_object__load instead of bpf_object__load_xattr David Ahern
@ 2022-04-24  1:56   ` Hangbin Liu
  2022-04-24 16:10     ` David Ahern
  0 siblings, 1 reply; 9+ messages in thread
From: Hangbin Liu @ 2022-04-24  1:56 UTC (permalink / raw)
  To: David Ahern; +Cc: netdev, stephen, toke, Paul Chaignon

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)
> 


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

* Re: [PATCH iproute2-next 1/3] libbpf: Use bpf_object__load instead of bpf_object__load_xattr
  2022-04-24  1:56   ` Hangbin Liu
@ 2022-04-24 16:10     ` David Ahern
  2022-04-26  2:29       ` Hangbin Liu
  0 siblings, 1 reply; 9+ messages in thread
From: David Ahern @ 2022-04-24 16:10 UTC (permalink / raw)
  To: Hangbin Liu; +Cc: netdev, stephen, toke, Paul Chaignon

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.

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

* Re: [PATCH iproute2-next 1/3] libbpf: Use bpf_object__load instead of bpf_object__load_xattr
  2022-04-24 16:10     ` David Ahern
@ 2022-04-26  2:29       ` Hangbin Liu
  0 siblings, 0 replies; 9+ messages in thread
From: Hangbin Liu @ 2022-04-26  2:29 UTC (permalink / raw)
  To: David Ahern; +Cc: netdev, stephen, toke, Paul Chaignon

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


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

* Re: [PATCH iproute2-next 0/3] Address more libbpf deprecations
  2022-04-23 15:22 [PATCH iproute2-next 0/3] Address more libbpf deprecations David Ahern
                   ` (3 preceding siblings ...)
  2022-04-23 21:35 ` [PATCH iproute2-next 0/3] Address more libbpf deprecations Toke Høiland-Jørgensen
@ 2022-05-02 21:50 ` patchwork-bot+netdevbpf
  4 siblings, 0 replies; 9+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-05-02 21:50 UTC (permalink / raw)
  To: David Ahern; +Cc: netdev, stephen, toke, haliu

Hello:

This series was applied to iproute2/iproute2-next.git (main)
by David Ahern <dsahern@kernel.org>:

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: 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
> 
> [...]

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-05-02 21:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-23 15:22 [PATCH iproute2-next 0/3] Address more libbpf deprecations David Ahern
2022-04-23 15:22 ` [PATCH iproute2-next 1/3] libbpf: Use bpf_object__load instead of bpf_object__load_xattr David Ahern
2022-04-24  1:56   ` Hangbin Liu
2022-04-24 16:10     ` David Ahern
2022-04-26  2:29       ` Hangbin Liu
2022-04-23 15:22 ` [PATCH iproute2-next 2/3] libbpf: Remove use of bpf_program__set_priv and bpf_program__priv David Ahern
2022-04-23 15:23 ` [PATCH iproute2-next 3/3] libbpf: Remove use of bpf_map_is_offload_neutral David Ahern
2022-04-23 21:35 ` [PATCH iproute2-next 0/3] Address more libbpf deprecations Toke Høiland-Jørgensen
2022-05-02 21:50 ` patchwork-bot+netdevbpf

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.