[PATCH bpf-next v1] bpf/selftests: improve arg parsing in test_verifier

2023-09-25 Thread Tony Ambardar
; behaviour (run all tests) is unchanged and backwards-compatible. Updated examples: $ test_verifier die die die # previously ran all tests Usage: test_verifier -l | [-v|-vv] [ []] $ test_verifier 700 # runs test subset from 700 to end Signed-off-by: Tony Ambardar

[PATCH bpf-next v1] selftests/bpf: Fix wrong binary in Makefile log output

2024-07-19 Thread Tony Ambardar
p.bpf.o GEN-SKEL [test_progs-cpuv4] access_map_in_map.skel.h Fixes: a5d0c26a2784 ("selftests/bpf: Add a cpuv4 test runner for cpu=v4 testing") Fixes: 89ad7420b25c ("selftests/bpf: Drop the need for LLVM's llc") Signed-off-by: Tony Ambardar --- tools/testing/selfte

Re: [PATCH bpf-next v1] selftests/bpf: Fix wrong binary in Makefile log output

2024-07-19 Thread Tony Ambardar
On Fri, Jul 19, 2024 at 07:57:09PM -0700, Andrii Nakryiko wrote: > On Fri, Jul 19, 2024 at 4:22 PM Tony Ambardar wrote: > > > > Make log output incorrectly shows 'test_maps' as the binary name for every > > 'CLNG-BPF' build step, apparently

[PATCH bpf-next v2] selftests/bpf: Fix wrong binary in Makefile log output

2024-07-19 Thread Tony Ambardar
p.bpf.o GEN-SKEL [test_progs-cpuv4] access_map_in_map.skel.h Fixes: a5d0c26a2784 ("selftests/bpf: Add a cpuv4 test runner for cpu=v4 testing") Fixes: 89ad7420b25c ("selftests/bpf: Drop the need for LLVM's llc") Signed-off-by: Tony Ambardar --- tools/testing/sel

[PATCH bpf-next v1 2/2] selftests/bpf: Fix error linking uprobe_multi on mips

2024-07-21 Thread Tony Ambardar
s: 519dfeaf5119 ("selftests/bpf: Add uprobe_multi test program") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/Makefile | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index a

[PATCH bpf-next v1 0/2] selftests/bpf: Add support for MIPS systems

2024-07-21 Thread Tony Ambardar
fixes a MIPS GOT issue when linking uprobe_multi. Feedback and suggestions for improvement are welcome! Thanks, Tony Tony Ambardar (2): selftests/bpf: Add missing system defines for mips selftests/bpf: Fix error linking uprobe_multi on mips tools/testing/selftests/bpf/Makefile | 8 ++-- 1

[PATCH bpf-next v1 1/2] selftests/bpf: Add missing system defines for mips

2024-07-21 Thread Tony Ambardar
_MIPS_SIM, _ABIO32, _ABIN32, _ABI64 Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 05b234248b38..a9c447c63fee 100644 --- a

Re: [PATCH bpf-next v1 2/2] selftests/bpf: Fix error linking uprobe_multi on mips

2024-07-22 Thread Tony Ambardar
On Mon, Jul 22, 2024 at 02:22:53PM -0700, Andrii Nakryiko wrote: > On Sun, Jul 21, 2024 at 12:51 AM Tony Ambardar > wrote: [...] > > --- a/tools/testing/selftests/bpf/Makefile > > +++ b/tools/testing/selftests/bpf/Makefile > > @@ -784,9 +784,12 @@ $(OUTPUT)/verist

[PATCH bpf-next v2 0/2] selftests/bpf: Add support for MIPS systems

2024-07-22 Thread Tony Ambardar
From: Tony Ambardar Hello, This series includes two fixes to support builds targeting MIPS systems. The patches have been tested both with the kernel-patches/bpf CI and locally using mips64el-gcc/musl-libc and QEMU with an OpenWrt rootfs. Patch 1 adds support for MIPS system includes when

[PATCH bpf-next v2 2/2] selftests/bpf: Fix error linking uprobe_multi on mips

2024-07-22 Thread Tony Ambardar
From: Tony Ambardar Linking uprobe_multi.c on mips64el fails due to relocation overflows, when the GOT entries required exceeds the default maximum. Add a specific CFLAGS (-mxgot) for uprobe_multi.c on MIPS that allows using a larger GOT and avoids errors such as: /tmp/ccBTNQzv.o: in function

[PATCH bpf-next v2 1/2] selftests/bpf: Add missing system defines for mips

2024-07-22 Thread Tony Ambardar
From: Tony Ambardar Update get_sys_includes in Makefile with missing MIPS-related definitions to fix many, many compilation errors building selftests/bpf. The following added defines drive conditional logic in system headers for word-size and endianness selection: MIPSEL, MIPSEB _MIPS_SZPTR

Re: [PATCH bpf-next v1] selftests/bpf: Fix wrong binary in Makefile log output

2024-07-22 Thread Tony Ambardar
On Fri, Jul 19, 2024 at 10:23:33PM -0700, Tony Ambardar wrote: > On Fri, Jul 19, 2024 at 07:57:09PM -0700, Andrii Nakryiko wrote: > > On Fri, Jul 19, 2024 at 4:22 PM Tony Ambardar > > wrote: > > > [...] > > > --- a/tools/testing/selftests/bpf/Makefile > &

[PATCH bpf-next v1 00/19] selftests/bpf: Improve libc portability / musl support (part 1)

