selftests/bpf: Add simple bpf tests in the tx path for timestamping feature
authorJason Xing <kerneljasonxing@gmail.com>
Thu, 20 Feb 2025 07:29:40 +0000 (15:29 +0800)
committerMartin KaFai Lau <martin.lau@kernel.org>
Thu, 20 Feb 2025 22:30:07 +0000 (14:30 -0800)
commitf4924aec58dd9e14779f4bc11a6bf3a830a42a6c
tree5a8d58615af649ddc8416ef380aaaafd5448b388
parent59422464266f8baa091edcb3779f0955a21abf00
selftests/bpf: Add simple bpf tests in the tx path for timestamping feature

BPF program calculates a couple of latency deltas between each tx
timestamping callbacks. It can be used in the real world to diagnose
the kernel behaviour in the tx path.

Check the safety issues by accessing a few bpf calls in
bpf_test_access_bpf_calls() which are implemented in the patch 3 and 4.

Check if the bpf timestamping can co-exist with socket timestamping.

There remains a few realistic things[1][2] to highlight:
1. in general a packet may pass through multiple qdiscs. For instance
with bonding or tunnel virtual devices in the egress path.
2. packets may be resent, in which case an ACK might precede a repeat
SCHED and SND.
3. erroneous or malicious peers may also just never send an ACK.

[1]: https://lore.kernel.org/all/67a389af981b0_14e0832949d@willemb.c.googlers.com.notmuch/
[2]: https://lore.kernel.org/all/c329a0c1-239b-4ca1-91f2-cb30b8dd2f6a@linux.dev/

Signed-off-by: Jason Xing <kerneljasonxing@gmail.com>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20250220072940.99994-13-kerneljasonxing@gmail.com
tools/testing/selftests/bpf/prog_tests/net_timestamping.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/net_timestamping.c [new file with mode: 0644]