[PATCH bpf v2 00/15] bpf, sockmap: Fixes for verdicts, redirects, corks and recvmsg()

Alexei Starovoitov posted 15 patches 2 days, 23 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/20261102072112.4160195-1-alexei.starovoitov@gmail.com
Documentation/bpf/map_sockmap.rst |  4 +-
include/linux/skmsg.h             | 19 +++++++
include/net/tcp.h                 |  6 ++
net/core/filter.c                 | 17 +-----
net/core/skmsg.c                  | 13 ++++-
net/core/sock_map.c               |  9 +++
net/core/stream.c                 |  6 +-
net/ipv4/tcp_bpf.c                | 93 ++++++++++++++++++++++++++++---
net/mptcp/protocol.c              |  6 --
9 files changed, 141 insertions(+), 32 deletions(-)
[PATCH bpf v2 00/15] bpf, sockmap: Fixes for verdicts, redirects, corks and recvmsg()
Posted by Alexei Starovoitov 2 days, 23 hours ago
From: Alexei Starovoitov <ast@kernel.org>

These patches fix bugs in sockmap:

  patches  area
  -------  ----------------------------------------------------------------
  01       recvmsg() after a fault
  02-04    the verdict of an sk_msg prog and the return value of sendmsg()
  05       the backlog of a stopped psock
  06       TCP listeners
  07-08    the target of an egress redirect
  09       the TCP state in recvmsg()
  10-14    corks and the redirect target
  15       bpf_msg_push_data() and bpf_msg_pop_data()

8 of the patches are from Chris Mason and Josef Bacik.

Patch 08 changes net/core/stream.c. Patch 09 moves tcp_can_send_ack() from
net/mptcp/protocol.c to include/net/tcp.h. Patches 10 and 15 change the
sk_msg helpers in net/core/filter.c.

v1 -> v2:
- Patch 03: end the verdict after a failed push too if apply_bytes is 0.
  Another sender can use up apply_bytes during the push (CI bot)
- Patch 04: correct the Fixes tag (CI bot)
- Rebase on the bpf tree

v1: https://lore.kernel.org/bpf/20261101192057.2296489-1-alexei.starovoitov@gmail.com/

Signed-off-by: Alexei Starovoitov <ast@kernel.org>

Alexei Starovoitov (7):
  bpf, sockmap: Don't let an SK_PASS verdict cover the next message
  bpf, sockmap: Subtract all dropped bytes from the return value
  net: Leave sk_stream_wait_memory() once the socket is dead
  bpf, sockmap: Clear the redirect target before the sk_msg prog runs
  bpf, sockmap: Check that the redirected message is the cork
  bpf, sockmap: Keep the rest of the cork after a redirect
  bpf, sockmap: Clear the end mark of elements added by push and pop

Chris Mason (5):
  bpf, sockmap: Give no progs to a TCP listener
  bpf, sockmap: Check the target of an egress redirect before each send
  bpf, sockmap: Check the TCP state in recvmsg()
  bpf, sockmap: Reset the copy position when corking
  bpf, sockmap: Don't copy 0 bytes into a full cork

Josef Bacik (3):
  bpf, sockmap: Write sg.start when recvmsg() faults
  bpf, sockmap: Don't let an SK_DROP verdict stick
  bpf, sockmap: Clear the resume state of a stopped psock

 Documentation/bpf/map_sockmap.rst |  4 +-
 include/linux/skmsg.h             | 19 +++++++
 include/net/tcp.h                 |  6 ++
 net/core/filter.c                 | 17 +-----
 net/core/skmsg.c                  | 13 ++++-
 net/core/sock_map.c               |  9 +++
 net/core/stream.c                 |  6 +-
 net/ipv4/tcp_bpf.c                | 93 ++++++++++++++++++++++++++++---
 net/mptcp/protocol.c              |  6 --
 9 files changed, 141 insertions(+), 32 deletions(-)


base-commit: 5e96760b25fdedbbf9312827f1f237d6b18b03e8
-- 
2.55.0
Re: [PATCH bpf v2 00/15] bpf, sockmap: Fixes for verdicts, redirects, corks and recvmsg()
Posted by MPTCP CI 2 days, 21 hours ago
Hi Alexei,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal (except selftest_mptcp_join): Unstable: 1 failed test(s): selftest_simult_flows ⚠️ 
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Unstable: 3 failed test(s): bpftest_test_progs-cpuv4_mptcp bpftest_test_progs-no_alu32_mptcp bpftest_test_progs_mptcp ⚠️ 
- KVM Validation: btf-debug (only bpftest_all): Unstable: 3 failed test(s): bpftest_test_progs-cpuv4_mptcp bpftest_test_progs-no_alu32_mptcp bpftest_test_progs_mptcp ⚠️ 
- Perf: Unstable: 1 failed test(s): error:sched-mem-pressure ⚠️ 
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/41408213721

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/ed7b3ed15cac
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1198506


If there are some issues, you can reproduce them using the same environment as
the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

    https://github.com/multipath-tcp/mptcp-upstream-virtme-docker


Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)
Re: [PATCH bpf v2 00/15] bpf, sockmap: Fixes for verdicts, redirects, corks and recvmsg()
Posted by patchwork-bot+netdevbpf@kernel.org 12 hours ago
Hello:

This series was applied to bpf/bpf.git (master)
by Alexei Starovoitov <ast@kernel.org>:

