Jesper Dangaard Brouer
095641817e
selftests/bpf: Fix check_mtu using wrong variable type
...
Dan Carpenter found via Smatch static checker, that unsigned 'mtu_lo' is
never less than zero.
Variable mtu_lo should have been an 'int', because read_mtu_device_lo()
uses minus as error indications.
Fixes: b62eba5632 ("selftests/bpf: Tests using bpf_check_mtu BPF-helper")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org >
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Reviewed-by: Simon Horman <simon.horman@corigine.com >
Link: https://lore.kernel.org/bpf/168605104733.3636467.17945947801753092590.stgit@firesoul
2023-06-06 17:08:22 +02:00
Ilya Leoshkevich
c5a237a4db
selftests/bpf: Use bpf_{btf,link,map,prog}_get_info_by_fd()
...
Use the new type-safe wrappers around bpf_obj_get_info_by_fd().
Fix a prog/map mixup in prog_holds_map().
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Link: https://lore.kernel.org/bpf/20230214231221.249277-6-iii@linux.ibm.com
2023-02-16 15:32:46 -08:00
Delyan Kratunov
3931618378
selftests/bpf: Migrate from bpf_prog_test_run_xattr
...
bpf_prog_test_run_xattr is being deprecated in favor of the OPTS-based
bpf_prog_test_run_opts.
We end up unable to use CHECK_ATTR so replace usages with ASSERT_* calls.
Also, prog_run_xattr is now prog_run_opts.
Signed-off-by: Delyan Kratunov <delyank@fb.com >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Link: https://lore.kernel.org/bpf/20220202235423.1097270-3-delyank@fb.com
2022-02-02 22:31:18 -08:00
Yucong Sun
d3f7b1664d
selfetest/bpf: Make some tests serial
...
Change tests that often fails in parallel execution mode to serial.
Signed-off-by: Yucong Sun <sunyucong@gmail.com >
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Link: https://lore.kernel.org/bpf/20211006185619.364369-15-fallentree@fb.com
2021-10-08 15:17:00 -07:00
Andrii Nakryiko
bad2e478af
selftests/bpf: Turn on libbpf 1.0 mode and fix all IS_ERR checks
...
Turn ony libbpf 1.0 mode. Fix all the explicit IS_ERR checks that now will be
broken because libbpf returns NULL on error (and sets errno). Fix
ASSERT_OK_PTR and ASSERT_ERR_PTR to work for both old mode and new modes and
use them throughout selftests. This is trivial to do by using
libbpf_get_error() API that all libbpf users are supposed to use, instead of
IS_ERR checks.
A bunch of checks also did explicit -1 comparison for various fd-returning
APIs. Such checks are replaced with >= 0 or < 0 cases.
There were also few misuses of bpf_object__find_map_by_name() in test_maps.
Those are fixed in this patch as well.
Signed-off-by: Andrii Nakryiko <andrii@kernel.org >
Signed-off-by: Alexei Starovoitov <ast@kernel.org >
Acked-by: John Fastabend <john.fastabend@gmail.com >
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com >
Link: https://lore.kernel.org/bpf/20210525035935.1461796-3-andrii@kernel.org
2021-05-25 17:32:35 -07:00
Jesper Dangaard Brouer
e5e010a306
selftests/bpf: Tests using bpf_check_mtu BPF-helper input mtu_len param
...
Add tests that use mtu_len as input parameter in BPF-helper
bpf_check_mtu().
The BPF-helper is avail from both XDP and TC context. Add two tests
per context, one that tests below MTU and one that exceeds the MTU.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Acked-by: John Fastabend <john.fastabend@gmail.com >
Link: https://lore.kernel.org/bpf/161521556358.3515614.5915221479709358964.stgit@firesoul
2021-03-08 22:45:56 +01:00
Jesper Dangaard Brouer
b62eba5632
selftests/bpf: Tests using bpf_check_mtu BPF-helper
...
Adding selftest for BPF-helper bpf_check_mtu(). Making sure
it can be used from both XDP and TC.
V16:
- Fix 'void' function definition
V11:
- Addresse nitpicks from Andrii Nakryiko
V10:
- Remove errno non-zero test in CHECK_ATTR()
- Addresse comments from Andrii Nakryiko
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com >
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net >
Acked-by: Andrii Nakryiko <andrii@kernel.org >
Link: https://lore.kernel.org/bpf/161287791989.790810.13612620012522164562.stgit@firesoul
2021-02-13 01:15:28 +01:00