[PATCH mptcp-net] mptcp: reclaim forward-allocated memory on RX path errors

Paolo Abeni posted 1 patch 4 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/54ad24594f194dace522b8f1be3912b242708a6e.1785162224.git.pabeni@redhat.com
net/mptcp/protocol.c | 7 +++++++
1 file changed, 7 insertions(+)
[PATCH mptcp-net] mptcp: reclaim forward-allocated memory on RX path errors
Posted by Paolo Abeni 4 weeks ago
After commit 9db5b3cec4ec ("mptcp: borrow forward memory from subflow"),
errors in the receive path prior to queueing skbs into the receive
queue do not trigger forward-allocated memory reclaiming.

Prevent forward memory from growing unboundedly in pathological drop
scenarios by explicitly reclaiming memory when skbs are dropped.

Fixes: 9db5b3cec4ec ("mptcp: borrow forward memory from subflow")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/mptcp/protocol.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index 954e20bb27de..90dc894cb976 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -149,6 +149,13 @@ struct sock *__mptcp_nmpc_sk(struct mptcp_sock *msk)
 
 static void mptcp_drop(struct sock *sk, struct sk_buff *skb)
 {
+	/*
+	 * The skb forward memory was already transferred to sk by
+	 * mptcp_borrow_fwdmem(), even before setting the destructor.
+	 */
+	if (!skb->destructor)
+		sk_mem_reclaim(sk);
+
 	sk_drops_skbadd(sk, skb);
 	__kfree_skb(skb);
 }
-- 
2.55.0
Re: [PATCH mptcp-net] mptcp: reclaim forward-allocated memory on RX path errors
Posted by Matthieu Baerts 3 weeks, 6 days ago
Hi Paolo,

On 27/07/2026 19:36, Paolo Abeni wrote:
> After commit 9db5b3cec4ec ("mptcp: borrow forward memory from subflow"),
> errors in the receive path prior to queueing skbs into the receive
> queue do not trigger forward-allocated memory reclaiming.
> 
> Prevent forward memory from growing unboundedly in pathological drop
> scenarios by explicitly reclaiming memory when skbs are dropped.
Thank you for this fix, it looks good to me:

Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>

New patches for t/upstream-net and t/upstream:
- 0ab6395f5005: mptcp: reclaim forward-allocated memory on RX path errors
- Results: c37d29475f67..2668d30f6377 (export-net)
- Results: aca5be746b7a..a596e199424d (export)

Tests are now in progress:

- export-net:
https://github.com/multipath-tcp/mptcp_net-next/commit/ad1a23355073cf3bf47b6f544c590998f451a9d5/checks
- export:
https://github.com/multipath-tcp/mptcp_net-next/commit/288eb31a56e9cd5a843c911085bb7968bb25057f/checks

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.
Re: [PATCH mptcp-net] mptcp: reclaim forward-allocated memory on RX path errors
Posted by MPTCP CI 4 weeks ago
Hi Paolo,

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): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/30293017841

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


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)