On Mon,  2 Nov 2026 07:20:57 +0000 you wrote:
> From: Alexei Starovoitov <ast@kernel.org>
> 
> These patches fix bugs in sockmap:
> 
>   patches  area
>   -------  ----------------------------------------------------------------
>   01       recvmsg() after a fault
>   02-04    the verdict of an sk_msg prog and the return value of sendmsg()
>   05       the backlog of a stopped psock
>   06       TCP listeners
>   07-08    the target of an egress redirect
>   09       the TCP state in recvmsg()
>   10-14    corks and the redirect target
>   15       bpf_msg_push_data() and bpf_msg_pop_data()
> 
> [...]

Here is the summary with links:
  - [bpf,v2,01/15] bpf, sockmap: Write sg.start when recvmsg() faults
    https://git.kernel.org/bpf/bpf/c/b889ea1f6dbe
  - [bpf,v2,02/15] bpf, sockmap: Don't let an SK_DROP verdict stick
    https://git.kernel.org/bpf/bpf/c/436c4cfa071e
  - [bpf,v2,03/15] bpf, sockmap: Don't let an SK_PASS verdict cover the next message
    https://git.kernel.org/bpf/bpf/c/f4c044966d6c
  - [bpf,v2,04/15] bpf, sockmap: Subtract all dropped bytes from the return value
    https://git.kernel.org/bpf/bpf/c/fa84be67b5bc
  - [bpf,v2,05/15] bpf, sockmap: Clear the resume state of a stopped psock
    https://git.kernel.org/bpf/bpf/c/51e0f3d60be5
  - [bpf,v2,06/15] bpf, sockmap: Give no progs to a TCP listener
    https://git.kernel.org/bpf/bpf/c/7c036a39ba29
  - [bpf,v2,07/15] bpf, sockmap: Check the target of an egress redirect before each send
    https://git.kernel.org/bpf/bpf/c/4aeaad1c536e
  - [bpf,v2,08/15] net: Leave sk_stream_wait_memory() once the socket is dead
    https://git.kernel.org/bpf/bpf/c/430775a30b1f
  - [bpf,v2,09/15] bpf, sockmap: Check the TCP state in recvmsg()
    https://git.kernel.org/bpf/bpf/c/9f5763e6287a
  - [bpf,v2,10/15] bpf, sockmap: Reset the copy position when corking
    https://git.kernel.org/bpf/bpf/c/12c45473dfe7
  - [bpf,v2,11/15] bpf, sockmap: Don't copy 0 bytes into a full cork
    https://git.kernel.org/bpf/bpf/c/a912358996f8
  - [bpf,v2,12/15] bpf, sockmap: Clear the redirect target before the sk_msg prog runs
    https://git.kernel.org/bpf/bpf/c/e4c2fe0b9a62
  - [bpf,v2,13/15] bpf, sockmap: Check that the redirected message is the cork
    https://git.kernel.org/bpf/bpf/c/815cfc482e63
  - [bpf,v2,14/15] bpf, sockmap: Keep the rest of the cork after a redirect
    https://git.kernel.org/bpf/bpf/c/13c41b87e4a7
  - [bpf,v2,15/15] bpf, sockmap: Clear the end mark of elements added by push and pop
    https://git.kernel.org/bpf/bpf/c/0048086bd361

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Re: [PATCH bpf v2 00/15] bpf, sockmap: Fixes for verdicts, redirects, corks and recvmsg()
Posted by John Fastabend 2 days, 10 hours ago
On Mon, Nov 02, 2026 at 07:20:57AM +0000, Alexei Starovoitov wrote:
>From: Alexei Starovoitov <ast@kernel.org>
>
>These patches fix bugs in sockmap:
>
>  patches  area
>  -------  ----------------------------------------------------------------
>  01       recvmsg() after a fault
>  02-04    the verdict of an sk_msg prog and the return value of sendmsg()
>  05       the backlog of a stopped psock
>  06       TCP listeners
>  07-08    the target of an egress redirect
>  09       the TCP state in recvmsg()
>  10-14    corks and the redirect target
>  15       bpf_msg_push_data() and bpf_msg_pop_data()
>
>8 of the patches are from Chris Mason and Josef Bacik.

Thanks everyone lgtm. For the series.

Reviewed-by: John Fastabend <john.fastabend@gmail.com>
Re: [PATCH bpf v2 00/15] bpf, sockmap: Fixes for verdicts, redirects, corks and recvmsg()
Posted by Eric Dumazet 1 day, 1 hour ago
Le lun. 2 nov. 2026 à 21:11, John Fastabend <john.fastabend@gmail.com> a écrit :
>
> On Mon, Nov 02, 2026 at 07:20:57AM +0000, Alexei Starovoitov wrote:
> >From: Alexei Starovoitov <ast@kernel.org>
> >
> >These patches fix bugs in sockmap:
> >
> >  patches  area
> >  -------  ----------------------------------------------------------------
> >  01       recvmsg() after a fault
> >  02-04    the verdict of an sk_msg prog and the return value of sendmsg()
> >  05       the backlog of a stopped psock
> >  06       TCP listeners
> >  07-08    the target of an egress redirect
> >  09       the TCP state in recvmsg()
> >  10-14    corks and the redirect target
> >  15       bpf_msg_push_data() and bpf_msg_pop_data()
> >
> >8 of the patches are from Chris Mason and Josef Bacik.
>
> Thanks everyone lgtm. For the series.
>
> Reviewed-by: John Fastabend <john.fastabend@gmail.com>

For the series:

Reviewed-by: Eric Dumazet <edumazet@kernel.org>