From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 320DD81377 for ; Fri, 6 Nov 2026 03:04:48 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A633WYr012783; Fri, 6 Nov 2026 06:03:32 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A633WYr012783 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="ir+cxqDs" Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A633AND012716 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Fri, 6 Nov 2026 06:03:10 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A633AND012716 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-4a009f82bedso1031615e9.0 for ; Thu, 05 Nov 2026 19:03:10 -0800 (PST) X-Gm-Message-State: APuU4Z9gM2UypdO97KPmRtTL2QAG3T984PrCqGj0rKcbOZY/rto+3YI3 tuK95u2nCAdgz0mFXTHYSiSPpjcfIVjw+/fTdgMuIFsxQxdjUEBOB56VGTLgoesKXt5GmDEvR9m 7CEq/r+E8cz3hXeo+r26yH/EuSb17h9g6Zs9nAAWz634CXP5BaLzt/g== X-Gm-Gg: AYBFou0nQMGGwEmbhXOtsoaQbMpG7gUvz1tUiLKR963qBcSb5SCV1VZ5UWs1NpCV9By BokolJuqBp1NrpexMxLGPganFRi3aAWcSc5P6kU9YQyGfPtarXSTtdLodM+wM8AEkQiFBeXOCKW dqu47XXiokwiYvJg3QpH2yJyBjgw1wjVGPFYCw8XJUjugGsob8UvmUFBE8cOpgJFK86ApWP2lxK AuqkXCOaMCiNwBx6tZEJ9u0Kuj9Quj9SK3XSStYdlazw1idYIZhYARtlra5qIeBR8reQvb9rCto WpM2Agzrvw3FHEl0CFMYmpf+6MQTd9MhE8V1YKcEJXMyBr2zEEav2G7wN5RAvO3b4Vq9FWMfJDu mk9FyfDDpWO3rtdGV2fSD7J/h X-Received: by 2002:a05:600c:4ecc:b0:4a2:191f:7cbd with SMTP id 5b1f17b1804b1-4b6dd82a92amr16055605e9.11.1793934190260; Thu, 05 Nov 2026 19:03:10 -0800 (PST) X-Received: by 2002:a05:600c:4ecc:b0:4a2:191f:7cbd with SMTP id 5b1f17b1804b1-4b6dd82a92amr16055315e9.11.1793934189685; Thu, 05 Nov 2026 19:03:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1793934189; cv=none; d=google.com; s=arc-20260327; b=LaaGFTD0Os/WpSEkhyrqu1p1Do/rnlWFJo0QrjvvSSBYkCUDVOdl8amchaJDnlSRm8 qUpHL8dRr9nOZRvuVcnYFC2GPx7KwxcheH7CbrWKL7/jv+eOrejkZDs7oui1PSYKgyAM Yqk0EV9Ot3DuiOfUKCeWLmmdpnpzslvaxzRc4hwVH5XxnZQTszSyREDYxMVNRWcAqrVt Vkn66hhrQ7CH9MeoUwxQBmHUQKQpDSuwwxbCgkA4XARIsyJi3XAqE5zVFeN+scKSMwvu 1v3e2ZCRku3ju9lBl1c9If8pnHvC/b7X3ADdS3Pw6zYDsAcDtmPgZGdSWchxGNtYu0oE kzfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=anqWlmRLYXiu7jrnNWYJpnMEg3vp1aztN6VyD4oj438=; fh=WpT6aB7RBAGHZeWZzqAr71yzRFbPTYkPWKsRagLn48Q=; b=hIs1XMyQRRga0YKyFmxoesMqJSBiRW3FiDS/XrM+SfMAH2aBUduHqlxQmCBvOxd+Bh geUkIcGy/L+OmJkE0JqdwZkqP+AvyFYYPoKaPa/aszpbs2/1R1TOsyjCM6otOFlc/caq 8kqgnW+mRsSbgTXOXcixsaVFJ6Xv0K1bDYHi1aVnGcU69RWD9KjS/Zt1Gg9y/gO7iNXd +cGHPQ58iZsfD94P/LW8y07jyS2+JrZVOl4XWNt11hkEeNDSjnhbM6WkD3GNrKnGWNMn D1O5atnsOM5ggX0J9Xf99XZguHiH37mDThJzg/q3cWhrSJfbQZjC5KePgz7kl576EN7A rAhw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=ir+cxqDs; spf=pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=eva.kurchatova@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id ffacd0b85a97d-492d856709bsi1016084f8f.415.2026.11.05.19.03.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2026 19:03:09 -0800 (PST) Received-SPF: pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=ir+cxqDs; spf=pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=eva.kurchatova@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=anqWlmRLYXiu7jrnNWYJpnMEg3vp1aztN6VyD4oj438=; b=ir+cxqDs3eMG U/Oltex/ljYvEOujMuWUCKD6EXLDRvxk+yxyqOHbqHGxwIPnprEhzVtuaEDzXX/D362jYk84hJN4L j0eEx8lUKEJgUY0+CO2Wxlvg6t/m0wVpbSyyBL1g89kaHLcGM9gQQews1oy9NusN0IgWjx+NJ7ApE h6K4LJQZy3qeNd4aRWVTzfCgbOqQyW6KpRIMMTGNz6ajU6z2dgybRB10RtPJpiYNdOq0fd+2/mb09 /c5wmjXn7EqpBOfeSZdb11dUe37xWE4eTjc+DWXmSENm5VQyCJaCKtpPhpWn+0UOFuQdKgzT7qna4 +MCx+bEk4VWOgwomaj/5VQ==; Received: from ch-vpn.virtuozzo.com ([130.117.225.6] helo=LekKit-T14) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xPAAQ-00Gfia-0g; Fri, 06 Nov 2026 04:03:06 +0100 From: Eva Kurchatova To: khorenko@virtuozzo.com Date: Fri, 6 Nov 2026 05:02:14 +0200 Message-ID: <20261106030306.16014-7-eva.kurchatova@virtuozzo.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261106030306.16014-1-eva.kurchatova@virtuozzo.com> References: <20261106030306.16014-1-eva.kurchatova@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 6/8] ms/mptcp: implemented OoO queue pruning X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org From: Paolo Abeni When moving incoming skbs in the msk receive queue and the latter is above limits, prune it as needed quite alike what TCP is doing at the subflow level. The main difference relies in the stop condition: since MPTCP does not perform collapsing, it's better off dropping the bare minimum to fit the (newer) incoming packet. Signed-off-by: Paolo Abeni Tested-by: Gang Yan Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) Link: https://patch.msgid.link/20260807-net-next-mptcp-oooq-pruning-v3-7-dbc1eb853cc3@kernel.org Signed-off-by: Jakub Kicinski (cherry picked from commit e468d371180d3c5b3333660bd742103b88703adf) Rebase note: in the older receive path of this tree the check goes into __mptcp_move_skb() and mptcp_data_queue_ofo(), after the map_seq of the skb is set, and replaces the drop of the previous patch, as in mainline. The commits of the series between the two, about the backlog this tree lacks and a cleanup, are not needed. OFOPruned is added after the last counter of this tree. https://virtuozzo.atlassian.net/browse/VSTOR-153491 Feature: fix ms/net Signed-off-by: Eva Kurchatova --- net/mptcp/mib.c | 1 + net/mptcp/mib.h | 1 + net/mptcp/protocol.c | 79 +++++++++++++++++++++++++++++++++++++++----- 3 files changed, 72 insertions(+), 9 deletions(-) diff --git a/net/mptcp/mib.c b/net/mptcp/mib.c index 19eb9292bd60..fbe27ddea8e1 100644 --- a/net/mptcp/mib.c +++ b/net/mptcp/mib.c @@ -79,6 +79,7 @@ static const struct snmp_mib mptcp_snmp_list[] = { SNMP_MIB_ITEM("RcvWndConflict", MPTCP_MIB_RCVWNDCONFLICT), SNMP_MIB_ITEM("MPCurrEstab", MPTCP_MIB_CURRESTAB), SNMP_MIB_ITEM("Blackhole", MPTCP_MIB_BLACKHOLE), + SNMP_MIB_ITEM("OFOPruned", MPTCP_MIB_OFOPRUNED), SNMP_MIB_SENTINEL }; diff --git a/net/mptcp/mib.h b/net/mptcp/mib.h index 128282982843..f2b9934a6ecb 100644 --- a/net/mptcp/mib.h +++ b/net/mptcp/mib.h @@ -80,6 +80,7 @@ enum linux_mptcp_mib_field { MPTCP_MIB_RCVWNDCONFLICT, /* Conflict with while updating msk rcv wnd */ MPTCP_MIB_CURRESTAB, /* Current established MPTCP connections */ MPTCP_MIB_BLACKHOLE, /* A blackhole has been detected */ + MPTCP_MIB_OFOPRUNED, /* MPTCP-level OoO queue pruned */ __MPTCP_MIB_MAX }; diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 6e8779646d17..3b02a63ad1a9 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -157,6 +157,65 @@ static bool mptcp_ooo_try_coalesce(struct mptcp_sock *msk, struct sk_buff *to, return mptcp_try_coalesce((struct sock *)msk, to, from); } +/* "Inspired" from the TCP version; main difference: stop as soon as the MPTCP + * socket is under memory limit. + */ +static void mptcp_prune_ofo_queue(struct sock *sk, + const struct sk_buff *in_skb) +{ + struct mptcp_sock *msk = mptcp_sk(sk); + struct rb_node *node, *prev; + bool pruned = false; + u64 mem; + + if (RB_EMPTY_ROOT(&msk->out_of_order_queue)) + return; + + node = &msk->ooo_last_skb->rbnode; + + do { + struct sk_buff *skb = rb_to_skb(node); + + /* Stop pruning if the incoming skb would land in OoO tail. */ + if (after64(MPTCP_SKB_CB(in_skb)->map_seq, + MPTCP_SKB_CB(skb)->map_seq)) + break; + + pruned = true; + prev = rb_prev(node); + rb_erase(node, &msk->out_of_order_queue); + mptcp_drop(sk, skb); + msk->ooo_last_skb = rb_to_skb(prev); + + mem = (unsigned int)sk_rmem_alloc_get(sk); + if (mem <= sk->sk_rcvbuf) + break; + + node = prev; + } while (node); + + if (pruned) + MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_OFOPRUNED); +} + +/* The stack can't drop packets for fallback socket at the msk level, or the + * stream will break. + */ +static bool mptcp_can_ingest(const struct sock *sk) +{ + return unlikely(sk_rmem_alloc_get(sk) <= READ_ONCE(sk->sk_rcvbuf)) || + __mptcp_check_fallback(mptcp_sk(sk)); +} + +static bool mptcp_try_rmem_schedule(struct sock *sk, const struct sk_buff *skb) +{ + if (!mptcp_can_ingest(sk)) { + mptcp_prune_ofo_queue(sk, skb); + return mptcp_can_ingest(sk); + } + return true; +} + /* "inspired" by tcp_data_queue_ofo(), main differences: * - use mptcp seqs * - don't cope with sacks @@ -168,6 +227,12 @@ static void mptcp_data_queue_ofo(struct mptcp_sock *msk, struct sk_buff *skb) u64 seq, end_seq, max_seq; struct sk_buff *skb1; + if (!mptcp_try_rmem_schedule(sk, skb)) { + MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RCVPRUNED); + mptcp_drop(sk, skb); + return; + } + seq = MPTCP_SKB_CB(skb)->map_seq; end_seq = MPTCP_SKB_CB(skb)->end_seq; max_seq = atomic64_read(&msk->rcv_wnd_sent); @@ -286,15 +351,6 @@ static bool __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk, skb_ext_reset(skb); skb_orphan(skb); - /* Can't drop packets for fallback socket this late, or the stream - * will break. - */ - if (unlikely(sk_rmem_alloc_get(sk) > READ_ONCE(sk->sk_rcvbuf)) && - !__mptcp_check_fallback(msk)) { - MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RCVPRUNED); - goto drop; - } - /* try to fetch required memory from subflow */ if (!sk_rmem_schedule(sk, skb, skb->truesize)) { MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RCVPRUNED); @@ -315,6 +371,11 @@ static bool __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk, if (MPTCP_SKB_CB(skb)->map_seq == msk->ack_seq) { /* in sequence */ + if (!mptcp_try_rmem_schedule(sk, skb)) { + MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_RCVPRUNED); + goto drop; + } + msk->bytes_received += copy_len; WRITE_ONCE(msk->ack_seq, msk->ack_seq + copy_len); tail = skb_peek_tail(&sk->sk_receive_queue); -- 2.56.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel