Skip to contentSkip to conversation

selftests/bpf: Test bpf_skb_adjust_room on CHECKSUM_PARTIAL

PATCH Superseded Martin KaFai Lau 1 participant 1 message Dec 21, 2022

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Martin KaFai Lau

author reviewer
#0 lore raw

PATCH 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
index 585fcf73c731..3fc3e54b19aa 100644
@@ -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
index b394817126cf..cfed4df490f3 100644
@@ -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