[PATCH net 0/3] tcp, mptcp: fix receive buffer sizing and peek accounting

lei lei posted 3 patches 6 days, 14 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/20261117052200.1507847-1-llleigoing@outlook.com
include/net/tcp.h    |  2 +-
net/ipv4/tcp_input.c | 11 ++++++-----
net/mptcp/protocol.c | 12 +++++++-----
3 files changed, 14 insertions(+), 11 deletions(-)
[PATCH net 0/3] tcp, mptcp: fix receive buffer sizing and peek accounting
Posted by lei lei 6 days, 14 hours ago
This series fixes receive-buffer sizing and accounting errors in TCP
and MPTCP.

The first two patches prevent integer truncation from producing an
undersized receive-memory budget. __tcp_space_from_win() can return a
truncated int, while tcp_rcvbuf_grow() and mptcp_rcvbuf_grow() can wrap
a u32 window prediction. The fixes saturate the conversion result at
INT_MAX and keep growth predictions in u64 until they are bounded for
the existing helper interface. Patch 2 depends on patch 1.

The third patch restores the MSG_PEEK exclusion from MPTCP receive
autotuning. Repeated peeks currently count the same queued bytes as
application consumption, which can inflate the receive-memory budget
without the application draining the queue.

Validation used targeted IPv4 loopback socket tests on unpatched and
patched kernels in x86_64 QEMU/KVM guests. GCC 13.3 builds completed
without warnings. The tests confirmed that, with the fixes applied:

  - Large SO_RCVLOWAT settings on TCP and MPTCP correctly increase the
    receive-memory budget to INT_MAX when tcp_rmem[2] is INT_MAX and
    the window-to-memory conversion exceeds the representable range.
  - For queued bursts whose predicted window exceeds 32 bits, TCP and
    MPTCP receive budgets now reach the configured 64 MiB limit.
  - Repeated MSG_PEEK calls leave both a fixed 32 KiB MPTCP receive
    queue and its memory budget unchanged. A subsequent consuming read
    returns the original data intact.

The investigation began with sk_rcvbuf failing to grow despite
application reads during normal use, constraining the advertised
receive window.

OpenAI Codex assisted with designing trigger conditions and socket
tests for reproduction and validation.

lllei (3):
  tcp: saturate window-to-memory conversions at INT_MAX
  net: bound receive window predictions before narrowing
  mptcp: exclude MSG_PEEK from receive buffer autotuning

 include/net/tcp.h    |  2 +-
 net/ipv4/tcp_input.c | 11 ++++++-----
 net/mptcp/protocol.c | 12 +++++++-----
 3 files changed, 14 insertions(+), 11 deletions(-)


base-commit: aa40afa831ebfe45e40a23721711059f2ac584d4
-- 
2.43.0

Re: [PATCH net 0/3] tcp, mptcp: fix receive buffer sizing and peek accounting
Posted by MPTCP CI 6 days, 13 hours ago
Hi lei,

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): packetdrill_dss ⚠️ 
- 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): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Perf: Unstable: 1 failed test(s): validation:sched-mem-pressure ⚠️ 
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/44024826211

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


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)