bpf, sockmap: Fix dropped data and EPIPE on empty skb redirect
Get series with b4
b4 am [email protected] change-id 20261020-sockmap-bare-fin-e1f8160c3c7bVersions newest first
- v1 Latest2 patches 6 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | bpf, sockmap: Stop reporting EPIPE on zero-length skb redirectnet/ | +1 | 5 replies | |
| 2/2 | selftests/bpf: Redirect a bare FIN to another socket's egresstools/ tools/ | +82 | 1 reply |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH bpf 0/2] bpf, sockmap: Fix dropped data and EPIPE on empty skb redirect
When a socket receives a bare FIN, tcp_read_skb() hands an empty skb to the attached BPF stream_verdict program. The program may redirect that skb to another socket. Doing so causes the target socket to report EPIPE and stop transmitting redirected data. A proxy may see the erroneous EPIPE and truncate a half-closed connection. Instead of treating a redirected empty skb as an error, treat a 0 return as an error only when there is more data to send.
Patch 2 adds a selftest that fails without patch 1.
Tested on x86_64 with virtme-ng, under QEMU without KVM. The new subtest fails on bpf/master without patch 1, and passes with it. The full test_progs -t sockmap passes all seven tests and 802 subtests with patch 1.
The bug dates from v6.0 (965b57b469a5), so please consider queueing patch 1 for stable.
Found while building a sockmap proxy between TCP and MPTCP sockets, running out-of-tree MPTCP sockmap patches, where the EPIPE caused half-closed connections to prematurely abort. An LLM helped locate and reproduce the issue, and proposed an initial fix. I traced the code path, reviewed and verified the LLM-written test, and simplified its proposal to a one-line fix.
---
Eli Skeggs (2):
bpf, sockmap: Stop reporting EPIPE on zero-length skb redirect selftests/bpf: Redirect a bare FIN to another socket's egress
net/core/skmsg.c | 2 +- .../selftests/bpf/prog_tests/sockmap_basic.c | 74 ++++++++++++++++++++++ .../selftests/bpf/progs/test_sockmap_pass_prog.c | 8 +++ 3 files changed, 83 insertions(+), 1 deletion(-)
---
base-commit: f909e534f5e34feb2ea2701d54df63e21aa506fc
change-id: 20261020-sockmap-bare-fin-e1f8160c3c7b
Best regards,
Signature · 1 line
Eli Skeggs <[email protected]>