mptcp: avoid underflow when growing subflow rcvbuf
Subsystems (2)
PATCH 1/1 mptcp: avoid underflow when growing subflow rcvbuf
When mptcp_rcvbuf_grow() grows the msk receive buffer, mptcp_rcv_space_adjust() propagates @copied to each subflow via tcp_rcvbuf_grow(ssk, copied). Because @copied only had to exceed msk->rcvq_space.space (initialized from the first subflow), it can still be smaller than a later MP_JOIN subflow's tp->rcvq_space.space (e.g. with an MTU 1500 initial subflow and an MTU 9000 MP_JOIN subflow).
Passing copied < tp->rcvq_space.space moves the subflow's space estimate backwards and, since commit aa251c84636c ("tcp: fix too slow tcp_rcvbuf_grow() action"), underflows the u32 (newval - oldval) slow-start delta in tcp_rcvbuf_grow(). Sashiko AI review flagged this path while reviewing a related autotuning change.
Pass max(copied, space) to tcp_rcvbuf_grow() so a subflow with a larger estimate keeps its space intact and sees a zero slow-start delta, while still accounting for its own out-of-order queue and low_rtt policy.
In a two-netns test with MTU 1500 MP_CAPABLE and MTU 9000 MP_JOIN subflows, a 30 KB read previously moved the join subflow's rcv_space backwards and inflated its sk_rcvbuf from 128 KiB to tcp_rmem[2] (32 MiB); with this fix, both stayed unchanged (~56 KB and 128 KiB).
---
Discussion: https://lore.kernel.org/r/[email protected]
net/mptcp/protocol.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/mptcp/protocol.c +4 -2
@@ -2352,12 +2352,14 @@ static void mptcp_rcv_space_adjust(struct mptcp_sock *msk, int copied)mptcp_for_each_subflow (msk, subflow) {struct sock *ssk;bool slow; +int space; ssk =mptcp_subflow_tcp_sock (subflow); slow =lock_sock_fast (ssk); + space =tcp_sk (ssk)->rcvq_space.space;/* subflows can be added before tcp_init_transfer() */ -if (tcp_sk (ssk)->rcvq_space.space) -tcp_rcvbuf_grow (ssk, copied); +if (space) +tcp_rcvbuf_grow (ssk,max (copied, space));unlock_sock_fast (ssk, slow); } }
base-commit: 8bb3ad7a62237c9199e0af733168fff4ee3a5be2
Signature · 1 line
2.43.0
Hi Lin,
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): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Critical: 85 Call Trace(s) - Critical: Global Timeout ❌
- 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): regression:sched-bbr(5) ⚠️ (15 new outliers to review) | Unstable: 2 failed test(s): validation:sched-loss validation:sched-weak-secondary ⚠️ (21 new outliers to review) | Unstable: 3 failed test(s): regression:sched-clientlim(4) regression:sched-weak-secondary(3) validation:sched-mem-pressure ⚠️ (10 new outliers to review) | Success! ✅ (7 new outliers to review)
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/46246136723
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/59062350a34a
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1225603
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-normalFor 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)
Hi Lin,
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): Success! ✅
- 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): regression:sched-bbr(5) ⚠️ (15 new outliers to review) | Unstable: 2 failed test(s): validation:sched-loss validation:sched-weak-secondary ⚠️ (21 new outliers to review) | Unstable: 3 failed test(s): regression:sched-clientlim(4) regression:sched-weak-secondary(3) validation:sched-mem-pressure ⚠️ (10 new outliers to review) | Success! ✅ (7 new outliers to review)
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/46246136723
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/59062350a34a
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1225603
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-normalFor 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)