Skip to content

bpf, sockmap: Fix dropped data and EPIPE on empty skb redirect

Eli Skeggs b4-sent bpf linux-kselftest lkml netdev sashiko-reviews 1 version In review

Get series with b4
b4 am [email protected] change-id 20261020-sockmap-bare-fin-e1f8160c3c7b

Versions newest first

  1. v1 Latest2 patches 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2bpf, sockmap: Stop reporting EPIPE on zero-length skb redirectnet/core/skmsg.c+1 -15 replies
2/2selftests/bpf: Redirect a bare FIN to another socket's egresstools/testing/selftests/bpf/prog_tests/sockmap_basic.c tools/testing/selftests/bpf/progs/test_sockmap_pass_prog.c+82 -01 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

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]>