2024-07-22 Thread Tony Ambardar
are welcome! Thanks, Tony Tony Ambardar (19): selftests/bpf: Use pid_t consistently in test_progs.c selftests/bpf: Fix compile error from rlim_t in sk_storage_map.c selftests/bpf: Fix error compiling bpf_iter_setsockopt.c with musl libc selftests/bpf: Drop unneeded include in

[PATCH bpf-next v1 01/19] selftests/bpf: Use pid_t consistently in test_progs.c

2024-07-22 Thread Tony Ambardar
eclared identifier is reported only once for each function it appears in Fixes: 91b2c0afd00c ("selftests/bpf: Add parallelism to test_progs") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/test_progs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a

[PATCH bpf-next v1 02/19] selftests/bpf: Fix compile error from rlim_t in sk_storage_map.c

2024-07-22 Thread Tony Ambardar
| | long unsigned int | %llu cc1: all warnings being treated as errors Fixes: 51a0e301a563 ("bpf: Add BPF_MAP_TYPE_SK_STORAGE test to test_maps") Signed-off-

[PATCH bpf-next v1 03/19] selftests/bpf: Fix error compiling bpf_iter_setsockopt.c with musl libc

2024-07-22 Thread Tony Ambardar
quot;funky" transparent union which includes both types above. Explicitly cast the argument to allow compiling for both musl and glibc. Fixes: eed92afdd14c ("bpf: selftest: Test batching and bpf_(get|set)sockopt in bpf tcp iter") Signed-off-by: Tony Ambardar --- tools/testing/

[PATCH bpf-next v1 04/19] selftests/bpf: Drop unneeded include in unpriv_helpers.c

2024-07-22 Thread Tony Ambardar
ore building. Fixes: 1d56ade032a4 ("selftests/bpf: Unprivileged tests for test_loader.c") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/unpriv_helpers.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/testing/selftests/bpf/unpriv_helpers.c b/tools/testing/selfte

[PATCH bpf-next v1 05/19] selftests/bpf: Drop unneeded include in sk_lookup.c

2024-07-22 Thread Tony Ambardar
Test prog sk_lookup.c includes glibc extension '' and fails to build for non-glibc (i.e. musl) systems. However, the header is actually not needed, so remove it to allow more portable compilation. Fixes: 0ab5539f8584 ("selftests/bpf: Tests for BPF_SK_LOOKUP attach point")

[PATCH bpf-next v1 07/19] selftests/bpf: Fix missing ARRAY_SIZE() definition in bench.c

2024-07-22 Thread Tony Ambardar
for (i = 0; i < ARRAY_SIZE(benchs); i++) { | ^~ cc1: all warnings being treated as errors Fixes: 8e7c2a023ac0 ("selftests/bpf: Add benchmark runner infrastructure") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/bench.c

[PATCH bpf-next v1 06/19] selftests/bpf: Drop unneeded include in flow_dissector.c

2024-07-22 Thread Tony Ambardar
quot;) Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/prog_tests/flow_dissector.c | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/testing/selftests/bpf/prog_tests/flow_dissector.c b/tools/testing/selftests/bpf/prog_tests/flow_dissector.c index 9e5f38739104..9625e6d2179

[PATCH bpf-next v1 08/19] selftests/bpf: Fix missing UINT_MAX definitions in benchmarks

2024-07-22 Thread Tony Ambardar
de +++ |+#include 11 | seen with bench_local_storage.c, bench_local_storage_rcu_tasks_trace.c, and bench_bpf_hashmap_lookup.c. Fixes: 73087489250d ("selftests/bpf: Add benchmark for local_storage get") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/bench.h | 1 + 1 file

[PATCH bpf-next v1 09/19] selftests/bpf: Fix missing BUILD_BUG_ON() declaration

2024-07-22 Thread Tony Ambardar
426 | BUILD_BUG_ON(total_samples <= c_max_entries); | ^~~~ cc1: all warnings being treated as errors Fixes: e5a9df51c746 ("selftests/bpf: Add selftests validating the user ringbuf") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/prog

[PATCH bpf-next v1 10/19] selftests/bpf: Fix include of

2024-07-22 Thread Tony Ambardar
edirecting incorrect #include to | ^~~ cc1: all warnings being treated as errors Fixes: 09c02d553c49 ("bpf, selftests: Fold test_current_pid_tgid_new_ns into test_progs.") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c | 2 +

[PATCH bpf-next v1 11/19] selftests/bpf: Fix compiling parse_tcp_hdr_opt.c with musl-libc

2024-07-22 Thread Tony Ambardar
| ^~~~ Fixes: cfa7b011894d ("selftests/bpf: tests for using dynptrs to parse skb and xdp buffers") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/prog_tests/parse_tcp_hdr_opt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selfte

[PATCH bpf-next v1 12/19] selftests/bpf: Fix compiling kfree_skb.c with musl-libc

