diff options
author | Wei Yongjun <weiyongjun1@huawei.com> | 2023-04-07 08:14:26 +0000 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2023-04-07 15:28:12 -0700 |
commit | b24f0b049e706c6fc6e822dfc519ee33c3865092 (patch) | |
tree | b9608607cc6c995e338fbf47dacb7b8ef1f3d1cb /tools/bpf | |
parent | 3ebf5212bf042954666b19fe4ff5a98911b08128 (diff) | |
download | linux-b24f0b049e706c6fc6e822dfc519ee33c3865092.tar.gz linux-b24f0b049e706c6fc6e822dfc519ee33c3865092.tar.bz2 linux-b24f0b049e706c6fc6e822dfc519ee33c3865092.zip |
bpftool: Set program type only if it differs from the desired one
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>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20230407081427.2621590-1-weiyongjun@huaweicloud.com
Diffstat (limited to 'tools/bpf')
-rw-r--r-- | tools/bpf/bpftool/prog.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index 430f72306409..e5b613a7974c 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c @@ -1685,7 +1685,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); } |