selftests/bpf: Test bpf_skb_adjust_room on CHECKSUM_PARTIAL
Subsystems (3)
Martin KaFai Lau
reviewerPATCH v3 1/1 selftests/bpf: Test bpf_skb_adjust_room on CHECKSUM_PARTIAL
From: Martin KaFai Lau <[email protected]>
When the bpf_skb_adjust_room() shrinks the skb such that its csum_start is invalid, the skb->ip_summed should be reset from CHECKSUM_PARTIAL to CHECKSUM_NONE.
The commit 54c3f1a81421 ("bpf: pull before calling skb_postpull_rcsum()") fixed it.
This patch adds a test to ensure the skb->ip_summed changed from CHECKSUM_PARTIAL to CHECKSUM_NONE after bpf_skb_adjust_room().
---
v3:
* Use ASSERT_TRUE and ASSERT_FALSE
* On top of 'ip netns del', also call bpf_tc_hook_destroy() in case bpf_tc_hook_create() may allocate memory in the future.
v2: Add test to DENYLIST.s390x due to kfunc usage
tools/testing/selftests/bpf/DENYLIST.s390x | 1 + .../selftests/bpf/prog_tests/decap_sanity.c | 85 +++++++++++++++++++ .../selftests/bpf/progs/bpf_tracing_net.h | 6 ++ .../selftests/bpf/progs/decap_sanity.c | 68 +++++++++++++++ 4 files changed, 160 insertions(+) create mode 100644 tools/testing/selftests/bpf/prog_tests/decap_sanity.c create mode 100644 tools/testing/selftests/bpf/progs/decap_sanity.c
tools/testing/selftests/bpf/DENYLIST.s390x +1 -0
@@ -14,6 +14,7 @@ cgrp_kfunc # JIT does not support calling kernel f cgrp_local_storage # prog_attach unexpected error: -524 (trampoline) core_read_macros # unknown func bpf_probe_read#4 (overlapping) d_path # failed to auto-attach program 'prog_stat': -524 (trampoline) +decap_sanity # JIT does not support calling kernel function (kfunc) deny_namespace # failed to attach: ERROR: strerror_r(-524)=22 (trampoline) dummy_st_ops # test_run unexpected error: -524 (errno 524) (trampoline) fentry_fexit # fentry attach failed: -524 (trampoline)
tools/testing/selftests/bpf/prog_tests/decap_sanity.c new file +85 -0
85 lines not on this page · raw message
tools/testing/selftests/bpf/progs/bpf_tracing_net.h +6 -0
@@ -50,6 +50,12 @@#define ICSK_TIME_LOSS_PROBE 5#define ICSK_TIME_REO_TIMEOUT 6 +#define ETH_HLEN 14 +#define ETH_P_IPV6 0x86DD + +#define CHECKSUM_NONE 0 +#define CHECKSUM_PARTIAL 3 +#define IFNAMSIZ 16#define RTF_GATEWAY 0x0002
tools/testing/selftests/bpf/progs/decap_sanity.c new file +68 -0
68 lines not on this page · raw message
Signature · 1 line
2.30.2