2024-07-22 Thread Tony Ambardar
7;: kfree_skb.c:45:30: error: 'struct tcphdr' has no member named 'doff' 45 | if (CHECK(pkt_v6->tcp.doff != 5, "check_tcp", | ^ Fixes: 580d656d80cf ("selftests/bpf: Add kfree_skb raw_tp test") Signed-off-b

[PATCH bpf-next v1 13/19] selftests/bpf: Fix compiling flow_dissector.c with musl-libc

2024-07-22 Thread Tony Ambardar
ce = 80, | ^~ flow_dissector.c:120:30: error: 'struct tcphdr' has no member named 'dest' 120 | .tcp.dest = 8080, | ^~~~ Fixes: ae173a915785 ("selftests/bpf: supp

[PATCH bpf-next v1 14/19] selftests/bpf: Fix compiling tcp_rtt.c with musl-libc

2024-07-22 Thread Tony Ambardar
age size of 'info' isn't known 24 | struct tcp_info info; | ^~~~ tcp_rtt.c:24:25: error: unused variable 'info' [-Werror=unused-variable] cc1: all warnings being treated as errors Fixes: 1f4f80fed217 ("selftests/bpf: tes

[PATCH bpf-next v1 15/19] selftests/bpf: Fix compiling core_reloc.c with musl-libc

2024-07-22 Thread Tony Ambardar
Add CO-RE relocs selftest relying on kernel module BTF") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/prog_tests/core_reloc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/bpf/prog_tests/core_reloc.c b/tools/testing/selftests/bpf/prog_tests/co

[PATCH bpf-next v1 17/19] selftests/bpf: Fix errors compiling decap_sanity.c with musl libc

2024-07-22 Thread Tony Ambardar
n of 'struct ipv6_mreq' 42 | struct ipv6_mreq { |^ .../linux/in6.h:60:8: note: originally defined here 60 | struct ipv6_mreq { |^ Fixes: 70a00e2f1dba ("selftests/bpf: Test bpf_skb_adjust_room on CHECKSUM_PARTIAL") Si

[PATCH bpf-next v1 16/19] selftests/bpf: Fix errors compiling lwt_redirect.c with musl libc

2024-07-22 Thread Tony Ambardar
;struct ipv6_mreq' 42 | struct ipv6_mreq { |^ .../linux/in6.h:60:8: note: originally defined here 60 | struct ipv6_mreq { |^ Fixes: 43a7c3ef8a15 ("selftests/bpf: Add lwt_xmit tests for BPF_REDIRECT") Signed-off-by: Tony Ambardar --- to

[PATCH bpf-next v1 18/19] selftests/bpf: Fix errors compiling crypto_sanity.c with musl libc

2024-07-22 Thread Tony Ambardar
definition of 'struct ipv6_mreq' 42 | struct ipv6_mreq { |^ .../linux/in6.h:60:8: note: originally defined here 60 | struct ipv6_mreq { |^ Fixes: 91541ab192fc ("selftests: bpf: crypto skcipher algo selftests") Signed-off-by

[PATCH bpf-next v1 19/19] selftests/bpf: Fix errors compiling cg_storage_multi.h with musl libc

2024-07-22 Thread Tony Ambardar
ixes: 9e5bd1f7633b ("selftests/bpf: Test CGROUP_STORAGE map can't be used by multiple progs") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/progs/cg_storage_multi.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/cg_storage_multi.h b/too

Re: [PATCH bpf-next v1 19/19] selftests/bpf: Fix errors compiling cg_storage_multi.h with musl libc

2024-07-24 Thread Tony Ambardar
On Tue, Jul 23, 2024 at 03:35:22PM -0700, YiFei Zhu wrote: > On Mon, Jul 22, 2024 at 10:56 PM Tony Ambardar > wrote: > > > > Remove a redundant include of '', whose needed definitions are > > already included (via '') in cg_storage_multi_egress_

Re: [PATCH bpf-next v1 00/19] selftests/bpf: Improve libc portability / musl support (part 1)

2024-07-24 Thread Tony Ambardar
Hi Andrii, On Wed, Jul 24, 2024 at 04:52:57PM -0700, Andrii Nakryiko wrote: > On Mon, Jul 22, 2024 at 10:55 PM Tony Ambardar > wrote: [...] > > > > Tony Ambardar (19): > > selftests/bpf: Use pid_t consistently in test_progs.c > > selftests/bpf: Fi

Re: [PATCH bpf-next v1 07/19] selftests/bpf: Fix missing ARRAY_SIZE() definition in bench.c

2024-07-24 Thread Tony Ambardar
On Wed, Jul 24, 2024 at 03:08:31PM +0800, Geliang Tang wrote: > On Mon, 2024-07-22 at 22:54 -0700, Tony Ambardar wrote: > > Add a "bpf_util.h" include to avoid the following error seen > > compiling for > > mips64el with musl libc: > > > >   bench.c:

[PATCH bpf-next v1 0/8] selftests/bpf: Improve libc portability / musl support (part 2)

2024-07-25 Thread Tony Ambardar
From: Tony Ambardar Hello all, This is part 2 of a series of fixes for libc-related issues encountered building for musl-based systems. The series has been tested with the kernel-patches/bpf CI and locally using mips64el-gcc/musl-libc and QEMU with an OpenWrt rootfs. The patches cover a few

[PATCH bpf-next v1 1/8] selftests/bpf: Use portable POSIX basename()

2024-07-25 Thread Tony Ambardar
From: Tony Ambardar Use the POSIX version of basename() to allow compilation against non-gnu libc (e.g. musl). Include ahead of to enable using functions from the latter while preferring POSIX over GNU basename(). In veristat.c, rely on strdupa() to avoid basename() altering the passed "

[PATCH bpf-next v1 2/8] selftests/bpf: Fix arg parsing in veristat, test_progs

2024-07-25 Thread Tony Ambardar
From: Tony Ambardar Current code parses arguments with strtok_r() using a construct like char *state = NULL; while ((next = strtok_r(state ? NULL : input, ",", &state))) { ... } where logic assumes the 'state' var can distinguish between first

[PATCH bpf-next v1 3/8] selftests/bpf: Fix error compiling test_lru_map.c

2024-07-25 Thread Tony Ambardar
From: Tony Ambardar Although the post-increment in macro 'CPU_SET(next++, &cpuset)' seems safe, the sequencing can raise compile errors, so move the increment outside the macro. This avoids an error seen using gcc 12.3.0 for mips64el/musl-libc: In file included from tes

[PATCH bpf-next v1 4/8] selftests/bpf: Fix C++ compile error from missing _Bool type

2024-07-25 Thread Tony Ambardar
From: Tony Ambardar While building, bpftool makes a skeleton from test_core_extern.c, which itself includes and uses the 'bool' type. However, the skeleton test_core_extern.skel.h generated *does not* include or use the 'bool' type, instead using the C-only '_Bool'

[PATCH bpf-next v1 5/8] selftests/bpf: Fix order-of-include compile errors in lwt_reroute.c

2024-07-25 Thread Tony Ambardar
From: Tony Ambardar Fix redefinition errors seen compiling lwt_reroute.c for mips64el/musl-libc by adjusting the order of includes in lwt_helpers.h. The ordering required is: --> (from "test_progs.h") --> . Because of the complexity and large number of includes, orderi

[PATCH bpf-next v1 6/8] selftests/bpf: Fix compile if backtrace support missing in libc

2024-07-25 Thread Tony Ambardar
From: Tony Ambardar Use backtrace functions only with glibc and otherwise provide stubs in test_progs.c. This avoids compile errors (e.g. with musl libc) like: test_progs.c:13:10: fatal error: execinfo.h: No such file or directory 13 | #include /* backtrace

[PATCH bpf-next v1 7/8] selftests/bpf: Fix using stdout, stderr as struct field names

2024-07-25 Thread Tony Ambardar
From: Tony Ambardar Typically stdin, stdout, stderr are treated as reserved identifiers under ISO/ANSI C, and a libc implementation is free to define these as macros. This is the case in musl libc and results in compile errors when these names are reused as struct fields, as with 's

[PATCH bpf-next v1 8/8] selftests/bpf: Fix error compiling tc_redirect.c with musl libc

2024-07-25 Thread Tony Ambardar
From: Tony Ambardar Linux 5.1 implemented 64-bit time types and related syscalls to address the Y2038 problem generally across archs. Userspace handling of Y2038 varies with the libc however. While musl libc uses 64-bit time across all 32-bit and 64-bit platforms, GNU glibc uses 64-bit time on

Re: [PATCH bpf-next v1 2/8] selftests/bpf: Fix arg parsing in veristat, test_progs

2024-07-26 Thread Tony Ambardar
On Thu, Jul 25, 2024 at 01:09:24PM -0700, Andrii Nakryiko wrote: > On Thu, Jul 25, 2024 at 3:39 AM Tony Ambardar wrote: > > ... > > --- a/tools/testing/selftests/bpf/testing_helpers.c > > +++ b/tools/testing/selftests/bpf/testing_helpers.c > > @@ -227,7 +227,7 @@ int

Re: [PATCH bpf-next v1 6/8] selftests/bpf: Fix compile if backtrace support missing in libc

2024-07-26 Thread Tony Ambardar
On Thu, Jul 25, 2024 at 01:22:37PM -0700, Andrii Nakryiko wrote: > On Thu, Jul 25, 2024 at 3:39 AM Tony Ambardar wrote: > > > > From: Tony Ambardar > > > > Use backtrace functions only with glibc and otherwise provide stubs in > > test_progs.c. This avoids co

Re: [PATCH bpf-next v1 5/8] selftests/bpf: Fix order-of-include compile errors in lwt_reroute.c

2024-07-26 Thread Tony Ambardar
On Thu, Jul 25, 2024 at 01:18:04PM -0700, Andrii Nakryiko wrote: > On Thu, Jul 25, 2024 at 3:39 AM Tony Ambardar wrote: > > > > From: Tony Ambardar > > > > Fix redefinition errors seen compiling lwt_reroute.c for mips64el/musl-libc > > by adjusting the order

Re: [PATCH bpf-next v1 7/8] selftests/bpf: Fix using stdout, stderr as struct field names

2024-07-26 Thread Tony Ambardar
On Thu, Jul 25, 2024 at 01:27:03PM -0700, Andrii Nakryiko wrote: > On Thu, Jul 25, 2024 at 3:39 AM Tony Ambardar wrote: > > > > From: Tony Ambardar > > > > Typically stdin, stdout, stderr are treated as reserved identifiers under > > ISO/ANSI C, and a libc imple

Re: [PATCH bpf-next v1 7/8] selftests/bpf: Fix using stdout, stderr as struct field names

2024-07-29 Thread Tony Ambardar
On Fri, Jul 26, 2024 at 09:22:38PM -0700, Tony Ambardar wrote: > On Thu, Jul 25, 2024 at 01:27:03PM -0700, Andrii Nakryiko wrote: > > On Thu, Jul 25, 2024 at 3:39 AM Tony Ambardar > > wrote: > > > > > > From: Tony Ambardar > > > > > > Typi

[PATCH bpf-next v2 0/8] selftests/bpf: Improve libc portability / musl support (part 2)

2024-07-29 Thread Tony Ambardar
appreciated! Thanks, Tony Changelog: -- v1->v2: (feedback from Andrii) - P2: rewrite simpler code using counter - P5: update description/fix after more research - P6: use weak functions for backtrace stubs - P7: use stdxxx_saved names, update desc Tony Ambardar (8): selftests/bpf:

[PATCH bpf-next v2 1/8] selftests/bpf: Use portable POSIX basename()

2024-07-29 Thread Tony Ambardar
ment. This is not needed in xskxceiver.c since the arg is mutable and the program exits immediately after usage. Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/veristat.c | 8 +--- tools/testing/selftests/bpf/xskxceiver.c | 1 + 2 files changed, 6 insertions(+), 3 deletion

[PATCH bpf-next v2 2/8] selftests/bpf: Fix arg parsing in veristat, test_progs

2024-07-29 Thread Tony Ambardar
Rewrite code using a counter to distinguish between strtok_r() calls. Fixes: 61ddff373ffa ("selftests/bpf: Improve by-name subtest selection logic in prog_tests") Fixes: 394169b079b5 ("selftests/bpf: add comparison mode to veristat") Fixes: c8bc5e050976 ("selftests/bpf: Add

[PATCH bpf-next v2 3/8] selftests/bpf: Fix error compiling test_lru_map.c

2024-07-29 Thread Tony Ambardar
errors Fixes: 3fbfadce6012 ("bpf: Fix test_lru_sanity5() in test_lru_map.c") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/test_lru_map.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_lru_map.c b/tools/testing/selftests/bpf/test_l

[PATCH bpf-next v2 4/8] selftests/bpf: Fix C++ compile error from missing _Bool type

2024-07-29 Thread Tony Ambardar
rrect type/include supporting C++, but in the meantime add a conditional define as above. Fixes: 7c8dce4b1661 ("bpftool: Make skeleton C code compilable with C++ compiler") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/test_cpp.cpp | 4 1 file changed, 4 insertions(+)

[PATCH bpf-next v2 5/8] selftests/bpf: Fix redefinition errors compiling lwt_reroute.c

2024-07-29 Thread Tony Ambardar
back for unsupported libcs") [2]: https://git.musl-libc.org/cgit/musl/commit/?id=04983f227238 Fixes: 6c77997bc639 ("selftests/bpf: Add lwt_xmit tests for BPF_REROUTE") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/prog_tests/lwt_reroute.c | 1 + 1 file changed, 1

[PATCH bpf-next v2 6/8] selftests/bpf: Fix compile if backtrace support missing in libc

2024-07-29 Thread Tony Ambardar
/bpf: Print backtrace on SIGSEGV in test_progs") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/test_progs.c | 16 +++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c

[PATCH bpf-next v2 7/8] selftests/bpf: Fix using stdout, stderr as struct field names

2024-07-29 Thread Tony Ambardar
tion 'fprintf' 237 | fprintf(env.stdout, "#%-*d %s:", TEST_NUM_WIDTH, test->test_num, test->test_name); | ^~~ Link: https://lore.kernel.org/bpf/ZqR2DuHdBXPX%2Fyx8@kodidev-ubuntu/ Signed-off-by: Tony Ambardar --- .../selftests/bpf/

[PATCH bpf-next v2 8/8] selftests/bpf: Fix error compiling tc_redirect.c with musl libc

2024-07-29 Thread Tony Ambardar
e the Y2038 roll-over. Fixes: ce6f6cffaeaa ("selftests/bpf: Wait for the netstamp_needed_key static key to be turned on") Fixes: c803475fd8dd ("bpf: selftests: test skb->tstamp in redirect_neigh") Signed-off-by: Tony Ambardar --- tools/testing/selftests/bpf/prog_tests/tc

[PATCH bpf-next v1 0/8] libbpf, selftests/bpf: Support cross-endian usage

2024-08-21 Thread Tony Ambardar
thread includes some background regarding testing on QEMU/s390x and the generally favourable results (3 failures running test_progs): https://lore.kernel.org/bpf/ZsEcsaa3juxxQBUf@kodidev-ubuntu/ Feedback and suggestions are welcome! Best regards, Tony Tony Ambardar (8): libbpf: Improve log

[PATCH bpf-next v1 1/8] libbpf: Improve log message formatting

2024-08-21 Thread Tony Ambardar
Fix missing newlines and extraneous terminal spaces in messages. Signed-off-by: Tony Ambardar --- tools/lib/bpf/btf.c | 6 +++--- tools/lib/bpf/btf_dump.c | 2 +- tools/lib/bpf/btf_relocate.c | 2 +- tools/lib/bpf/libbpf.c | 4 ++-- tools/lib/bpf/relo_core.c| 2 +- 5

[PATCH bpf-next v1 2/8] libbpf: Fix header comment typos for BTF.ext

2024-08-21 Thread Tony Ambardar
Mention struct btf_ext_info_sec rather than non-existent btf_sec_func_info in BTF.ext struct documentation. Signed-off-by: Tony Ambardar --- tools/lib/bpf/libbpf_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf

[PATCH bpf-next v1 3/8] libbpf: Fix output .symtab byte-order during linking

2024-08-21 Thread Tony Ambardar
rectly translated. Fixes: faf6ed321cf6 ("libbpf: Add BPF static linker APIs") Signed-off-by: Tony Ambardar --- tools/lib/bpf/linker.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c index 9cd3d4109788..7489306cd6f7 100644 --- a/tools/l

[PATCH bpf-next v1 4/8] libbpf: Support BTF.ext loading and output in either endianness

2024-08-21 Thread Tony Ambardar
exist for BTF data. [1]:commit 3289959b97ca ("libbpf: Support BTF loading and raw data output in both endianness") [2]:commit 8fd27bf69b86 ("libbpf: Add BPF static linker BTF and BTF.ext support") Signed-off-by: Tony Ambardar --- tools/lib/bpf/btf

[PATCH bpf-next v1 5/8] libbpf: Support opening bpf objects of either endianness

2024-08-21 Thread Tony Ambardar
Allow bpf_object__open() to access files of either endianness, and convert included BPF programs to native byte-order in-memory for introspection. Signed-off-by: Tony Ambardar --- tools/lib/bpf/libbpf.c | 21 +++-- tools/lib/bpf/libbpf_internal.h | 11 +++ 2

[PATCH bpf-next v1 6/8] libbpf: Support linking bpf objects of either endianness

2024-08-21 Thread Tony Ambardar
. This is enabled by built-in ELF translation and recent BTF/BTF.ext endianness functions. Further add local functions for swapping byte-order of sections containing BPF insns. Signed-off-by: Tony Ambardar --- tools/lib/bpf/linker.c | 106 ++--- 1 file changed

[PATCH bpf-next v1 7/8] libbpf: Support creating light skeleton of either endianness

2024-08-21 Thread Tony Ambardar
to target byte-order on finalization. Add support functions to convert data to target endianness as it is added to the blob. Also add additional debug logging for data blob structure details and skeleton loading. Signed-off-by: Tony Ambardar --- tools/lib/bpf/bpf_gen_internal.h | 1 + too

[PATCH bpf-next v1 8/8] selftests/bpf: Support cross-endian building

2024-08-21 Thread Tony Ambardar
Update Makefile build rules to compile BPF programs with target endianness rather than host byte-order. With recent changes, this allows building the full selftests/bpf suite hosted on x86_64 and targeting s390x or mips64eb for example. Signed-off-by: Tony Ambardar --- tools/testing/selftests

Re: [PATCH bpf-next v1 5/8] libbpf: Support opening bpf objects of either endianness

2024-08-22 Thread Tony Ambardar
On Wed, Aug 21, 2024 at 06:55:58PM -0700, Alexei Starovoitov wrote: > On Wed, Aug 21, 2024 at 2:10 AM Tony Ambardar wrote: > > > > > > +static inline void bpf_insn_bswap(struct bpf_insn *insn) > > +{ > > + /* dst_reg & src_reg nibbles */ > > +

[PATCH bpf-next v2 1/8] libbpf: Improve log message formatting

2024-08-22 Thread Tony Ambardar
From: Tony Ambardar Fix missing newlines and extraneous terminal spaces in messages. Signed-off-by: Tony Ambardar --- tools/lib/bpf/btf.c | 7 --- tools/lib/bpf/btf_dump.c | 2 +- tools/lib/bpf/btf_relocate.c | 2 +- tools/lib/bpf/libbpf.c | 4 ++-- tools/lib/bpf

[PATCH bpf-next v2 0/8] libbpf, selftests/bpf: Support cross-endian usage

2024-08-22 Thread Tony Ambardar
From: Tony Ambardar Hello all, This patch series targets a long-standing BPF usability issue - the lack of general cross-compilation support - by enabling cross-endian usage of libbpf and bpftool, as well as supporting cross-endian build targets for selftests/bpf. Benefits include improved BPF

[PATCH bpf-next v2 2/8] libbpf: Fix header comment typos for BTF.ext

2024-08-22 Thread Tony Ambardar
From: Tony Ambardar Mention struct btf_ext_info_sec rather than non-existent btf_sec_func_info in BTF.ext struct documentation. Signed-off-by: Tony Ambardar --- tools/lib/bpf/libbpf_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/lib/bpf

[PATCH bpf-next v2 3/8] libbpf: Fix output .symtab byte-order during linking

2024-08-22 Thread Tony Ambardar
From: Tony Ambardar Object linking output data uses the default ELF_T_BYTE type for '.symtab' section data, which disables any libelf-based translation. Explicitly set the ELF_T_SYM type for output to restore libelf's byte-order conversion, noting that input '.symtab'

[PATCH bpf-next v2 5/8] libbpf: Support opening bpf objects of either endianness

2024-08-22 Thread Tony Ambardar
From: Tony Ambardar Allow bpf_object__open() to access files of either endianness, and convert included BPF programs to native byte-order in-memory for introspection. Signed-off-by: Tony Ambardar --- tools/lib/bpf/libbpf.c | 21 +++-- tools/lib/bpf/libbpf_internal.h

[PATCH bpf-next v2 6/8] libbpf: Support linking bpf objects of either endianness

2024-08-22 Thread Tony Ambardar
From: Tony Ambardar Allow static linking object files of either endianness, checking that input files have consistent byte-order, and setting output endianness from input. Linking requires in-memory processing of programs, relocations, sections, etc. in native endianness, and output conversion

[PATCH bpf-next v2 7/8] libbpf: Support creating light skeleton of either endianness

2024-08-22 Thread Tony Ambardar
From: Tony Ambardar Track target endianness in 'struct bpf_gen' and process in-memory data in native byte-order, but on finalization convert the embedded loader BPF insns to target endianness. The light skeleton also includes a target-accessed data blob which is heterogeneous and thus

[PATCH bpf-next v2 4/8] libbpf: Support BTF.ext loading and output in either endianness

2024-08-22 Thread Tony Ambardar
From: Tony Ambardar Support for handling BTF data of either endianness was added in [1], but did not include BTF.ext data for lack of use cases. Later, support for static linking [2] provided a use case, but this feature and later ones were restricted to native-endian usage. Add support for

[PATCH bpf-next v2 8/8] selftests/bpf: Support cross-endian building

2024-08-22 Thread Tony Ambardar
From: Tony Ambardar Update Makefile build rules to compile BPF programs with target endianness rather than host byte-order. With recent changes, this allows building the full selftests/bpf suite hosted on x86_64 and targeting s390x or mips64eb for example. Signed-off-by: Tony Ambardar

Re: [PATCH bpf-next v2 1/8] libbpf: Improve log message formatting

2024-08-26 Thread Tony Ambardar
On Thu, Aug 22, 2024 at 04:36:13PM -0700, Andrii Nakryiko wrote: > On Thu, Aug 22, 2024 at 2:24 AM Tony Ambardar wrote: > > > > From: Tony Ambardar > > > > Fix missing newlines and extraneous terminal spaces in messages. > > > > Signed-off-by: Tony Amb

Re: [PATCH bpf-next v2 5/8] libbpf: Support opening bpf objects of either endianness

2024-08-26 Thread Tony Ambardar
On Fri, Aug 23, 2024 at 12:47:47PM -0700, Andrii Nakryiko wrote: > On Thu, Aug 22, 2024 at 2:25 AM Tony Ambardar wrote: > > > > From: Tony Ambardar > > > > Allow bpf_object__open() to access files of either endianness, and convert > > included BPF programs t

Re: [PATCH bpf-next v2 6/8] libbpf: Support linking bpf objects of either endianness

2024-08-26 Thread Tony Ambardar
On Fri, Aug 23, 2024 at 12:47:52PM -0700, Andrii Nakryiko wrote: > On Thu, Aug 22, 2024 at 2:25 AM Tony Ambardar wrote: > > > > From: Tony Ambardar > > > > Allow static linking object files of either endianness, checking that input > > files have consiste

Re: [PATCH bpf-next v2 7/8] libbpf: Support creating light skeleton of either endianness

2024-08-26 Thread Tony Ambardar
On Fri, Aug 23, 2024 at 12:47:56PM -0700, Andrii Nakryiko wrote: > On Thu, Aug 22, 2024 at 2:25 AM Tony Ambardar wrote: > > > > From: Tony Ambardar > > > > Track target endianness in 'struct bpf_gen' and process in-memory data in > > native byte-orde

Re: [PATCH bpf-next v2 5/8] libbpf: Support opening bpf objects of either endianness

2024-08-27 Thread Tony Ambardar
On Mon, Aug 26, 2024 at 02:28:17PM -0700, Andrii Nakryiko wrote: > On Mon, Aug 26, 2024 at 3:53 AM Tony Ambardar wrote: > > > > On Fri, Aug 23, 2024 at 12:47:47PM -0700, Andrii Nakryiko wrote: > > > On Thu, Aug 22, 2024 at 2:25 AM Tony Ambardar > > > wrote: &g

Re: [PATCH bpf-next v2 7/8] libbpf: Support creating light skeleton of either endianness

2024-08-27 Thread Tony Ambardar
On Mon, Aug 26, 2024 at 02:25:27PM -0700, Andrii Nakryiko wrote: > On Mon, Aug 26, 2024 at 3:58 AM Tony Ambardar wrote: > > > > On Fri, Aug 23, 2024 at 12:47:56PM -0700, Andrii Nakryiko wrote: > > > On Thu, Aug 22, 2024 at 2:25 AM Tony Ambardar > > > wrote: &g

[PATCH bpf-next v3 0/8] libbpf, selftests/bpf: Support cross-endian usage

2024-08-28 Thread Tony Ambardar
formatting noted by checkpatch warnings - unexpected 'test_progs' failures drop 3 -> 2 (x86_64 to s390x cross) Tony Ambardar (8): libbpf: Improve log message formatting libbpf: Fix header comment typos for BTF.ext libbpf: Fix output .symtab byte-order during linking libbpf: Sup

[PATCH bpf-next v3 1/8] libbpf: Improve log message formatting

2024-08-28 Thread Tony Ambardar
Fix missing newlines and extraneous terminal spaces in messages. Signed-off-by: Tony Ambardar --- tools/lib/bpf/btf.c | 6 +++--- tools/lib/bpf/btf_dump.c | 2 +- tools/lib/bpf/btf_relocate.c | 2 +- tools/lib/bpf/libbpf.c | 4 ++-- tools/lib/bpf/relo_core.c| 2 +- 5

[PATCH bpf-next v3 3/8] libbpf: Fix output .symtab byte-order during linking

2024-08-28 Thread Tony Ambardar
rectly translated. Fixes: faf6ed321cf6 ("libbpf: Add BPF static linker APIs") Signed-off-by: Tony Ambardar --- tools/lib/bpf/linker.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c index 9cd3d4109788..7489306cd6f7 100644 --- a/tools/l

[PATCH bpf-next v3 2/8] libbpf: Fix header comment typos for BTF.ext

2024-08-28 Thread Tony Ambardar
Mention struct btf_ext_info_sec rather than non-existent btf_sec_func_info in BTF.ext struct documentation. Signed-off-by: Tony Ambardar --- tools/lib/bpf/libbpf_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf

[PATCH bpf-next v3 4/8] libbpf: Support BTF.ext loading and output in either endianness

2024-08-28 Thread Tony Ambardar
exist for BTF data. [1] 3289959b97ca ("libbpf: Support BTF loading and raw data output in both endianness") [2] 8fd27bf69b86 ("libbpf: Add BPF static linker BTF and BTF.ext support") Signed-off-by: Tony Ambardar --- tools/lib/bpf/btf.c | 226 +++

[PATCH bpf-next v3 5/8] libbpf: Support opening bpf objects of either endianness

2024-08-28 Thread Tony Ambardar
Allow bpf_object__open() to access files of either endianness, and convert included BPF programs to native byte-order in-memory for introspection. Loading BPF objects of non-native byte-order is still disallowed however. Signed-off-by: Tony Ambardar --- tools/lib/bpf/libbpf.c | 34

[PATCH bpf-next v3 6/8] libbpf: Support linking bpf objects of either endianness

2024-08-28 Thread Tony Ambardar
. This is enabled by built-in ELF translation and recent BTF/BTF.ext endianness functions. Further add local functions for swapping byte-order of sections containing BPF insns. Signed-off-by: Tony Ambardar --- tools/lib/bpf/linker.c | 90 ++ 1 file changed

[PATCH bpf-next v3 7/8] libbpf: Support creating light skeleton of either endianness

2024-08-28 Thread Tony Ambardar
to target byte-order on finalization. Add support functions to convert data to target endianness as it is added to the blob. Also add additional debug logging for data blob structure details and skeleton loading. Signed-off-by: Tony Ambardar --- tools/lib/bpf/bpf_gen_internal.h | 1 + too

[PATCH bpf-next v3 8/8] selftests/bpf: Support cross-endian building

2024-08-28 Thread Tony Ambardar
Update Makefile build rules to compile BPF programs with target endianness rather than host byte-order. With recent changes, this allows building the full selftests/bpf suite hosted on x86_64 and targeting s390x or mips64eb for example. Signed-off-by: Tony Ambardar --- tools/testing/selftests

Re: [PATCH bpf-next v3 0/8] libbpf, selftests/bpf: Support cross-endian usage

2024-08-28 Thread Tony Ambardar
On Wed, Aug 28, 2024 at 04:11:50AM -0700, Tony Ambardar wrote: > Hello all, [snip] > Changelog: > - > v2 -> v3: (feedback from Andrii) > - improve some log and commit message formatting > - restructure BTF.ext endianness safety checks and byte-swapping > -

[PATCH bpf-next v4 8/8] selftests/bpf: Support cross-endian building

2024-08-30 Thread Tony Ambardar
Update Makefile build rules to compile BPF programs with target endianness rather than host byte-order. With recent changes, this allows building the full selftests/bpf suite hosted on x86_64 and targeting s390x or mips64eb for example. Signed-off-by: Tony Ambardar --- tools/testing/selftests

[PATCH bpf-next v4 6/8] libbpf: Support linking bpf objects of either endianness

2024-08-30 Thread Tony Ambardar
. This is enabled by built-in ELF translation and recent BTF/BTF.ext endianness functions. Further add local functions for swapping byte-order of sections containing BPF insns. Signed-off-by: Tony Ambardar --- tools/lib/bpf/linker.c | 90 ++ 1 file changed

[PATCH bpf-next v4 7/8] libbpf: Support creating light skeleton of either endianness

2024-08-30 Thread Tony Ambardar
to target byte-order on finalization. Add support functions to convert data to target endianness as it is added to the blob. Also add additional debug logging for data blob structure details and skeleton loading. Signed-off-by: Tony Ambardar --- tools/lib/bpf/bpf_gen_internal.h | 1 + too

[PATCH bpf-next v4 3/8] libbpf: Fix output .symtab byte-order during linking

2024-08-30 Thread Tony Ambardar
rectly translated. Fixes: faf6ed321cf6 ("libbpf: Add BPF static linker APIs") Signed-off-by: Tony Ambardar --- tools/lib/bpf/linker.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c index 9cd3d4109788..7489306cd6f7 100644 --- a/tools/l

[PATCH bpf-next v4 0/8] libbpf, selftests/bpf: Support cross-endian usage

2024-08-30 Thread Tony Ambardar
fixed a light skeleton bug causing test_progs 'map_ptr' failure - simplified some BTF.ext related endianness logic - remove an 'inline' usage related to CI checkpatch failure - improve some formatting noted by checkpatch warnings - unexpected 'test_progs' failures

[PATCH bpf-next v4 1/8] libbpf: Improve log message formatting

2024-08-30 Thread Tony Ambardar
Fix missing newlines and extraneous terminal spaces in messages. Signed-off-by: Tony Ambardar --- tools/lib/bpf/btf.c | 6 +++--- tools/lib/bpf/btf_dump.c | 2 +- tools/lib/bpf/btf_relocate.c | 2 +- tools/lib/bpf/libbpf.c | 4 ++-- tools/lib/bpf/relo_core.c| 2 +- 5

[PATCH bpf-next v4 2/8] libbpf: Fix header comment typos for BTF.ext

2024-08-30 Thread Tony Ambardar
Mention struct btf_ext_info_sec rather than non-existent btf_sec_func_info in BTF.ext struct documentation. Signed-off-by: Tony Ambardar --- tools/lib/bpf/libbpf_internal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf

  1   2   >