bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpftool: set program type only if it differs from the desired one
@ 2023-04-07  8:14 Wei Yongjun
  2023-04-07 22:30 ` patchwork-bot+netdevbpf
  2023-04-09 21:21 ` Quentin Monnet
  0 siblings, 2 replies; 3+ messages in thread
From: Wei Yongjun @ 2023-04-07  8:14 UTC (permalink / raw)
  To: Andrii Nakryiko, Quentin Monnet, Alexei Starovoitov,
	Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa
  Cc: Wei Yongjun, bpf

From: Wei Yongjun <weiyongjun1@huawei.com>

After commit d6e6286a12e7 ("libbpf: disassociate section handler on explicit
bpf_program__set_type() call"), bpf_program__set_type() will force cleanup
the program's SEC() definition, this commit fixed the test helper but missed
the bpftool, which leads to bpftool prog autoattach broken as follows:

  $ bpftool prog load spi-xfer-r1v1.o /sys/fs/bpf/test autoattach
  Program spi_xfer_r1v1 does not support autoattach, falling back to pinning

This patch fix bpftool to set program type only if it differs.

Fixes: d6e6286a12e7 ("libbpf: disassociate section handler on explicit bpf_program__set_type() call")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 tools/bpf/bpftool/prog.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index afbe3ec342c8..9b377db08597 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -1681,7 +1681,8 @@ static int load_with_options(int argc, char **argv, bool first_prog_only)
 		}
 
 		bpf_program__set_ifindex(pos, ifindex);
-		bpf_program__set_type(pos, prog_type);
+		if (bpf_program__type(pos) != prog_type)
+			bpf_program__set_type(pos, prog_type);
 		bpf_program__set_expected_attach_type(pos, expected_attach_type);
 	}
 
-- 
2.34.1


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

* Re: [PATCH bpf-next] bpftool: set program type only if it differs from the desired one
  2023-04-07  8:14 [PATCH bpf-next] bpftool: set program type only if it differs from the desired one Wei Yongjun
@ 2023-04-07 22:30 ` patchwork-bot+netdevbpf
  2023-04-09 21:21 ` Quentin Monnet
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-04-07 22:30 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: andrii, quentin, ast, daniel, martin.lau, song, yhs,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, weiyongjun1, bpf

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Fri,  7 Apr 2023 08:14:26 +0000 you wrote:
> From: Wei Yongjun <weiyongjun1@huawei.com>
> 
> After commit d6e6286a12e7 ("libbpf: disassociate section handler on explicit
> bpf_program__set_type() call"), bpf_program__set_type() will force cleanup
> the program's SEC() definition, this commit fixed the test helper but missed
> the bpftool, which leads to bpftool prog autoattach broken as follows:
> 
> [...]

Here is the summary with links:
  - [bpf-next] bpftool: set program type only if it differs from the desired one
    https://git.kernel.org/bpf/bpf-next/c/b24f0b049e70

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] 3+ messages in thread

* Re: [PATCH bpf-next] bpftool: set program type only if it differs from the desired one
  2023-04-07  8:14 [PATCH bpf-next] bpftool: set program type only if it differs from the desired one Wei Yongjun
  2023-04-07 22:30 ` patchwork-bot+netdevbpf
@ 2023-04-09 21:21 ` Quentin Monnet
  1 sibling, 0 replies; 3+ messages in thread
From: Quentin Monnet @ 2023-04-09 21:21 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: Andrii Nakryiko, Alexei Starovoitov, Daniel Borkmann,
	Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend,
	KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa, Wei Yongjun,
	bpf

On Fri, 7 Apr 2023 at 08:48, Wei Yongjun <weiyongjun@huaweicloud.com> wrote:
>
> From: Wei Yongjun <weiyongjun1@huawei.com>
>
> After commit d6e6286a12e7 ("libbpf: disassociate section handler on explicit
> bpf_program__set_type() call"), bpf_program__set_type() will force cleanup
> the program's SEC() definition, this commit fixed the test helper but missed
> the bpftool, which leads to bpftool prog autoattach broken as follows:
>
>   $ bpftool prog load spi-xfer-r1v1.o /sys/fs/bpf/test autoattach
>   Program spi_xfer_r1v1 does not support autoattach, falling back to pinning
>
> This patch fix bpftool to set program type only if it differs.
>
> Fixes: d6e6286a12e7 ("libbpf: disassociate section handler on explicit bpf_program__set_type() call")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

I'm late, but for the record:

Acked-by: Quentin Monnet <quentin@isovalent.com>

Thank you!

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

end of thread, other threads:[~2023-04-09 21:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-07  8:14 [PATCH bpf-next] bpftool: set program type only if it differs from the desired one Wei Yongjun
2023-04-07 22:30 ` patchwork-bot+netdevbpf
2023-04-09 21:21 ` Quentin Monnet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).