From nobody Thu Nov 5 07:28:49 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.171 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792996624; b=dUeAmfmOqj5Zh5uNDHW3IqRqIcpyO2WjXTfA6piBrh01GZCyeOsY8VJOeN3Iapvy95BN NWF6Zopi8gWeegz/K10zmeJosyRBykJ7jyM/SXQVV8pWXvo40fLojLp3tWKFCalQ36Kmt 9DyzDuhSlbEPzVWWyVg396xFBhB5xFr++erHixAziAF7vndMUOtxk/tHo7LstHSrCU2xw XvAAlgnXZZv+3N5ynEZyjaVtBJcAf77gr0pCW1vjn9l3q+VSUBDo/xM7k9ZYWgbCunBcV QMjhyqkPxtEcbll5jEV0n6Pj7yCYLQTjbzqrlup/4eOGma+Esmc3pUD9DIoGI7f3ixg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792996624; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=XwlldahLZl6u6KBDX9l7n8vOmnvTZvhZdUFA/a8ErDA=; b=AIaa/ZZYcnZ2MgKc12cWPfrzkpFrYPL88IkWpNvgofNx9GH1zs0kl0WTtllhYPN4mYOi lywHodFw+u9v2dLfN0WnbHcjwik6kS2TponzJuaIqUtn74pt8vgXuTzRSCggFY/iSSBX6 NcvFpKpg7YUB2fkUXLtLjdgH7/xDgR0RRpIa7BEmZebu5W3gedjoU2ewo4JiEAOk53fAM BYq0oaE+LOSPvPWTrfZAwM7yymZZzernkbE/zXNMjc08rLufobRJeS0YPK93nutPGViFF Plva6T3TXzN2ivTQj+IXvXSTasc37HkR3tu2WEVLiqcMcpHQN5SUIX+4PqByO6DNc1A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=oPkvesGn; arc=none smtp.remote-ip=74.125.82.171 Received: from mail-dy1-f171.google.com (mail-dy1-f171.google.com [74.125.82.171]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50ED5606A31A for ; Mon, 26 Oct 2026 06:37:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 50ED5606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=oPkvesGn Received: by mail-dy1-f171.google.com with SMTP id 5a478bee46e88-3550c917fd3so4012514eec.0 for ; Sun, 25 Oct 2026 23:37:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792996623; x=1793601423; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=XwlldahLZl6u6KBDX9l7n8vOmnvTZvhZdUFA/a8ErDA=; b=oPkvesGnt46FwDE2OYNUFms1VfrjfJp2tfA7yj3tCW6mDI9TV4ldxliOwC9T5GvDce Zj1CW5jWrhMOR8M5yDRKspaHuocWI/GHuR184XYa+j7IGPmkzs8/MIw2gqhM/HxNsd8d APSnMb3Gub4N0E1VnhG8XZYAHHWpadRCckj7rM/RkowU9bjI47QurygmHEgxvYrdks0g t9WFOgJwZhB6+cSNiy7ZxdoZ4AIzv0mQIUAnntOjMIQOSrjq4YxC76gbJjW9UcDjnDny GSOZ+6fSOFckzWttc/ht+znjiTeUreg0a4mqA1gETpI4jXTJ6uAFDX8oHFFfUv2SK1sf HhFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792996623; x=1793601423; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=XwlldahLZl6u6KBDX9l7n8vOmnvTZvhZdUFA/a8ErDA=; b=KthnxgqCmm347+WUyLqgGFvzbs3vXlrug/tj2rPWucYZ4tbcD0uLr3O6lmgbT9KKf6 xNQuiH1IEg31f08gXotwzWpHh+muThPJ3NGA9Ql1zxeONkBGXdNeDO7X8wYoqOmztk5E eXMW6qu4WGWLnYeLepzGwckq7LsGEw6I1EVKUs6uuvCtRRpZ2BiKHoCzuLPP+lmIGPQ8 VcdVJfkaENQlyyL0Nv1L2fMrnzAv6UmVwweiSOe9QlGKEZ4jvALmVFQ4UbY9F4x7P+rG bhaMHZHSw4slaGT3W+aVbb1Y3eUxKb3Jm91lumAPasOsoLtIMpayxu25v7BncvFWXXVL Us7A== X-Gm-Message-State: AFq9FYLpMN7rdq07Nj2YxOCBTIGyMckk2dVy8dWVAeb/PiCI79jzkYyg 1MIUrBEtN97Z+gmUD0IZ8wqSu9vXCwgf4wo05e+l4pVei6aE7HZwV4wHXnsVqw== X-Gm-Gg: AYBFou3avSe5e0XnEcd7XZHPv0VPAlH5qiDXF+Bly/u4CXOGspr/VCuLFFKIYmQ2Xgr Hf7MR6Sgno4ReVZb0uOlan86ExqeH3RPAlSmeF4Ff3x5qAIWHSNhSVw4GwEtrRv6yNmhcvNSWiE VTCzKyzswRvyxdfuAsa7uHZxRqmzlgf2bX8TGxMS6/QQFv1wYoqhVgLymni5HMgfAa8fPTBIs4r jCV0+lkdGrHvi272ZwhrVREkXGNy4rTxQ1Rclu5VXpqJqes2uZP18zPk8VB3l0SVaxTCuzZnpcG FGbNgfF6OJg6y3r67yK/F4AQN5ZLEYQ2szTO0vMl4DZuFB0KhOqN4O9pb3HGjcUxoyIiwJtjtmO xFvwrR7bGNzoApTNIDha2Pjjw03Ri1a/hsUjfagw+NlW+e0o8OkJzEdrHsP8lglBnGZ9gENS/As CEN4OG0ECLkTWwAiA9EojIeXIgScIXtNa7We1RXtP07ffy0kEOwamzVXDIwCEQolzrK0ndmmsn/ U5L0Q0hthIHLi8vq6rraWCNpt6i9bdggVetAejxtqFEB0lRr5PTNhhTvgd3fNLUEq2Dy/DmkxyY giJWt87/T+eD8TD3upaCnE9XUXPlpohXseSvBpHwvxlNxfhTd1zvEt8IQ4rniamBsRMdUm8bt0x 1vkDKSAY7eOdF07IIwn2VvVPV X-Received: by 2002:a05:7300:c00f:20b0:358:5bc0:4f08 with SMTP id 5a478bee46e88-369e84d7f7bmr9692985eec.37.1792996623075; Sun, 25 Oct 2026 23:37:03 -0700 (PDT) Received: from ramen-dev-security-2.asia-south1-c.c.ramen-dev-345017.internal (90.156.200.35.bc.googleusercontent.com. [35.200.156.90]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-369ef6a71a4sm21191609eec.8.2026.10.25.23.37.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2026 23:37:02 -0700 (PDT) From: Anil Kaushik To: mptcp@lists.linux.dev Cc: Anil Kaushik Subject: [PATCH mptcp-next v10 1/6] selftests: mptcp: connect: retry write() on EAGAIN Date: Mon, 26 Oct 2026 06:36:52 +0000 Message-Id: <20261026063657.2955783-2-anilkaushikwireless@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261026063657.2955783-1-anilkaushikwireless@gmail.com> References: <20261026063657.2955783-1-anilkaushikwireless@gmail.com> X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" mptcp_connect treats any write() error as fatal. But write() can fail with EAGAIN even after poll() said the socket was writable: the MPTCP send buffer shrinks when a subflow is closed. The tool then exits and the transfer fails on both sides. Instead, go back to poll() and wait for more space. If a poll timeout is set, still fail after as many retries, 1ms apart: poll() does not check every cause of EAGAIN. Fixes: 048d19d444be ("mptcp: add basic kselftest for mptcp") Signed-off-by: Anil Kaushik --- Notes: v6: - the comment says the limit only applies with a poll timeout (netdev Sashiko) v5: - no change v4: - count the EAGAIN retries, not ms (Sashiko) - no limit when there is no poll timeout, -t 0 (Sashiko) v3: - do not wait forever on EAGAIN (Sashiko) - wrap lines over 80 columns v2: - Fixes tag .../selftests/net/mptcp/mptcp_connect.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/test= ing/selftests/net/mptcp/mptcp_connect.c index 178d98d91fea..49017d00ab69 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c @@ -638,6 +638,7 @@ static int copyfd_io_poll(int infd, int peerfd, int out= fd, .events =3D POLLIN | POLLOUT, }; unsigned int total_wlen =3D 0, total_rlen =3D 0; + int eagain_cnt =3D 0; =20 set_nonblock(peerfd, true); =20 @@ -711,6 +712,22 @@ static int copyfd_io_poll(int infd, int peerfd, int ou= tfd, =20 bw =3D do_rnd_write(peerfd, winfo->buf + winfo->off, winfo->len); if (bw < 0) { + /* POLLOUT does not guarantee that + * the next write will not block: + * the MPTCP send buffer can shrink + * in between, e.g. when a subflow + * is closed. Wait for more space, + * but not forever if a poll timeout + * is set: poll() does not check + * every cause of EAGAIN. + */ + if (errno =3D=3D EAGAIN && + (poll_timeout < 0 || + ++eagain_cnt <=3D poll_timeout)) { + usleep(1000); + continue; + } + /* expected reset, continue to read */ if (cfg_rcv_trunc && (errno =3D=3D ECONNRESET || @@ -723,6 +740,7 @@ static int copyfd_io_poll(int infd, int peerfd, int out= fd, return 111; } =20 + eagain_cnt =3D 0; winfo->off +=3D bw; winfo->len -=3D bw; total_wlen +=3D bw; --=20 2.25.1 From nobody Thu Nov 5 07:28:49 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792996626; b=4P/ycZK0z1m2R/OA3kwUIgDUNiYtGXqIR/jK0oQGBaTZszpY5MXf3iD8Uksb+qDEJl6r vwJxnwlkh/g9RvJTF8OMJwu49eSYoL7/TQ+cwn78+T8/Hv6sMalmK5vdobcqJG5/qCL4l cVIS3rR7z4zbXKF4NIV/SDfgy4vHKHAIYiRK8uewFQP9V9GuHg7iUtaKWLAR2RELhTc23 0RAw79auK5sGrtRVX23O3eU6q6v30f8NTbPvHxY4fRrVrnHByAPDP/7on6WS3CYRlYrdy WhvbqN8WlooYjxm/VAQHgjpZJTxrODv7pBrMESommZYDnq1zg03UCsjUpYP1F9s55bQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792996626; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=RhdWlyO5Sam//srEVeWFrjzifW9W6rttgI3RE0aHgEU=; b=whMMadm8Z/BeoR6Sh/TSMiyDeOcMcPvuVEIfk8OBNBBrwspufWMyK5aW73sQN3Yool1a /wwzwA9puw76DnN4fL3bpx9C/BokTkdH+hsFxJCqKbCevbTcsW6iEkFL/l9xaIWKHuddS KN5M5JB/adlrZdJ4F1e/5TxR4v+HFshBq8KHWrY8vD3RZUV9Ti81UEh/fmmVR1J0iNDfT QntKMAyqj8mjwIG3wvGpADA9zw6orXs0aEHjVYivL3d7MCX4ShsjBby4DPbBBh0sIpoI3 IyyOUlZSy+TJ2B0iVkT/CErQy0EtoO/+X6K72PjHeDEFRSNREeJjrlQQe9F8l0goWRQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=GMRVLTLl; arc=none smtp.remote-ip=74.125.82.172 Received: from mail-dy1-f172.google.com (mail-dy1-f172.google.com [74.125.82.172]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5EFEA606A31A for ; Mon, 26 Oct 2026 06:37:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5EFEA606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=GMRVLTLl Received: by mail-dy1-f172.google.com with SMTP id 5a478bee46e88-3282db206d3so5207770eec.0 for ; Sun, 25 Oct 2026 23:37:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792996625; x=1793601425; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=RhdWlyO5Sam//srEVeWFrjzifW9W6rttgI3RE0aHgEU=; b=GMRVLTLlCmgHM2bdqY4wwELY6Zfn8QDJABxLSOGR19SjhOJ/xNC8iZQgx5fb9ag+Qn L9S1YLRjV3iD8Inp7ZAs3lkaH8oYtxfZLQ3KUOw4ZSpZzE1iuyPxGQqhf0SNto99vN4M YrWTXypAv5oQPo4hsuidXcr2KhWEHgFRfvE5gypXuSRquvk9VPGsSu/eA1mYAI7T0PYE wwRavhGuSlwQlmkVg30JiUYvxWdesNgUUpq5xyKBYXqJPj2ycYT+U7oPw/IeNXJb+TRn XAiShSIRnTsZvofmFI0qdnq+qN5ir79F5g+IuXUpwrIuuLxpI6Kqr1lXMF1yT/3m3k3P rctA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792996625; x=1793601425; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=RhdWlyO5Sam//srEVeWFrjzifW9W6rttgI3RE0aHgEU=; b=MNAqpWtpKPGAJJul0sduJMuxLR3GrQSfpY644L0l1Q09+DWrMnew92UMcNtbFQgxQ5 LKWqVSe+TXlo+0hQgzt1KEdy2WUQQdaF794bMpa2tLBCf8FHhRfAsq1jiE52Qd9h6OX0 jW4FZYgAR6fbem/Ax+kboGB92eKGVHisrdoey18eRQvN4mjdJkMvDCNNDfXSO8cPGbwa /NrPB5VzIDfUGVKvLkFanMujmZ4iBtqiKeBbBcgVwlmbg27tijruPp4f8uvjMzoKrJSA RURPUCIkY0XPj3vSSvj/glAZL2vdXFg/5RMfI9AmAuzV7xFbrjlI659OHO8NtU4iHECo M3DA== X-Gm-Message-State: AFq9FYL2X5Rz/z6c1MGWCDOr/fMZHVY30EUGg1ik70mCfSCvMaTvLtpq 8BHhB3Q2naOPA/yzSoVunPe738AikpgTQdBqm+wMcrjMeStg/gjbPPofPhAAkA== X-Gm-Gg: AYBFou1ldaB/8VW0Z9RsSxRIBnuVBWuAwG39vCAiPovCFBsqwuITr2JtM4btqw/HW7Y AUMHPoqx8m/fnljk5wIXuIZalXu2Lid7IBP+L9t30KTyrom/6CGRIf1LvTiiXmpMZva4mk6Xfk+ jyZxZVPRZ1nm2DPCfeGLH55pt0k4dVijkOvk+rm9w+1/WDc8bORWHnJtQHScgUO0kB3r48LcZJq q1phSquXmZYRH6t5Q0wB74GHqMbba7ksIALbBcZAMlLewVDXRa5OjtW6+xERC/hi1ZMfXZDGneJ VDTCtaKHg/yHFf5xnXO0+eZjnE/Ob4e3CPJ4H+8fe/zj/oe464DgNdG7kX/LnvFm2frQB1AyRjJ U5tp/XbldsJf+aQ/rVpWaV/2NyQBoEjRdpmF8+GQgAkMgduTynrbt6WXorQikWvgepTPpykbTiY xyezVyXOetki+xnsr90zd2iSpD6ZT4mknrnUN2UKAHupUu+0+WSv+LFRkWo5YHEeWW1FH2/7tY+ ayXBbIKqpEduWhqszc+VWJEeyBH5yXbWjDVywW6jS9+/BJfFMc5KOi4XRLuKCzlGE1hwhtXnh2q V1BS+DoTQSgolB3plVaYgdjVgEqQnb3fo1qlbVQbZAPcAVF3CNpwZ0xcD5XxK477LOiS1lqyx6I EE3SZxzMCvKJFGKC9n0hztxsW X-Received: by 2002:a05:693c:8211:b0:360:8596:657d with SMTP id 5a478bee46e88-369e850e61emr8948308eec.32.1792996625006; Sun, 25 Oct 2026 23:37:05 -0700 (PDT) Received: from ramen-dev-security-2.asia-south1-c.c.ramen-dev-345017.internal (90.156.200.35.bc.googleusercontent.com. [35.200.156.90]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-369ef6a71a4sm21191609eec.8.2026.10.25.23.37.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2026 23:37:04 -0700 (PDT) From: Anil Kaushik To: mptcp@lists.linux.dev Cc: Anil Kaushik Subject: [PATCH mptcp-next v10 2/6] netlink: specs: mptcp: add the subflow-retries attribute Date: Mon, 26 Oct 2026 06:36:53 +0000 Message-Id: <20261026063657.2955783-3-anilkaushikwireless@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261026063657.2955783-1-anilkaushikwireless@gmail.com> References: <20261026063657.2955783-1-anilkaushikwireless@gmail.com> X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It will be used by the in-kernel PM to set the number of SYN retransmissions of a subflow re-created after a timeout, with the other limits: add it to the set-limits and get-limits commands. The uapi header and the generated files are updated with ynl-regen. Signed-off-by: Anil Kaushik --- Notes: v9: - after a timeout, not any error, and about 4 hours with the default RTO settings v8: - the default is the maximum, MAX_TCP_SYNCNT (127) (Matthieu) v7: - the doc gives the default value (netdev Sashiko) v6 (netdev Sashiko): - the policy checks the maximum value, 127 (MAX_TCP_SYNCNT) - the doc says the value works like TCP_SYNCNT v5: - new, split from the retry patch (Matthieu) Documentation/netlink/specs/mptcp_pm.yaml | 13 +++++++++++++ include/uapi/linux/mptcp_pm.h | 1 + net/mptcp/mptcp_pm_gen.c | 10 ++++++---- net/mptcp/mptcp_pm_gen.h | 4 ++-- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Documentation/netlink/specs/mptcp_pm.yaml b/Documentation/netl= ink/specs/mptcp_pm.yaml index 39f3facc38e5..690d3c5dfdd2 100644 --- a/Documentation/netlink/specs/mptcp_pm.yaml +++ b/Documentation/netlink/specs/mptcp_pm.yaml @@ -196,6 +196,16 @@ attribute-sets: name: addr-remote type: nest nested-attributes: address + - + name: subflow-retries + type: u32 + checks: + max: 127 + doc: | + SYN retries of a subflow re-created after a timeout, like the + TCP_SYNCNT socket option, so with tcp_syn_linear_timeouts on top. + The default is the maximum, MAX_TCP_SYNCNT (127), about 4 hours + with the default RTO settings. 0 to not re-create it. - name: event-attr enum-name: mptcp-event-attr @@ -327,6 +337,7 @@ operations: attributes: - rcv-add-addrs - subflows + - subflow-retries - name: get-limits doc: Get protocol limits @@ -337,10 +348,12 @@ operations: attributes: - rcv-add-addrs - subflows + - subflow-retries reply: attributes: - rcv-add-addrs - subflows + - subflow-retries - name: set-flags doc: Change endpoint flags diff --git a/include/uapi/linux/mptcp_pm.h b/include/uapi/linux/mptcp_pm.h index fe9863d75350..43e9643deda9 100644 --- a/include/uapi/linux/mptcp_pm.h +++ b/include/uapi/linux/mptcp_pm.h @@ -102,6 +102,7 @@ enum { MPTCP_PM_ATTR_TOKEN, MPTCP_PM_ATTR_LOC_ID, MPTCP_PM_ATTR_ADDR_REMOTE, + MPTCP_PM_ATTR_SUBFLOW_RETRIES, =20 __MPTCP_ATTR_AFTER_LAST }; diff --git a/net/mptcp/mptcp_pm_gen.c b/net/mptcp/mptcp_pm_gen.c index c180930a8e0e..e2d4af1bc1d5 100644 --- a/net/mptcp/mptcp_pm_gen.c +++ b/net/mptcp/mptcp_pm_gen.c @@ -44,15 +44,17 @@ const struct nla_policy mptcp_pm_flush_addrs_nl_policy[= MPTCP_PM_ENDPOINT_ADDR + }; =20 /* MPTCP_PM_CMD_SET_LIMITS - do */ -const struct nla_policy mptcp_pm_set_limits_nl_policy[MPTCP_PM_ATTR_SUBFLO= WS + 1] =3D { +const struct nla_policy mptcp_pm_set_limits_nl_policy[MPTCP_PM_ATTR_SUBFLO= W_RETRIES + 1] =3D { [MPTCP_PM_ATTR_RCV_ADD_ADDRS] =3D { .type =3D NLA_U32, }, [MPTCP_PM_ATTR_SUBFLOWS] =3D { .type =3D NLA_U32, }, + [MPTCP_PM_ATTR_SUBFLOW_RETRIES] =3D NLA_POLICY_MAX(NLA_U32, 127), }; =20 /* MPTCP_PM_CMD_GET_LIMITS - do */ -const struct nla_policy mptcp_pm_get_limits_nl_policy[MPTCP_PM_ATTR_SUBFLO= WS + 1] =3D { +const struct nla_policy mptcp_pm_get_limits_nl_policy[MPTCP_PM_ATTR_SUBFLO= W_RETRIES + 1] =3D { [MPTCP_PM_ATTR_RCV_ADD_ADDRS] =3D { .type =3D NLA_U32, }, [MPTCP_PM_ATTR_SUBFLOWS] =3D { .type =3D NLA_U32, }, + [MPTCP_PM_ATTR_SUBFLOW_RETRIES] =3D NLA_POLICY_MAX(NLA_U32, 127), }; =20 /* MPTCP_PM_CMD_SET_FLAGS - do */ @@ -127,7 +129,7 @@ const struct genl_ops mptcp_pm_nl_ops[11] =3D { .validate =3D GENL_DONT_VALIDATE_STRICT, .doit =3D mptcp_pm_nl_set_limits_doit, .policy =3D mptcp_pm_set_limits_nl_policy, - .maxattr =3D MPTCP_PM_ATTR_SUBFLOWS, + .maxattr =3D MPTCP_PM_ATTR_SUBFLOW_RETRIES, .flags =3D GENL_UNS_ADMIN_PERM, }, { @@ -135,7 +137,7 @@ const struct genl_ops mptcp_pm_nl_ops[11] =3D { .validate =3D GENL_DONT_VALIDATE_STRICT, .doit =3D mptcp_pm_nl_get_limits_doit, .policy =3D mptcp_pm_get_limits_nl_policy, - .maxattr =3D MPTCP_PM_ATTR_SUBFLOWS, + .maxattr =3D MPTCP_PM_ATTR_SUBFLOW_RETRIES, }, { .cmd =3D MPTCP_PM_CMD_SET_FLAGS, diff --git a/net/mptcp/mptcp_pm_gen.h b/net/mptcp/mptcp_pm_gen.h index b9280bcb43f5..5b4dee8a0a34 100644 --- a/net/mptcp/mptcp_pm_gen.h +++ b/net/mptcp/mptcp_pm_gen.h @@ -23,9 +23,9 @@ extern const struct nla_policy mptcp_pm_get_addr_nl_polic= y[MPTCP_PM_ATTR_TOKEN + =20 extern const struct nla_policy mptcp_pm_flush_addrs_nl_policy[MPTCP_PM_END= POINT_ADDR + 1]; =20 -extern const struct nla_policy mptcp_pm_set_limits_nl_policy[MPTCP_PM_ATTR= _SUBFLOWS + 1]; +extern const struct nla_policy mptcp_pm_set_limits_nl_policy[MPTCP_PM_ATTR= _SUBFLOW_RETRIES + 1]; =20 -extern const struct nla_policy mptcp_pm_get_limits_nl_policy[MPTCP_PM_ATTR= _SUBFLOWS + 1]; +extern const struct nla_policy mptcp_pm_get_limits_nl_policy[MPTCP_PM_ATTR= _SUBFLOW_RETRIES + 1]; =20 extern const struct nla_policy mptcp_pm_set_flags_nl_policy[MPTCP_PM_ATTR_= ADDR_REMOTE + 1]; =20 --=20 2.25.1 From nobody Thu Nov 5 07:28:49 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792996628; b=QtiVfSZu3TO4HTXTzZvujHNqSPY+WoU1vBqWLD+xwZO0LH+80z7HYsmUbStQJUapeGEN FK3K8zDWvUPaEh/Bn3Be5yhTe+L17kuu7LRXOACFaJENlkmWd63aMT9KwgB1HPxZo39TQ AUWAsJtbCNgoUKEtVa0UJxGZyfPxhlTGqB9S3WmMq1dLuW21UP7Jn1sOqqWLEIef8hSPW L+Tly7qKIwvAtZrXOnjFBjv5vNK2UamgVn3eupVqnRyBgQl0ZU/9BE8x6kjNP/B+VfvNb mZ/C5SBkH9XpDhHrTyB+3qNTVENdd/vfXqGT1Nj7QnX2kF3uuJeUD8oH0VAppFVrDgA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792996628; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=GMa51ST4XjCQkd4qYSnBFNlKaUJYxzH2Que0Zxlz+Ok=; b=IcTzA2HLVcvEP91ewTeSTLzzMI2vGYgKGchsMH5cgUJaJ0X8lDGVjBwJN2t8FUbg4qBX 5K+N+A4GSfqAuUDIBhClP+fVyCvRlZzCMxaHQxCU7/lniPRnHZGaRzWCsQd7mU5vWZzIi i6DpvzCG2554hpPsXQ5LR5VGY3SkkLam3M8bDpDxgSbn2zrdie6J2Bg+kuxiyiBE4AGGv N32MMQ5w7MeYFcjBtTPyPfrcMyww7jApjeOTulMmGJBj49HeIwDQftWSSWh6KEd6AzE3N bbyrBQ6C9vbcq7qg3ZZUxC77TZBdhj+KOIAUHik8IckZBTTDMYn6nOg89VtJ7Q07tDA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=Oe2QY0bh; arc=none smtp.remote-ip=74.125.82.170 Received: from mail-dy1-f170.google.com (mail-dy1-f170.google.com [74.125.82.170]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 569D2606A31A for ; Mon, 26 Oct 2026 06:37:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 569D2606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=Oe2QY0bh Received: by mail-dy1-f170.google.com with SMTP id 5a478bee46e88-369f3e9e431so373857eec.1 for ; Sun, 25 Oct 2026 23:37:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792996627; x=1793601427; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=GMa51ST4XjCQkd4qYSnBFNlKaUJYxzH2Que0Zxlz+Ok=; b=Oe2QY0bhthBz08Df3515YtJNTGLVzWCKhUh8FDWNpd6GlF8HMRrKdYh2f9khQCMJPT fVCb/3A5/4EgkQNAjrOWkoNqUXhMl2EDY/ArCjnWEpfEHlFQVzgEoTVqxuw6iDCCYa1a NOMwUO87G5cggdyiRcS7Aed3LRGhweZTmJKR5uRvoR6DAGMVaCPrpcT7ciQeOmJY1CFi KGy/rI9k/nQuKOPX4+u1xWIviMhe5wDHCx6sPp6TZ5IqdILPdLaOlXZmvfWezqlYKNjN iHmyaRVqlBcmnEUr4oaskpsFgH6/a9tO3DfelFxqcueRl27L2TQeMQLmwyf0eq7/fkI8 oXpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792996627; x=1793601427; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=GMa51ST4XjCQkd4qYSnBFNlKaUJYxzH2Que0Zxlz+Ok=; b=HFP6MbfvAoNyF/by8CSmstiEoYP/3B4uYdan1uMLHPcPPmTsGu03Bd+6Op6snn2aIt sTx0CNINKvFwT0mAjoGf8VTryKwr+zFgLVmA0I2x6IsFWKwt63CHTku2qKMVWeSmCdrf 57hPIgwIH2GNFFfrMQ8b1ekJ61sgYAM5K6Kk2K2UNdNCMstX9SmdP0/NrwAVNSUDWpns a33VF0Zzr4BMQL5uuklQTS8G+6ORf7t0XTINy0FrxdEd4AWASGHh7HBoWYWQOWxkiCvx 7G9mKxxoQ6TGZo64Jcqsaf6s9W/hlyv4duHpd/EA2bAGg1aFuURVz8OIVFhn3xjjFEwu GDkg== X-Gm-Message-State: AFq9FYKx3onALNBs0W57nlXlC76/cOO1ocGh26vJNd/UGWuI5AKzprJQ 09AcPTpjP0W+eqGi/n3cuLmWT99Mg9bdVQ+VPAIOezga8rqk83tWBrAfyShXAw== X-Gm-Gg: AYBFou0vOnt18/twV5U14vynBewVuEM/k8iwoaV6nLZDJABHji2n8F+DYyxttcKjgUA LMoK7rjZamuHnueWn0tosia5cT+W4F+FCkqpRL0hlY1TCPBeYAhpWERRufJVQY82Rz9j86cv7yP zstdYKcaUCBhqzd01shn/Jy2brN8gjZVh//fta2kmE6VoHafH+41T4VY9Mkffl0g5Z+zb12Xyp1 0tNm+EVdVrgf7zOqMKdk8JwJTVj1bXAo9iEmB/OStKtmb/tcuVy7fsp+EGmse/ngBBuXrs/1jqU nmQdNHUJtrulxipbKf+wYfDcgHAfnLDZP4iaGzRda+Wq2FWoVy1oNBUlfAUFRpQUuBW772aqblz 7gMOTIftCQMBuTlodCNXeWj1D5VComAJlN4J1kqdRueZNjVzVgkURCSclVY14XQ242ILxrX+cui PbuSghPGVqb0oH0oJYZ/Cr2OaQhJh3EroP+ZKZoXHJ3Vf/PXzGg25mKnx6sYKkfehSaIAvtmYiA eIPThLTJvpl30AJoc2JpgKhyk7Q1U1xIl5DY7K2yrOlUWGNPtoGlF9vfHYe7ybOVb/mRWDojr+l 9ZCSoktHlRczwo29QvNe5uWlb7PaRQlmcdhC39LOMDkT7fhC4A+Hr0aXAFEo8pW61qoBQwfYkmy 84AAy3MEz+4YRfRDV0V9xpjey X-Received: by 2002:a05:693c:88ca:b0:366:6c79:212b with SMTP id 5a478bee46e88-369e85043a7mr7149926eec.25.1792996626897; Sun, 25 Oct 2026 23:37:06 -0700 (PDT) Received: from ramen-dev-security-2.asia-south1-c.c.ramen-dev-345017.internal (90.156.200.35.bc.googleusercontent.com. [35.200.156.90]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-369ef6a71a4sm21191609eec.8.2026.10.25.23.37.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2026 23:37:06 -0700 (PDT) From: Anil Kaushik To: mptcp@lists.linux.dev Cc: Anil Kaushik Subject: [PATCH mptcp-next v10 3/6] mptcp: pm: in-kernel: add the subflow-retries limit Date: Mon, 26 Oct 2026 06:36:54 +0000 Message-Id: <20261026063657.2955783-4-anilkaushikwireless@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261026063657.2955783-1-anilkaushikwireless@gmail.com> References: <20261026063657.2955783-1-anilkaushikwireless@gmail.com> X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" A new limit for the in-kernel PM, set and read with the other limits: the number of SYN retries of a subflow re-created after a timeout, like the TCP_SYNCNT socket option. The default is the maximum, MAX_TCP_SYNCNT (127), about 4 hours, and 0 to not re-create it. The netlink policy checks this maximum value. It is also exposed in struct mptcp_info, in place of the reserved field. The next patch uses it. Signed-off-by: Anil Kaushik --- Notes: v9: - MAX_TCP_SYNCNT instead of 127 for the default - after a timeout, not any error v8: - the default is the maximum, 127, about 4 hours (Matthieu) v6: - the netlink policy checks the maximum, no more parse_limit() change (netdev Sashiko) - the limit works like TCP_SYNCNT, say so (netdev Sashiko) v5: - new, split from the retry patch (Matthieu) - the limit is also in struct mptcp_info (Matthieu) include/uapi/linux/mptcp.h | 2 +- net/mptcp/pm_kernel.c | 23 ++++++++++++++++++++++- net/mptcp/protocol.h | 1 + net/mptcp/sockopt.c | 2 ++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h index 72a5d030154e..d7e3f359773d 100644 --- a/include/uapi/linux/mptcp.h +++ b/include/uapi/linux/mptcp.h @@ -72,7 +72,7 @@ struct mptcp_info { __u8 mptcpi_subflows_total; __u8 mptcpi_endp_laminar_max; __u8 mptcpi_endp_fullmesh_max; - __u8 reserved; + __u8 mptcpi_limit_subflow_retries; __u32 mptcpi_last_data_sent; __u32 mptcpi_last_data_recv; __u32 mptcpi_last_ack_recv; diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c index d3014bf57bf3..7fb4c7874340 100644 --- a/net/mptcp/pm_kernel.c +++ b/net/mptcp/pm_kernel.c @@ -25,6 +25,7 @@ struct pm_nl_pernet { u8 endp_fullmesh_max; u8 limit_add_addr_accepted; u8 limit_extra_subflows; + u8 limit_subflow_retries; u8 next_id; DECLARE_BITMAP(id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1); }; @@ -96,6 +97,14 @@ u8 mptcp_pm_get_limit_extra_subflows(const struct mptcp_= sock *msk) } EXPORT_SYMBOL_GPL(mptcp_pm_get_limit_extra_subflows); =20 +u8 mptcp_pm_get_limit_subflow_retries(const struct mptcp_sock *msk) +{ + struct pm_nl_pernet *pernet =3D pm_nl_get_pernet_from_msk(msk); + + return READ_ONCE(pernet->limit_subflow_retries); +} +EXPORT_SYMBOL_GPL(mptcp_pm_get_limit_subflow_retries); + static bool has_subflow_daddr(const struct mptcp_sock *msk, const struct mptcp_addr_info *daddr) { @@ -1419,7 +1428,8 @@ static int parse_limit(struct genl_info *info, int id= , unsigned int *limit) int mptcp_pm_nl_set_limits_doit(struct sk_buff *skb, struct genl_info *inf= o) { struct pm_nl_pernet *pernet =3D genl_info_pm_nl(info); - unsigned int rcv_addrs, subflows; + unsigned int rcv_addrs, subflows, retries; + struct nlattr *attr; int ret; =20 spin_lock_bh(&pernet->lock); @@ -1433,8 +1443,13 @@ int mptcp_pm_nl_set_limits_doit(struct sk_buff *skb,= struct genl_info *info) if (ret) goto unlock; =20 + /* the maximum, MAX_TCP_SYNCNT, is checked by the policy */ + attr =3D info->attrs[MPTCP_PM_ATTR_SUBFLOW_RETRIES]; + retries =3D nla_get_u32_default(attr, pernet->limit_subflow_retries); + WRITE_ONCE(pernet->limit_add_addr_accepted, rcv_addrs); WRITE_ONCE(pernet->limit_extra_subflows, subflows); + WRITE_ONCE(pernet->limit_subflow_retries, retries); =20 unlock: spin_unlock_bh(&pernet->lock); @@ -1464,6 +1479,10 @@ int mptcp_pm_nl_get_limits_doit(struct sk_buff *skb,= struct genl_info *info) READ_ONCE(pernet->limit_extra_subflows))) goto fail; =20 + if (nla_put_u32(msg, MPTCP_PM_ATTR_SUBFLOW_RETRIES, + READ_ONCE(pernet->limit_subflow_retries))) + goto fail; + genlmsg_end(msg, reply); return genlmsg_reply(msg, info); =20 @@ -1618,6 +1637,8 @@ static int __net_init pm_nl_init_net(struct net *net) =20 /* Cit. 2 subflows ought to be enough for anybody. */ pernet->limit_extra_subflows =3D 2; + /* the maximum: about 4 hours with the default RTOs */ + pernet->limit_subflow_retries =3D MAX_TCP_SYNCNT; pernet->next_id =3D 1; spin_lock_init(&pernet->lock); =20 diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 3be60da12924..4aa4aedb2ba7 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1266,6 +1266,7 @@ u8 mptcp_pm_get_endp_laminar_max(const struct mptcp_s= ock *msk); u8 mptcp_pm_get_endp_fullmesh_max(const struct mptcp_sock *msk); u8 mptcp_pm_get_limit_add_addr_accepted(const struct mptcp_sock *msk); u8 mptcp_pm_get_limit_extra_subflows(const struct mptcp_sock *msk); +u8 mptcp_pm_get_limit_subflow_retries(const struct mptcp_sock *msk); =20 /* called under PM lock */ static inline void __mptcp_pm_close_subflow(struct mptcp_sock *msk) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index 922f6ae5c80c..d3c4abf59ec5 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -1075,6 +1075,8 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, str= uct mptcp_info *info) mptcp_pm_get_endp_laminar_max(msk); info->mptcpi_endp_fullmesh_max =3D mptcp_pm_get_endp_fullmesh_max(msk); + info->mptcpi_limit_subflow_retries =3D + mptcp_pm_get_limit_subflow_retries(msk); } =20 if (__mptcp_check_fallback(msk)) --=20 2.25.1 From nobody Thu Nov 5 07:28:49 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792996631; b=R2iRFHHl1LKHK9GuVubGXVQ/C1CP8On7TLSwwWTS8AERfhG+kemWsDsqRPgqw6sul+N+ Rrijz+zCnSTM3DI5AruKgGeO8Yy8CrczfetkOq6BMTLyCAieyaRiBV86G4SAW447fMvbI 03qCMOCbHX4KgHnxACbJYQF/DJnHkEOdAERpHyfzAGNVosWbEH/rBtcONuFqmz7RuhRBw 1Sech9dg+V1OC0+PfrKI77psXdQX0xAQSDfS/luz2cIqXHggcxy3/6chLlyGZbILQpi4b xCvFkK2KJGNH27O5IizRdh+nYJdnnPICHSIOJBUzTZUDGiTjSd4rqMFB0+jul3q7aeg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792996631; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=aYvtl7wOKcqvvOxRN8W4EKStZc/2fE1akkjmaYjYrZ0=; b=BzKUGlT9sQ6XwWrSQQm14mb3pRGfLtomiCmZzqabBxo3vepnUlNFdgdEcORl12nE0Ust 2dJ+foYP5vzCtATqPAA7K+sr5jBk0g8bYXTbsP0FjCOBi5WKBlk4LV/xxopYj3kQ+RdP0 v3weVL1rPCObuCb1OoAvWrsOFcw9CkHSx0zHInoEQ5X4IeigL5MYcVkpK1sF7xphUD0g7 qKa9mzSilcdLNbj900IGSx9Bo66ynjftVCqWjtudqXZwLVu5FEkU1sIMHRH5ThF9tJ+aH tg+JsEM/Zt8qhw09835vMlUUxvPbBmgD5My59OXHORj88B0kaU/2JB0NwLYDJIbABPg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=tCnD3m3i; arc=none smtp.remote-ip=74.125.82.170 Received: from mail-dy1-f170.google.com (mail-dy1-f170.google.com [74.125.82.170]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 653DA606A31A for ; Mon, 26 Oct 2026 06:37:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 653DA606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=tCnD3m3i Received: by mail-dy1-f170.google.com with SMTP id 5a478bee46e88-353804b591eso4952378eec.0 for ; Sun, 25 Oct 2026 23:37:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792996629; x=1793601429; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=aYvtl7wOKcqvvOxRN8W4EKStZc/2fE1akkjmaYjYrZ0=; b=tCnD3m3itohoNm8IY6be+EowLNflcR2qbOePH+62KcKv/rrbPBZ3X4+ccjPF8PEIlR xRIrbCXtUa/0GHHh5fYwavV19vlwf19wXMfLUwm+8EHf4kyNl5VSSA9sthE9kOoCGS7y 4Lbk4z9TEMRX85ONRCmt4yqnJ6D6oysPBxVFb5PUMF2CYKmFFPAVXOM50FPop9GufjXX iLiqB3Z4OjWQMUzmULqE1v31UrpeOvGujNjXNnrc05u3K4FJw8g44VtXHa4EP2Xyt6Ab oFa0p7EitgjWMO8iH/97igKyS6gUkUt+G0/HaWolN4fPZ3mcAR21emq8hXXkYwwEWV4C wFOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792996629; x=1793601429; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=aYvtl7wOKcqvvOxRN8W4EKStZc/2fE1akkjmaYjYrZ0=; b=nZ4T9oS/lLub/OaBpwpDZ6n/q2DHlQmHxJYj19umyoiPmh1dFr2TM3Di8RbkVSTo0O qqK8kxuZfliV1/3aVuQw+ku3nvdlGDXRi9RK8Jq5Amy/o6LlXuiXRXDuzRHZe0xyNjLU xM7qc9EN6acvKdY21LqUVhTLC6lUnUIHx70V351dcyK99n/8UHQb79UNXvWCp2Tn/iUm OaWIf0oSuv2E+GPlRZ3mY9eTlnu0impuA5onDxoHVtzutMoyCnt4ebO6ab/RdLtROiJX TlGRq+7a4jikPg3PUPexK6WwdrQ2ktYPVHnM3N3dk8pYBTElPA/vXO9ac26khZE4H6R/ hrRA== X-Gm-Message-State: AFq9FYI9egUUWuI53hVPstT1gGj000/WB76GwZkHd6Wd4Q3kT87t+3jT nL6ua965pKVcRVEM14ZqrT69Trd8+JGAkdkJFQnmKdaHFUwbaNH2AlCj/AQswg== X-Gm-Gg: AYBFou0Hw1reCYtk3jlNYvSCtArsdgTib7tJyGAF3zDC6rQ3FldjQXZs6Fv/hHOtEqN HjzGBYn1MenNP2ER9yn4YEmSsik3qxObY8xWhIVB/qi/T2Ala9DK16gKXai/CIz0CZoa/MO8mLl 2X9rcqXTHtJPkaDyRqdTnHuTNr1m3QIRSdjKBOjpl09KJsq1xjWv0VwRq5TDP7E3m1QYF7OA34f QkzmnfD7yJOS4nsfOH9rrgNtN59SuNoNrg3HFSN99J49bIF1EOOdT7EYbiX+0pnJlVyxwabLyyj 3Grm886BZ3nCGSGZMqmXZb0SaN2R6mAbg4w3IbrDK/9pxr/51hCqnI1HQKu3tckw8/bRznRWfyL e4EYM4YZ86PAc71wBTEmtOJOSvc6sKhQ+9u6sFKoFXkrfrLL3ctRU9fMA71IG2+SWbJSqv9TwuM 1wzL5nJ33R7IVfQjiMB2dYClK5NyuSfYD9Hcmzh3MH+yRzKJnlLcwVIN+RCtCfwr0RaxJdVNjf1 XlEfqWcVqLUlNq7RiPm6JgW4nqWijNVcu4tqbctxDduc6UCa4fQn6Idb5gGfH4ba5UinS2KdjQx DuLsKsZZU0CzETEEtkqgVkFb76zMOmlNWUG7kGiZP5L1XINhouV88DFZ9kUGy4SMg75bXvIxy2E ZAk4c5Bkx742LdCIbcrfThwFtuMx//JhaZ4M5LW5CZWFneg== X-Received: by 2002:a05:693c:87dc:20b0:361:306f:c32a with SMTP id 5a478bee46e88-369e847acf9mr9364260eec.11.1792996628872; Sun, 25 Oct 2026 23:37:08 -0700 (PDT) Received: from ramen-dev-security-2.asia-south1-c.c.ramen-dev-345017.internal (90.156.200.35.bc.googleusercontent.com. [35.200.156.90]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-369ef6a71a4sm21191609eec.8.2026.10.25.23.37.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2026 23:37:08 -0700 (PDT) From: Anil Kaushik To: mptcp@lists.linux.dev Cc: Anil Kaushik Subject: [PATCH mptcp-next v10 4/6] mptcp: pm: in-kernel: retry subflows closed after an error Date: Mon, 26 Oct 2026 06:36:55 +0000 Message-Id: <20261026063657.2955783-5-anilkaushikwireless@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261026063657.2955783-1-anilkaushikwireless@gmail.com> References: <20261026063657.2955783-1-anilkaushikwireless@gmail.com> X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" With the in-kernel PM, a subflow closed after an error, e.g. a timeout when a path silently drops packets, is never re-created, even once the path works again. For example, with a main link and a backup link, connections move to the backup after an outage but never come back. When TCP gives up on an established subflow created by this side, after a retransmission or keepalive timeout, whatever ICMP error was received from the path before, the PM now creates a new one with the same addresses. Its SYN retries, set like TCP_SYNCNT by the subflow-retries limit, space out the attempts. This is a single connection attempt: an ICMP error, or a local error when connecting, ends it, and it is not retried again. It is also closed if the MPTCP socket is closed in the meantime. If no other subflow can send data, the connection is still closed after the close timeout, as when all the subflows are closed, unless the new subflow connects before. Once it is established, it is handled like any other subflow. Re-creating the initial subflow uses one of the additional subflows allowed by the limits. __mptcp_close_ssk() now always cleans the references to the closed subflow in the MPTCP backlog, not only with MPTCP_CF_PUSH: a re-created subflow closed with the MPTCP socket can get established in between. The other paths without MPTCP_CF_PUSH have already purged the backlog. A subflow reset by the peer, or by anything on the path, is not re-created: the path works, and re-creating it right away could loop. A subflow that never got established is not re-created either: the PM keeps trying the next endpoints, as before. Subflows aborted locally, also by MPTCP, or using an address that has been removed are not retried. TCP only closes a subflow after tcp_retries2 retransmissions, about 15 minutes by default. A subflow that only receives data never gets an error: the application has to enable TCP keepalive on the MPTCP socket, which MPTCP applies to all the subflows. Both are documented in mptcp.rst. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/440 Signed-off-by: Anil Kaushik --- Notes: v10: - keep the connection when the close timeout expires if a re-created subflow connected in the meantime: an active join does not stop the timer, mptcp_finish_join() returns early for it (sashiko.dev) - close the re-created subflows still connecting once the msk is no longer established, after a DATA_FIN or a shutdown(), when no other subflow is left: they cannot join anymore, and would keep the msk around (sashiko.dev) v9: - every timeout is retried, whatever ICMP error TCP reports for it, the last one received, see tcp_write_err(): resets, local aborts and MPTCP protocol errors are excluded instead of listing the timeout errors, so IPv4 and IPv6 behave the same (netdev Sashiko) - mptcp.rst: 0 does not re-create the subflows (netdev Sashiko) - the re-created subflows closed with the msk get no SUB_CLOSED event, like the other subflows closed with it - if no other subflow can send data, the close timeout still applies: creating the new subflow no longer keeps the connection open for the whole SYN retries - doc and commit message: a single connection attempt, ended by an ICMP error or a local connect error - __mptcp_close_ssk() always cleans the msk backlog of the closed subflow: a re-created subflow closed with the msk can have been established in between, with data in the backlog (netdev Sashiko). It is still closed without MPTCP_CF_PUSH, which would re-send all the pending data - tcp_sock_set_syncnt(), without the ssk lock v8: - mptcp.rst gives the default, 127, about 4 hours - close the re-created subflows still connecting before __mptcp_wr_shutdown() disconnects them, and also the already disconnected ones, e.g. after shutdown(SHUT_WR) (sashiko.dev) - mptcp.rst: the initial subflow on the client side, the subflows limit, and only one attempt (netdev Sashiko) v7: - only after a path error, a retransmission or keepalive timeout: a reset from the peer or the path could make it loop (netdev Sashiko) - retry and no_retry are bools under the msk socket lock, in the padding after close_event_done, not bits next to the reset ones (netdev Sashiko) - mark all the subflows using a removed address, whatever their state (netdev Sashiko) - doc: tcp_retries2, and keepalive for a subflow that only receives data (Abdul Wasey's tests) - not retried after a reset by MPTCP itself, even with an old sk_err left by IP_RECVERR (netdev Sashiko) - close the re-created subflows still connecting without MPTCP_CF_PUSH: they never carried data (netdev Sashiko) v6 (netdev Sashiko): - only re-create subflows that were established: the PM still tries the next endpoints when one never gets established - only once TCP closed the subflow, to read its reset flags safely - removed addresses, also the remote ones and the local ID 0: the dead subflows are marked in mptcp_pm_rm_addr_or_subflow(), instead of looking up the endpoint v5 (Matthieu): - split in 4 patches - reverse xmas tree in mptcp_pm_kernel_retry_check() - "in-kernel" in the subject, like the other in-kernel PM patches - close the re-created subflows still connecting when the socket is closed (Matthieu: closing the socket during a retry) v4 (Matthieu): - netlink limit, on by default, instead of the sysctl - one new subflow per failure, its SYN retries set from the limit: no socket reuse, no attempts counter, no 60s check - no MIB counter - not retried if the endpoint was removed, instead of the pm.c change - called through pm.c - new bit in the subflow context, no new hole - commit message: MP_RST, not any RST (Sashiko) v3 (Sashiko): - no retry after MP_RST without the T flag, local abort or EBADMSG - no retry on a removed endpoint or address - use only request_bkup for the backup flag v2: - use the subflow sockets, no list or timer - code moved to pm_kernel.c Documentation/networking/mptcp.rst | 18 +++++ net/mptcp/pm.c | 39 ++++++++++ net/mptcp/pm_kernel.c | 118 +++++++++++++++++++++++++++++ net/mptcp/protocol.c | 108 ++++++++++++++++++++++++-- net/mptcp/protocol.h | 19 +++++ 5 files changed, 296 insertions(+), 6 deletions(-) diff --git a/Documentation/networking/mptcp.rst b/Documentation/networking/= mptcp.rst index b6753ffb9c9a..8a2c9b9d2a4f 100644 --- a/Documentation/networking/mptcp.rst +++ b/Documentation/networking/mptcp.rst @@ -73,6 +73,24 @@ To be able to use multiple IP addresses on a host to cre= ate multiple *subflows* addresses can be used. This can be configured with ``ip mptcp endpoint`` f= or example. =20 +When TCP gives up on an established subflow created by this host, after a +retransmission or keepalive timeout, the in-kernel path manager creates it +again, with the ``subflow-retries`` limit as its number of SYN retries, li= ke +``TCP_SYNCNT``: 127 by default, about 4 hours, and 0 to not re-create it. = This +is done for the additional subflows, and for the initial one on the client= side: +the new subflow then takes one of the additional subflows allowed by the +``subflows`` limit. This is a single connection attempt: an ICMP error, or= a +local error when connecting, ends it, and it is not created again. If no o= ther +subflow can send data in the meantime, the connection is closed after +``close_timeout``, as when all the subflows are closed, unless the new sub= flow +connects before. A subflow reset by the peer, or by anything on the path, = is not +created again either. TCP only gives up on a subflow after ``tcp_retries2`` +retransmissions, about 15 minutes by default: shorter outages are handled = by TCP +itself. A subflow that only receives data does not notice that its path st= opped +working: the application should then enable TCP keepalive on the MPTCP soc= ket +(``SO_KEEPALIVE``, ``TCP_KEEPIDLE``, ``TCP_KEEPINTVL`` and ``TCP_KEEPCNT``= ), +which MPTCP applies to all its subflows. + Packet Scheduler ---------------- =20 diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index d7c5b50b34cc..2bb08be95cd1 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -694,6 +694,26 @@ void mptcp_pm_subflow_check_next(struct mptcp_sock *ms= k, spin_unlock_bh(&pm->lock); } =20 +/* Called with the msk socket lock held, before closing a subflow: true if + * it has to be re-created once closed, see mptcp_pm_subflow_retry(). + */ +bool mptcp_pm_subflow_retry_check(struct mptcp_sock *msk, + const struct mptcp_subflow_context *subflow, + struct mptcp_pm_retry *retry) +{ + if (!mptcp_pm_is_kernel(msk)) + return false; + + return mptcp_pm_kernel_retry_check(msk, subflow, retry); +} + +void mptcp_pm_subflow_retry(struct mptcp_sock *msk, + const struct mptcp_pm_retry *retry) +{ + if (mptcp_pm_is_kernel(msk)) + mptcp_pm_kernel_retry(msk, retry); +} + void mptcp_pm_add_addr_received(const struct sock *ssk, const struct mptcp_addr_info *addr) { @@ -762,6 +782,24 @@ static void mptcp_pm_add_addr_send_ack(struct mptcp_so= ck *msk) mptcp_pm_schedule_work(msk, MPTCP_PM_ADD_ADDR_SEND_ACK); } =20 +/* A subflow using a removed address must not be re-created, whatever its + * state, e.g. closed by TCP but not collected yet, see + * mptcp_pm_kernel_retry_check(). + */ +static void mptcp_pm_rm_no_retry(struct mptcp_subflow_context *subflow, + enum linux_mptcp_mib_field rm_type, u8 rm_id) +{ + u8 id; + + if (rm_type =3D=3D MPTCP_MIB_RMADDR) + id =3D READ_ONCE(subflow->remote_id); + else + id =3D subflow_get_local_id(subflow); + + if (id =3D=3D rm_id) + subflow->no_retry =3D true; +} + static void mptcp_pm_rm_addr_or_subflow(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list, enum linux_mptcp_mib_field rm_type) @@ -794,6 +832,7 @@ static void mptcp_pm_rm_addr_or_subflow(struct mptcp_so= ck *msk, int how =3D RCV_SHUTDOWN | SEND_SHUTDOWN; u8 id =3D subflow_get_local_id(subflow); =20 + mptcp_pm_rm_no_retry(subflow, rm_type, rm_id); if ((1 << inet_sk_state_load(ssk)) & (TCPF_FIN_WAIT1 | TCPF_FIN_WAIT2 | TCPF_CLOSING | TCPF_CLOSE)) continue; diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c index 7fb4c7874340..de84aecd6a62 100644 --- a/net/mptcp/pm_kernel.c +++ b/net/mptcp/pm_kernel.c @@ -1610,6 +1610,124 @@ bool mptcp_pm_nl_check_work_pending(struct mptcp_so= ck *msk) return true; } =20 +/* TCP gave up on the path: after a retransmission, keepalive or user + * timeout, sk_err is ETIMEDOUT, or the last ICMP error received from the + * path, see tcp_write_err(). The other errors on an established subflow + * are not path failures: a reset, from the peer or from anything on the + * path (ECONNRESET, or EPIPE in CLOSE_WAIT, see tcp_reset()), a local + * abort (ECONNABORTED), or an MPTCP protocol error (EBADMSG). + */ +static bool mptcp_pm_retry_path_error(int err) +{ + switch (err) { + case ECONNRESET: + case EPIPE: + case ECONNABORTED: + case EBADMSG: + return false; + } + + return true; +} + +/* Called with the msk socket lock held, before the subflow is closed */ +bool mptcp_pm_kernel_retry_check(struct mptcp_sock *msk, + const struct mptcp_subflow_context *subflow, + struct mptcp_pm_retry *retry) +{ + struct sock *ssk =3D mptcp_subflow_tcp_sock(subflow); + struct sock *sk =3D (struct sock *)msk; + int err; + + /* Only once TCP closed it: the acquire in inet_sk_state_load() makes + * sure sk_err and the resetting flag checked below are the ones of + * this close. + */ + if (inet_sk_state_load(ssk) !=3D TCP_CLOSE) + return false; + + err =3D READ_ONCE(ssk->sk_err); + retry->syn_retries =3D mptcp_pm_get_limit_subflow_retries(msk); + if (!retry->syn_retries || !err || sk->sk_state !=3D TCP_ESTABLISHED || + __mptcp_check_fallback(msk)) + return false; + + /* mptcp_close_ssk() will not handle it again, e.g. the initial + * subflow, kept in the list once closed + */ + if (subflow->close_event_done || READ_ONCE(subflow->local_id) < 0) + return false; + + /* Only a path that worked is tried again. If a subflow never got + * established, the PM moves on to the next endpoints instead, and a + * re-created subflow that cannot connect is not retried again: its SYN + * retransmissions already spaced out the tries. + */ + if (!READ_ONCE(subflow->fully_established)) + return false; + + /* its address has been removed, see mptcp_pm_rm_addr_or_subflow() */ + if (subflow->no_retry) + return false; + + /* Only when the path stopped working. A reset, from the peer or from + * anything on the path, means the path works: re-creating the subflow + * right away could loop. Not after a reset by MPTCP itself either, with + * mptcp_subflow_reset(), whatever sk_err says. + */ + if (!mptcp_pm_retry_path_error(err) || subflow->resetting) + return false; + + /* Only re-create subflows initiated by this side: MP_JOIN ones, or the + * initial one on the client side. + */ + if (!subflow->request_join && + (subflow->mp_join || READ_ONCE(msk->pm.server_side))) + return false; + + mptcp_remote_address((struct sock_common *)ssk, &retry->remote); + retry->remote.id =3D READ_ONCE(subflow->remote_id); + if (!retry->remote.id && READ_ONCE(msk->pm.remote_deny_join_id0)) + return false; + + mptcp_local_address((struct sock_common *)ssk, &retry->local.addr); + retry->local.addr.port =3D 0; + retry->local.addr.id =3D subflow_get_local_id(subflow); + retry->local.flags =3D subflow->request_bkup ? + MPTCP_PM_ADDR_FLAG_BACKUP : 0; + retry->local.ifindex =3D ssk->sk_bound_dev_if; + + return true; +} + +/* Called with the msk socket lock held, after the subflow has been closed= */ +void mptcp_pm_kernel_retry(struct mptcp_sock *msk, + const struct mptcp_pm_retry *retry) +{ + struct mptcp_subflow_context *subflow; + struct sock *sk =3D (struct sock *)msk; + bool allowed; + + spin_lock_bh(&msk->pm.lock); + allowed =3D msk->pm.extra_subflows < + mptcp_pm_get_limit_extra_subflows(msk); + if (allowed) + msk->pm.extra_subflows++; + spin_unlock_bh(&msk->pm.lock); + + if (!allowed || + __mptcp_subflow_connect(sk, &retry->local, &retry->remote)) + return; + + /* the new subflow is the last one */ + subflow =3D list_last_entry(&msk->conn_list, struct mptcp_subflow_context, + node); + /* from 1 to MAX_TCP_SYNCNT, see mptcp_pm_kernel_retry_check() */ + tcp_sock_set_syncnt(mptcp_subflow_tcp_sock(subflow), + retry->syn_retries); + subflow->retry =3D true; +} + /* Called under PM lock */ void __mptcp_pm_kernel_worker(struct mptcp_sock *msk) { diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 02a4f479d9d8..6d3232dc2b19 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2697,8 +2697,11 @@ static void __mptcp_close_ssk(struct sock *sk, struc= t sock *ssk, lock_sock_nested(ssk, SINGLE_DEPTH_NESTING); subflow->closing =3D 1; =20 - if (flags & MPTCP_CF_PUSH) - mptcp_cleanup_ssk_backlog(sk, ssk); + /* also without MPTCP_CF_PUSH: a re-created subflow closed with the msk + * can have been established in between, see + * mptcp_close_retry_subflows() + */ + mptcp_cleanup_ssk_backlog(sk, ssk); =20 /* Borrow the fwd allocated page left-over; fwd memory for the subflow * could be negative at this point, but will be reach zero soon - when @@ -2788,6 +2791,78 @@ static void __mptcp_close_ssk(struct sock *sk, struc= t sock *ssk, } } =20 +/* Re-created subflows still connecting are useless once the msk is closed, + * or no longer established: they cannot join anymore, see + * mptcp_finish_join(), and would keep it around. + */ +static void mptcp_close_retry_subflows(struct sock *sk) +{ + struct mptcp_subflow_context *subflow, *tmp; + struct mptcp_sock *msk =3D mptcp_sk(sk); + + mptcp_for_each_subflow_safe(msk, subflow, tmp) { + struct sock *ssk =3D mptcp_subflow_tcp_sock(subflow); + int state; + + if (!subflow->retry || READ_ONCE(subflow->fully_established)) + continue; + + /* still connecting, or already disconnected by + * mptcp_subflow_shutdown(), e.g. after shutdown(SHUT_WR) + */ + state =3D inet_sk_state_load(ssk); + if (state !=3D TCP_SYN_SENT && state !=3D TCP_CLOSE) + continue; + + /* Checked without the ssk lock: it can have been established + * in between. __mptcp_close_ssk() cleans its data in the msk + * backlog, and the MPTCP retransmissions cover what it sent. + * No need to push the pending data again. + */ + mptcp_pm_subflow_check_next(msk, subflow); + __mptcp_close_ssk(sk, ssk, subflow, 0); + } +} + +static bool mptcp_has_active_subflow(struct mptcp_sock *msk) +{ + struct mptcp_subflow_context *subflow; + + mptcp_for_each_subflow(msk, subflow) { + if (__mptcp_subflow_active(subflow)) + return true; + } + + return false; +} + +/* With no subflow left to send data, a re-created subflow still connecting + * must not keep the connection open longer than the close timeout, as when + * all the subflows are closed, see __mptcp_close_ssk(). mptcp_worker() ke= eps + * the connection if the subflow connected in the meantime. + */ +static void mptcp_retry_check_tout(struct sock *sk) +{ + struct mptcp_subflow_context *subflow; + struct mptcp_sock *msk =3D mptcp_sk(sk); + bool connecting =3D false; + + if (inet_csk(sk)->icsk_mtup.probe_timestamp || + mptcp_has_active_subflow(msk)) + return; + + mptcp_for_each_subflow(msk, subflow) + connecting |=3D subflow->retry && + !READ_ONCE(subflow->fully_established); + if (!connecting) + return; + + if (sk->sk_state =3D=3D TCP_ESTABLISHED) + mptcp_start_tout_timer(sk); + else + mptcp_close_retry_subflows(sk); +} + void mptcp_close_ssk(struct sock *sk, struct sock *ssk, struct mptcp_subflow_context *subflow) { @@ -2806,6 +2881,7 @@ void mptcp_close_ssk(struct sock *sk, struct sock *ss= k, mptcp_pm_subflow_check_next(mptcp_sk(sk), subflow); =20 __mptcp_close_ssk(sk, ssk, subflow, MPTCP_CF_PUSH); + mptcp_retry_check_tout(sk); } =20 static unsigned int mptcp_sync_mss(struct sock *sk, u32 pmtu) @@ -2823,6 +2899,8 @@ static void __mptcp_close_subflow(struct sock *sk) mptcp_for_each_subflow_safe(msk, subflow, tmp) { struct sock *ssk =3D mptcp_subflow_tcp_sock(subflow); int ssk_state =3D inet_sk_state_load(ssk); + struct mptcp_pm_retry retry; + bool do_retry; =20 if (ssk_state !=3D TCP_CLOSE && (ssk_state !=3D TCP_CLOSE_WAIT || @@ -2834,7 +2912,13 @@ static void __mptcp_close_subflow(struct sock *sk) if (!skb_queue_empty_lockless(&ssk->sk_receive_queue)) continue; =20 + do_retry =3D mptcp_pm_subflow_retry_check(msk, subflow, &retry); mptcp_close_ssk(sk, ssk, subflow); + if (do_retry) { + mptcp_pm_subflow_retry(msk, &retry); + /* creating a subflow stopped the close timeout */ + mptcp_retry_check_tout(sk); + } } =20 } @@ -3188,10 +3272,19 @@ static void mptcp_worker(struct work_struct *work) if (mptcp_close_tout_expired(sk)) { struct mptcp_subflow_context *subflow, *tmp; =20 - mptcp_do_fastclose(sk); - mptcp_for_each_subflow_safe(msk, subflow, tmp) - __mptcp_close_ssk(sk, subflow->tcp_sock, subflow, 0); - mptcp_close_wake_up(sk); + /* a re-created subflow connected in the meantime, see + * mptcp_retry_check_tout() + */ + if (sk->sk_state =3D=3D TCP_ESTABLISHED && + mptcp_has_active_subflow(msk)) { + mptcp_stop_tout_timer(sk); + } else { + mptcp_do_fastclose(sk); + mptcp_for_each_subflow_safe(msk, subflow, tmp) + __mptcp_close_ssk(sk, subflow->tcp_sock, + subflow, 0); + mptcp_close_wake_up(sk); + } } =20 if (sock_flag(sk, SOCK_DEAD) && sk->sk_state =3D=3D TCP_CLOSE) { @@ -3516,6 +3609,9 @@ bool __mptcp_close(struct sock *sk, long timeout) goto cleanup; } =20 + /* before __mptcp_wr_shutdown() disconnects them */ + mptcp_close_retry_subflows(sk); + if (mptcp_data_avail(msk) || timeout < 0 || (sock_flag(sk, SOCK_LINGER) && !sk->sk_lingertime)) { /* If the msk has read data, or the caller explicitly ask it, diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 4aa4aedb2ba7..d47430fc7dc8 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -610,6 +610,8 @@ struct mptcp_subflow_context { bool close_event_done; /* has done the post-closed part, * protected by msk socket lock */ + bool retry; /* re-created after an error, msk lock */ + bool no_retry; /* uses a removed address, msk lock */ u32 lent_mem_frag; u32 remote_nonce; u32 local_nonce; @@ -1139,6 +1141,18 @@ void mptcp_pm_subflow_established(struct mptcp_sock = *msk); bool mptcp_pm_nl_check_work_pending(struct mptcp_sock *msk); void mptcp_pm_subflow_check_next(struct mptcp_sock *msk, const struct mptcp_subflow_context *subflow); + +struct mptcp_pm_retry { + struct mptcp_pm_local local; + struct mptcp_addr_info remote; + u8 syn_retries; +}; + +bool mptcp_pm_subflow_retry_check(struct mptcp_sock *msk, + const struct mptcp_subflow_context *subflow, + struct mptcp_pm_retry *retry); +void mptcp_pm_subflow_retry(struct mptcp_sock *msk, + const struct mptcp_pm_retry *retry); void mptcp_pm_add_addr_received(const struct sock *ssk, const struct mptcp_addr_info *addr); void mptcp_pm_add_addr_echoed(struct mptcp_sock *msk, @@ -1260,6 +1274,11 @@ void __init mptcp_pm_userspace_register(void); void __init mptcp_pm_nl_init(void); void mptcp_pm_worker(struct mptcp_sock *msk); void __mptcp_pm_kernel_worker(struct mptcp_sock *msk); +bool mptcp_pm_kernel_retry_check(struct mptcp_sock *msk, + const struct mptcp_subflow_context *subflow, + struct mptcp_pm_retry *retry); +void mptcp_pm_kernel_retry(struct mptcp_sock *msk, + const struct mptcp_pm_retry *retry); u8 mptcp_pm_get_endp_signal_max(const struct mptcp_sock *msk); u8 mptcp_pm_get_endp_subflow_max(const struct mptcp_sock *msk); u8 mptcp_pm_get_endp_laminar_max(const struct mptcp_sock *msk); --=20 2.25.1 From nobody Thu Nov 5 07:28:49 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.182 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792996632; b=4l8Hj/j5E7rCqEUhpAkfquuMyq5pFmjPhN7SODeict+iF2WuBLjtqVGFZ6dKW5Y122s3 txT+TqfeguV6FqLqtoepVtwJ5oF+gY1ErJTInwFbUJcyW6Jtb4z7lOO+cFfFQrNXy6LE8 1m80lRiW2RAyrdx1SkrgBy038o9HCT6RUNGxPnn6acfGQlDo4iM5b+vdklBu3dg1lFta6 sRn5bjTbKu0nVqCxul0f9FVs4YOGTmu743RlpzbxLz2GK/joYQd/z/mZeTGyFlDsa/GiQ QHfMjNxb7QSUMTL/TRz/LLKliOeJI0OSyx7ga5liVMJWqkK56iAv0YFfr7zSWjhGVNA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792996632; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=17GOmCrtuAsxF144oT296XUfRZYmIcuHgGJDCaIHaZY=; b=kFUyECsEOta0/Uz11LCY54PzsotEKuJ31o8esURzZLSu7AjO0wOEbiG+fz4TffE/X8vl WG4bLCdkBUjIs1dP7lO8LxTT1oGK4FYGJfvU5k41psJ3C8GMB/3tek6GHDq9lP5gSxtoE 8dAg+h63u2Y4YMig7DAllBSNzZwTeC1JPJ5M5G3bqpPRL2dl1c9yx4JaVCy2N0t2wu8A6 IJqkT55xagq+hRjuAAaHP7DZYXr1dqMOUoTJND0GnKQLHyTAqxi0UgtugDokl87TKtNUH OxgSotBrJ0m3AsQCR7jUWHxYZ8kv5OItSEKf8jLSQY5KpdD4RndP9I6xq+8gD1/qZ7A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=q9AmxYvl; arc=none smtp.remote-ip=74.125.82.182 Received: from mail-dy1-f182.google.com (mail-dy1-f182.google.com [74.125.82.182]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68890606A31A for ; Mon, 26 Oct 2026 06:37:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 68890606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=q9AmxYvl Received: by mail-dy1-f182.google.com with SMTP id 5a478bee46e88-36681e85e87so763359eec.1 for ; Sun, 25 Oct 2026 23:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792996631; x=1793601431; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=17GOmCrtuAsxF144oT296XUfRZYmIcuHgGJDCaIHaZY=; b=q9AmxYvlJ9LuWWoyT+W+lpbRjRRBPa29q7dMnrm4+VVvpslbtaUYHJgG7s25Vzs4aH yFn5thadFZNsQzP+v6ogQAm+kByigxzLtc7qaKNSNR6zqRTnboxJgqMxTWX1kBWsVei8 iugtYVmWEW9Pt0/bBOnVuKAb+ve2jMiK/8yUIBVlFawW0JR80epkub0Zfh8RxxM9t/MK Y4V9l4pKYBMB1HK3vCb2/CrjsYA1xihw0MJoAAJDAk0+TIFFgen5VPRR2jGs+XRmlhKR 5Vk0ke1eyK26nRYGX49MvO0aOZ9UHvb8W/uX3wHrt2XpWYLBBWKvPtSl1ScZrXUau+lD EM3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792996631; x=1793601431; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=17GOmCrtuAsxF144oT296XUfRZYmIcuHgGJDCaIHaZY=; b=BFLeUMBqfMSVawswz8w41ocxKNSiNJM1B2Rr4+A5blOqndjSgCAhSEHc8ZOsWlcvkK HPztXTeKy+a/CJLEYjM237lfc2oULPUaPibWcwd+Yh4NmrNBBNTsqaJwC3lPn8hURPBy umfifr0xG666Za/cUwKIqhMtdRxyb1iLY8rywQvNSOcrUl5YjSALfwxoyDRpP6vnOXoh 7Nq6Ywmj+5PszwQfjkl3kLZSYU4JIN08ZfXtPcnnFVXgnZ03a+Lc7MAjrKzRu7rIzVIP gFnWfKORDrk83IDHkSvc2j2uhnoGGZu9vbH/BTnRapYdG3dEEfWg51eFuqh2OphilGme gPEA== X-Gm-Message-State: AFq9FYIzUaBfNMfdDFl+eJmPbhMNz9+RhtEEjg3+LoIHBLQlhMrOVC6E MjicFgtvenCMv39vfOkOckD6R+j++6Ny0bLy9z6H2+CQOAtoR7SC0T+3CWmjjQ== X-Gm-Gg: AYBFou3VwC0D2HKvhQwKIfshvR+irqtIQMR53odSf55R9EDOQEVfqBcDScBZoQSIZuQ JFxQ2AZEoar9AgNiYOrNet4dMHNewzxRXv3hFv7EtLasybMPIV7UiPZ4WoH5pvVqiJ9sIXC8YOf 6pPM8UNJXyk1ifGpK5YtcmP8MJHrGMFNeUKxirQe0F/qQWOL53fc2I4KRRfvxkl+nca5g1127k5 gO08VVU8uTpCNMudKBJxedlP/iyLHYxE3rrtRGBLYHgl/6pz3/KlUKdJmvz/dTo1VhkHoyRhVjY VXIOrX8IjFhZuqm5yO7cTdd4TlXmexqj5p+tKOE8bzC9dscgi1rdGY89p874VRn4dZ5IZ2ruGH+ 5JJOIMK5bcWiEM+F31cKaVr7xoQ87xOkKzUnvFTavyV2D1setzZqhNzSRlC4La8lnFiTCZoKcUa s7SIoNUgAVJwq/PFQ+dyyDwGXKH0cxLTqqs0UBYhrYpj8/YuWtqj+kF+YB3RrKO3ThdgdW8qo+d PpD7re9WihCcloDJSgJgPAGnnDkrHvQgdPvjzf8b799crp6acfvM7tlFpgCAQyOR7wkXaEjh1Dh G/IUQXMaevagwf8sEiyaBQWfug/xgCvcaaN2NJxJ/zapQEZGvPrGIGMljlGPoUj7r0uemPs19rs ZxYdLzTX92+xwlxv/c5NbtwYGDWUecpTZBJmf8m0O3EJGvA== X-Received: by 2002:a05:7301:d816:20b0:369:f277:7f09 with SMTP id 5a478bee46e88-369f277b32cmr7379930eec.25.1792996630868; Sun, 25 Oct 2026 23:37:10 -0700 (PDT) Received: from ramen-dev-security-2.asia-south1-c.c.ramen-dev-345017.internal (90.156.200.35.bc.googleusercontent.com. [35.200.156.90]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-369ef6a71a4sm21191609eec.8.2026.10.25.23.37.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2026 23:37:10 -0700 (PDT) From: Anil Kaushik To: mptcp@lists.linux.dev Cc: Anil Kaushik Subject: [PATCH mptcp-next v10 5/6] selftests: mptcp: pm_nl_ctl: support the subflow-retries limit Date: Mon, 26 Oct 2026 06:36:56 +0000 Message-Id: <20261026063657.2955783-6-anilkaushikwireless@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261026063657.2955783-1-anilkaushikwireless@gmail.com> References: <20261026063657.2955783-1-anilkaushikwireless@gmail.com> X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 'pm_nl_ctl limits' can now set the subflow-retries limit with a third value, and shows it when the kernel supports it. pm_netlink.sh checks its default value, that a value above the maximum is refused, and that it can be set. This is only done with pm_nl_ctl for the moment: iproute2 does not support this limit yet. Signed-off-by: Anil Kaushik --- Notes: v9: - try the value above the maximum after setting 0, not the default value, which is also the maximum: a refused value is then told apart from a clamped one (netdev Sashiko) v8: - the default value is now 127 v7: - also check that the maximum value, 127, is accepted (netdev Sashiko) v5: - new (Matthieu) .../testing/selftests/net/mptcp/pm_netlink.sh | 48 ++++++++++++++++++- tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 34 ++++++++++--- 2 files changed, 73 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testin= g/selftests/net/mptcp/pm_netlink.sh index 21bfe1311f11..9a6209181962 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -46,15 +46,20 @@ trap cleanup EXIT =20 mptcp_lib_ns_init ns1 =20 +# $3: subflow retries, only shown by pm_nl_ctl, if supported format_limits() { local accept=3D"${1}" local subflows=3D"${2}" + local retries=3D"${3}" =20 if mptcp_lib_is_ip_mptcp; then # with a space at the end printf "add_addr_accepted %d subflows %d \n" "${accept}" "${subflows}" else printf "accept %d\nsubflows %d\n" "${accept}" "${subflows}" + if [ -n "${retries}" ]; then + printf "subflow_retries %d\n" "${retries}" + fi fi } =20 @@ -75,6 +80,22 @@ get_limits_nb() { fi } =20 +# The subflow retries limit is only set and shown with pm_nl_ctl for now. +# Prints its default value if it is supported. +get_default_retries() { + if mptcp_lib_is_ip_mptcp; then + return + fi + + if ip netns exec "${ns1}" ./pm_nl_ctl limits | + grep -q "^subflow_retries"; then + echo 127 + elif mptcp_lib_expect_all_features; then + # missing feature: the defaults limits check will fail + echo 127 + fi +} + format_endpoints() { mptcp_lib_pm_nl_format_endpoints "${@}" } @@ -154,8 +175,10 @@ mptcp_lib_subtests_last_ts_reset check "show_endpoints" "" "defaults addr list" =20 default_limits=3D"$(get_limits)" +default_retries=3D"$(get_default_retries)" if mptcp_lib_expect_all_features; then - check "get_limits" "$(format_limits 0 2)" "defaults limits" + check "get_limits" "$(format_limits 0 2 "${default_retries}")" \ + "defaults limits" fi =20 add_endpoint 10.0.1.1 @@ -224,7 +247,28 @@ check "get_limits" "${default_limits}" "subflows above= hard limit" =20 set_limits ${max_limits} ${max_limits} flush_endpoint ## to make sure it doesn't affect the limits -check "get_limits" "$(format_limits ${max_limits} ${max_limits})" "set lim= its" +max_limits_out=3D"$(format_limits ${max_limits} ${max_limits} \ + "${default_retries}")" +check "get_limits" "${max_limits_out}" "set limits" + +if [ -n "${default_retries}" ]; then + ip netns exec "${ns1}" ./pm_nl_ctl limits ${max_limits} ${max_limits} 0 + check "get_limits" "$(format_limits ${max_limits} ${max_limits} 0)" \ + "set subflow retries" + + # not from the default: a refused value differs from a clamped one + ip netns exec "${ns1}" ./pm_nl_ctl limits ${max_limits} ${max_limits} \ + 128 2>/dev/null + check "get_limits" "$(format_limits ${max_limits} ${max_limits} 0)" \ + "subflow retries above hard limit" + + ip netns exec "${ns1}" ./pm_nl_ctl limits ${max_limits} ${max_limits} \ + 127 + check "get_limits" "$(format_limits ${max_limits} ${max_limits} 127)" \ + "set max subflow retries" + ip netns exec "${ns1}" ./pm_nl_ctl limits ${max_limits} ${max_limits} \ + "${default_retries}" +fi =20 flush_endpoint add_endpoint 10.0.1.1 diff --git a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c b/tools/testing/= selftests/net/mptcp/pm_nl_ctl.c index 78180da1efcc..41467b997018 100644 --- a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c +++ b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c @@ -39,7 +39,7 @@ static void syntax(char *argv[]) fprintf(stderr, "\tset [] [id ] flags [no]backup|[no]fullmesh [po= rt ] [token ] [rip ] [rport ]\n"); fprintf(stderr, "\tflush\n"); fprintf(stderr, "\tdump\n"); - fprintf(stderr, "\tlimits [ ]\n"); + fprintf(stderr, "\tlimits [ []]\n"); fprintf(stderr, "\tevents\n"); fprintf(stderr, "\tlisten \n"); exit(0); @@ -1217,6 +1217,7 @@ int flush_addrs(int fd, int pm_family, int argc, char= *argv[]) static void print_limits(struct nlmsghdr *nh, int pm_family, int total_len) { struct rtattr *attrs; + const char *name; uint32_t max; =20 for (; NLMSG_OK(nh, total_len); nh =3D NLMSG_NEXT(nh, total_len)) { @@ -1235,13 +1236,22 @@ static void print_limits(struct nlmsghdr *nh, int p= m_family, int total_len) while (RTA_OK(attrs, len)) { int type =3D attrs->rta_type; =20 - if (type !=3D MPTCP_PM_ATTR_RCV_ADD_ADDRS && - type !=3D MPTCP_PM_ATTR_SUBFLOWS) + switch (type) { + case MPTCP_PM_ATTR_RCV_ADD_ADDRS: + name =3D "accept"; + break; + case MPTCP_PM_ATTR_SUBFLOWS: + name =3D "subflows"; + break; + case MPTCP_PM_ATTR_SUBFLOW_RETRIES: + name =3D "subflow_retries"; + break; + default: goto next; + } =20 memcpy(&max, RTA_DATA(attrs), 4); - printf("%s %u\n", type =3D=3D MPTCP_PM_ATTR_SUBFLOWS ? - "subflows" : "accept", max); + printf("%s %u\n", name, max); =20 next: attrs =3D RTA_NEXT(attrs, len); @@ -1254,15 +1264,17 @@ int get_set_limits(int fd, int pm_family, int argc,= char *argv[]) char data[NLMSG_ALIGN(sizeof(struct nlmsghdr)) + NLMSG_ALIGN(sizeof(struct genlmsghdr)) + 1024]; - uint32_t rcv_addr =3D 0, subflows =3D 0; + uint32_t rcv_addr =3D 0, subflows =3D 0, retries =3D 0; int cmd, len =3D sizeof(data); struct nlmsghdr *nh; int off =3D 0; =20 /* limit */ - if (argc =3D=3D 4) { + if (argc =3D=3D 4 || argc =3D=3D 5) { rcv_addr =3D atoi(argv[2]); subflows =3D atoi(argv[3]); + if (argc =3D=3D 5) + retries =3D atoi(argv[4]); cmd =3D MPTCP_PM_CMD_SET_LIMITS; } else { cmd =3D MPTCP_PM_CMD_GET_LIMITS; @@ -1287,6 +1299,14 @@ int get_set_limits(int fd, int pm_family, int argc, = char *argv[]) memcpy(RTA_DATA(rta), &subflows, 4); off +=3D NLMSG_ALIGN(rta->rta_len); =20 + if (argc =3D=3D 5) { + rta =3D (void *)(data + off); + rta->rta_type =3D MPTCP_PM_ATTR_SUBFLOW_RETRIES; + rta->rta_len =3D RTA_LENGTH(4); + memcpy(RTA_DATA(rta), &retries, 4); + off +=3D NLMSG_ALIGN(rta->rta_len); + } + /* do not expect a reply */ len =3D 0; } --=20 2.25.1 From nobody Thu Nov 5 07:28:49 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.173 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792996634; b=nHE+Mx8QPeVbW/YGbP153/S9KEAz6q5OH9kIBpFBWV/owAn3z2aggk1MMhWwNd1lRmKd 1DDCYbvcvcceUeZkMmgu02NR0TGpqRso/vjtKsUu9CC32IOa5cbulXe/KbX28lt88Uy4/ iComLZgGthGRq1UloZ/LsyV6Hd42zCyJXNxfBhXdWUbx7mei2yzZgIE7winDed6o+Bd+h 1FWLk0I9VskY3SjkS9xTGD4NaYdv5YpOdp403tSFkUpBkp+pATxIbinEZgPri53j6nqY5 r3RqkmmeOSJ6W/en3WnZhbCVMmNz9f7ufgfk67UPIUftq3PWPtQQWWnM4i6o5eBR2GQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792996634; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=nZ1ISpUzXpxjtn8ICSnDrkmh3D2uUbF+KbGS6rMkJYY=; b=BXHnXNpkafokdFgkOaeCVRqhjLasVxgrsch88zNcqxpMbaRsYSO8zvoQJbapMXu1Xrql NHtpyLPFxt0Xx0oVPB2RFIrGkoaOjUxPgWK5ApICE5QgH6FDe2I4m1Pg/yqecHBtoXn5J 02Q2q9fKiarltwns94z9izRonkR7Zui3+MErYLwxrtBcM8AWbvOLHEE4kuoJdEoVEdSNt +rGVEqOR2kp4ZMqzi54gBME6GlE74UPAX3EVniH3H10zv5/zyprFqQh1dnRc1z5s8KJm5 GVNmumx/AGiLsN2gkw9FvJeQ+E1rC2fc1GJuMU4yQeiCA3Ni1qA9bhmJRxZ+XKIkfSA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=ndE7T0CN; arc=none smtp.remote-ip=74.125.82.173 Received: from mail-dy1-f173.google.com (mail-dy1-f173.google.com [74.125.82.173]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 508E7606A31A for ; Mon, 26 Oct 2026 06:37:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 508E7606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=ndE7T0CN Received: by mail-dy1-f173.google.com with SMTP id 5a478bee46e88-35c76e9614aso4317707eec.0 for ; Sun, 25 Oct 2026 23:37:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792996633; x=1793601433; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=nZ1ISpUzXpxjtn8ICSnDrkmh3D2uUbF+KbGS6rMkJYY=; b=ndE7T0CNYoI4rgOdC+l7kq8KnYbetNBv4/qzHvXWrRy04VZ8aFcEWnAsp7TGfDWNev laXEX0028wZPxA5upenw+34m8sJM9zNoMzlpYJcnFm1nRschRCPz9NPcXyLXsbs/jVAb p+6HnoS1zO4gBCM/3Z/v4ntLDP9i7+PRbXmj+UEKKhq0r0YHGzvIzON95hIDPqvgUvt9 9x4VKumFUN2BU/3gQuXIY4jl61a7ivNeCmmD+tWQdVUM5Z/ByQR8mpSWsvtfmxLMr8pg tm+V25LDKO2Pk8Uggs2RESJmofRK+54Y15Lv/cQ92BdsL3PRW8xAPEec+E3Id8ZSczbH e+3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792996633; x=1793601433; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=nZ1ISpUzXpxjtn8ICSnDrkmh3D2uUbF+KbGS6rMkJYY=; b=tpjidW1NR7qOPe8WXGALfLSipQYgVASpMfxYwKTtzGHWNj5qszAu6M7G8rdQZ6yqjH WMHsR5DCmg3GMEgjsaBNwtIb/Kna1//NmfF6xUQkVqUQupyZJNJFtPYj3pgCiBTunT1Y I0F9gbzggf6L5JvmYYW9lmkpwpBVGGSzffvaviOoACROkkQnRO1eMvW+l8DYg1pUUTw3 l+bGjvq7VHEhSqeWvJkj0G4j+ar/RS/itCAhj59d25OIrv+2MrLKH/omLcwBLcBCLJC7 q+ttbgxi573GJ1heOuLDASeZaw4MkireWZs1lMq6GsWRe0QnFZIJ3nKZdo44hoRwOMij xrBQ== X-Gm-Message-State: AFq9FYLglz+tHfrqYXCxErYNBvGeL7SQHMY9wTw3kj/40YDK/Z8X/cU+ mMhyKgLhEET8ymKVFzL/W6Ro0zZfjAp/Iy4iGa+X/K/ZKL/ncG/lHDPCX9ZnPQ== X-Gm-Gg: AYBFou0UOUI5gYFWruvokcJ4SNWo7AErIUA/ZpxK6qjAX57Dm6uDPSEobJleBvtLspJ lhc8dwlQda595czlBgbCFeSN19IOHMBUBbvlL3/cq2eTbRGFtu5HZnLba8CYrMAQnZJHcC6F3o4 3AIYowEX9E7xgETX5TJJjYViRYpd1PwTPwB1o8i4TQiIfeVctFCpCgl/cpdTL7ihxqS9NWoEbaw 4Y8SIQrLmAnpIw5x/fX5ttmogws3S+DS0/3fKNHcalUoV+DXIq7xQilkPrNQ6Fph8pqB7DVRTdH HsdiJTSJzHdhNZQKrBmtvYycLMBd1WKz6u0/5lcGDSNYjMYybezQySH/ZmAX04IHtunPeibuWQ+ UgtrHcmJReUb1joW3AoK6xuQNyxUJro/JGzn1+wGVRlxDIu+ZZ6Y8KrFJKjgThm+JUKUxv1QxSk plT279wmigDbDg1ig0sm9awmS4ZuCqH04xb3w1ytIps79ebckL2ubdMiq7OejWi/2nimBPqDgFW 6t+HxMBSYmr2Voaxln6xXI59zRBypwFzafdJwSwOwtRv2MN2O5pLpJ4DuzpvtCfI8bBeHWHcuqV svWPGIpzGbhWNqjLKIyEGewLCnQR+zcykWbGyqndjqUzMA+6ZBWFtHhKU63hkNovdZPKbhy7Qpk j7OZXHUqdYdK3aC8c5mr4q2qH X-Received: by 2002:a05:7300:ec14:b0:351:202c:c7a5 with SMTP id 5a478bee46e88-369e81c4c2bmr13935987eec.0.1792996632949; Sun, 25 Oct 2026 23:37:12 -0700 (PDT) Received: from ramen-dev-security-2.asia-south1-c.c.ramen-dev-345017.internal (90.156.200.35.bc.googleusercontent.com. [35.200.156.90]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-369ef6a71a4sm21191609eec.8.2026.10.25.23.37.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2026 23:37:12 -0700 (PDT) From: Anil Kaushik To: mptcp@lists.linux.dev Cc: Anil Kaushik Subject: [PATCH mptcp-next v10 6/6] selftests: mptcp: join: validate subflow retry after link failure Date: Mon, 26 Oct 2026 06:36:57 +0000 Message-Id: <20261026063657.2955783-7-anilkaushikwireless@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261026063657.2955783-1-anilkaushikwireless@gmail.com> References: <20261026063657.2955783-1-anilkaushikwireless@gmail.com> X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Test the subflow-retries limit, with its default value, and a long connection in the background: drop the packets the client sends from the additional subflow address with netfilter, without bringing the link down, until the subflow is closed and re-created. Let them through again once the SYN of the new subflow has been retransmitted more times than tcp_syn_retries allows, and check the subflow comes back from the same address. Then do the same with the initial subflow. A second test closes the connection while a subflow is being re-created, and checks the netlink events. Only the client sends data: the server reads it all first, in sendfile mode, and keeps its side open. The client gets a big MPTCP send buffer compared to its subflows, and both paths are blocked: the data left in it is never sent, nor the DATA_FIN, so only the close of the MPTCP socket can stop the subflow being re-created. Only the client is closed: it has nothing left to read, so the connection is not closed with a fastclose, which would reset all the subflows anyway. The check is skipped if a fastclose happens. The big files used for the long connection are emptied at the end. A third test re-creates the only subflow, and checks the connection is still closed after the close timeout, the new subflow being unable to connect. A fourth one lets the path come back before the close timeout, and checks the connection stays open. The tests are skipped if pm_nl_ctl does not show the new limit, or if the filter rules cannot be set. Signed-off-by: Anil Kaushik --- Notes: v10: - new test: the path of the only subflow comes back before the close timeout, and the connection stays open (sashiko.dev) The path comes back as soon as the subflow is re-created, with a 30s close timeout, longer than the SYN backoff, and its transfer has a longer poll timeout, with no data at all while the only path is blocked: both are needed on a slow debug kernel v9: - wait for absolute counter values, read before blocking the path, or 0 and 1 in the new netns: the subflow can be re-created before a later read (netdev Sashiko) - check that the connection is established before blocking it, in the close test and the new one (netdev Sashiko) - the close test blocks the other path too, with a big msk send buffer: the pending data and the DATA_FIN no longer close the subflow being re-created, only the close of the MPTCP socket can. Checked: both the close test and the new test fail without their fix - new test: the only subflow is re-created, and the connection is still closed after the close timeout - $sinfail as the server input, kill errors ignored, clearer failure message, $cout and $sout emptied too - the server of the second test reads all the data from the client first, in sendfile mode, instead of blocking on a FIFO in poll mode: the client always has data in flight (netdev Sashiko) v8: - comment in run_tests() matching the new condition (netdev Sashiko) - a separate test closes the connection while a subflow is re-created: the server sends nothing but keeps its side open, and only the client is closed, so there is no fastclose, which would reset all the subflows anyway; the check is skipped if one happens (netdev Sashiko) v7 (netdev Sashiko): - the test_linkfail=3D1/2 modes regenerate the shared files when they are empty, e.g. when running link_failure_tests() twice - read the MP_JOIN ACK counter before letting the packets through, and do not compare the ports, they can be reused v6 (Sashiko): - use the slowwait helpers from net/lib.sh - longer first wait, while the 128 MB files are created - skip if the filter rules cannot be set, check each drop rule (netdev Sashiko) - empty the big files at the end, cinsent too, keep the variables (netdev Sashiko) v5 (Matthieu): - skipped if pm_nl_ctl does not show the new limit - wait for the SYN retransmissions instead of a sleep, with tcp_syn_linear_timeouts=3D0 - helper for the check after the close - slower links with short queues, so the transfer lasts the whole test on any machine, longer timeout (killed at the end) v4: - default limit, no sysctl or MIB counter - more SYN retransmissions than tcp_syn_retries - close the connection while a subflow is re-created - check the netlink events - check the waits and the new subflow port, remove the big files at the end (Sashiko) v3: - check the subflow address, create the files before the background job v2: - one test, with netfilter .../testing/selftests/net/mptcp/mptcp_join.sh | 399 +++++++++++++++++- 1 file changed, 391 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index c3ccce96b45b..3fa561b1a8fd 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -52,6 +52,7 @@ nr_blank=3D6 # These var are used only in some tests, make sure they are not already set unset FAILING_LINKS unset test_linkfail +unset server_in unset addr_nr_ns1 unset addr_nr_ns2 unset cestab_ns1 @@ -1038,7 +1039,12 @@ do_transfer() fi =20 extra_srv_args=3D"$extra_args $extra_srv_args" - if [ "$test_linkfail" -gt 1 ];then + if [ -n "${server_in}" ]; then + # the server reads all the data from the client before sending + # this file: it does not block on its input + extra_srv_args=3D"$extra_srv_args -m sendfile" + listener_in=3D"${server_in}" + elif [ "$test_linkfail" -gt 1 ]; then listener_in=3D"${sinfail}" fi ip netns exec ${listener_ns} \ @@ -1135,9 +1141,9 @@ run_tests() cinfail=3D$(mktemp) fi make_file "$cinfail" "client" $size - # create the input file for the failure test when - # the first failure test run - elif [ "$test_linkfail" -ne 0 ] && [ -z "$cinfail" ]; then + # create the input file for the failure test, when + # it is missing or has been emptied + elif [ "$test_linkfail" -ne 0 ] && [ ! -s "$cinfail" ]; then # the client file must be considerably larger # of the maximum expected cwin value, or the # link utilization will be not predicable @@ -1146,23 +1152,27 @@ run_tests() size=3D$((size*8192)) size=3D$((size + ( RANDOM % 8192) )) =20 - cinfail=3D$(mktemp) + if [ -z "$cinfail" ]; then + cinfail=3D$(mktemp) + fi make_file "$cinfail" "client" $size fi =20 - if [ "$test_linkfail" -gt 2 ]; then + if [ "$test_linkfail" -gt 2 ] && [ -z "${server_in}" ]; then size=3D$test_linkfail =20 if [ -z "$sinfail" ]; then sinfail=3D$(mktemp) fi make_file "$sinfail" "server" $size - elif [ "$test_linkfail" -eq 2 ] && [ -z "$sinfail" ]; then + elif [ "$test_linkfail" -eq 2 ] && [ ! -s "$sinfail" ]; then size=3D$((RANDOM%16)) size=3D$((size+1)) size=3D$((size*2048)) =20 - sinfail=3D$(mktemp) + if [ -z "$sinfail" ]; then + sinfail=3D$(mktemp) + fi make_file "$sinfail" "server" $size fi =20 @@ -2151,6 +2161,237 @@ wait_attempt_fail() return 1 } =20 +# $1: timeout in seconds ; $2: ns ; $3: counter ; $4: increment, 1 by defa= ult +wait_counter_inc() +{ + slowwait_for_counter "${1}" "${4:-1}" \ + mptcp_lib_get_counter "${2}" "${3}" >/dev/null +} + +# $1: timeout ; $2: ns ; $3: counter ; $4: value to reach +wait_counter_ge() +{ + slowwait "${1}" until_counter_is ">=3D ${4}" \ + mptcp_lib_get_counter "${2}" "${3}" >/dev/null +} + +# $1: client address ; prints the local address and port of its subflow +sf_from() +{ + ip netns exec $ns2 ss -tnH state established src "${1}" | + awk '{ print $3; exit }' +} + +has_subflow_retries() +{ + ip netns exec $ns2 ./pm_nl_ctl limits | grep -q "^subflow_retries" +} + +# the client packets are dropped with rules in this chain +init_nft_filter() +{ + init_nftables + if ! ip netns exec $ns2 nft list chain ip filter OUTPUT \ + &>/dev/null; then + mark_as_skipped "unable to set the filter rules" + return 1 + fi +} + +# $1: client address +nft_drop_from() +{ + ip netns exec $ns2 nft add rule ip filter OUTPUT ip saddr "${1}" drop +} + +# $1: client address to block +# +# The link stays up, but the client packets from this address are dropped: +# the subflow using it is closed after a few retransmissions, and re-creat= ed. +# The packets go through again once the SYN has been retransmitted more ti= mes +# than tcp_syn_retries allows: the new subflow still connects thanks to the +# subflow-retries limit. +sf_retry_after_block() +{ + local before ack_rx syn_tx + + before=3D$(sf_from "${1}") + + print_check "subflow from ${1}" + if [ -z "${before}" ]; then + fail_test "no established subflow from ${1} before the block" + return + fi + + # read before the block: the subflow can be re-created right after it + syn_tx=3D$(mptcp_lib_get_counter $ns2 "MPTcpExtMPJoinSynTx") + if ! nft_drop_from "${1}"; then + fail_test "unable to drop the packets from ${1}" + return + fi + if ! wait_counter_ge "${timeout_poll}" $ns2 "MPTcpExtMPJoinSynTx" \ + $((syn_tx + 1)); then + ip netns exec $ns2 nft flush chain ip filter OUTPUT + fail_test "subflow from ${1} not re-created" + return + fi + # tcp_syn_retries=3D1: one more retransmission than allowed + if ! wait_counter_inc "${timeout_poll}" \ + $ns2 "TcpExtTCPSynRetrans" 2; then + ip netns exec $ns2 nft flush chain ip filter OUTPUT + fail_test "SYN from ${1} not retransmitted enough" + return + fi + # read before the flush: the next SYN can be sent right after it + ack_rx=3D$(mptcp_lib_get_counter $ns1 "MPTcpExtMPJoinAckRx") + ip netns exec $ns2 nft flush chain ip filter OUTPUT + + if ! wait_counter_ge "${timeout_poll}" $ns1 "MPTcpExtMPJoinAckRx" \ + $((ack_rx + 1)); then + fail_test "re-created subflow from ${1} not established" + return + fi + + if [ -z "$(sf_from "${1}")" ]; then + fail_test "no established subflow from ${1}" + else + print_ok + fi +} + +# $1: ns ; prints the number of MP_FASTCLOSE sent and received +fastclose_nr() +{ + local tx rx + + tx=3D$(mptcp_lib_get_counter "${1}" "MPTcpExtMPFastcloseTx") + rx=3D$(mptcp_lib_get_counter "${1}" "MPTcpExtMPFastcloseRx") + echo $((${tx:-0} + ${rx:-0})) +} + +no_sf_connecting() +{ + ! ip netns exec $ns2 ss -tnH state syn-sent | grep -q . +} + +# $1: client address of the only subflow ; $2: close timeout +# +# The subflow is blocked and re-created, and its path comes back right awa= y: +# the new subflow connects before the close timeout, and keeps the connect= ion +# open after it. +chk_sf_retry_path_back() +{ + print_check "open after the close timeout" + if ! wait_counter_ge $((timeout_poll * 4)) \ + $ns1 "MPTcpExtMPCapableACKRX" 1; then + fail_test "connection not established" + return + fi + if ! nft_drop_from "${1}"; then + fail_test "unable to drop the packets from ${1}" + return + fi + # no other subflow: the first MP_JOIN SYN is the re-created one + if ! wait_counter_ge "${timeout_poll}" \ + $ns2 "MPTcpExtMPJoinSynTx" 1; then + ip netns exec $ns2 nft flush chain ip filter OUTPUT + fail_test "subflow from ${1} not re-created" + return + fi + ip netns exec $ns2 nft flush chain ip filter OUTPUT + if ! wait_counter_ge "${timeout_poll}" \ + $ns1 "MPTcpExtMPJoinAckRx" 1; then + fail_test "re-created subflow from ${1} not established" + return + fi + + # the close timeout started when the subflow was re-created + sleep $((${2} + 2)) + if [ "$(fastclose_nr $ns2)" -gt 0 ]; then + fail_test "closed with a fastclose" + elif [ -z "$(sf_from "${1}")" ]; then + fail_test "no established subflow from ${1}" + else + print_ok + fi +} + +# The client has nothing left to read: it closes the connection without a +# fastclose, which would reset all the subflows anyway. +kill_client() +{ + local pid + + for pid in $(ip netns pids $ns2); do + if [ "$(cat "/proc/${pid}/comm" 2>/dev/null)" =3D mptcp_connect ] + then + kill "${pid}" 2>/dev/null + fi + done +} + +# $1: why the subflow is not being re-created before the close, if it is n= ot +# $2: number of MP_FASTCLOSE before the close +chk_no_sf_connecting() +{ + local closed + + print_check "no subflow connecting after close" + if [ -n "${1}" ]; then + fail_test "${1}" + return + fi + + # closed with the MPTCP socket + slowwait "${timeout_poll}" no_sf_connecting + closed=3D$? + if [ "$(fastclose_nr $ns2)" -gt "${2}" ]; then + print_skip "closed with a fastclose, resetting all the subflows" + elif [ "${closed}" -eq 0 ]; then + print_ok + else + fail_test "subflow still connecting after close" + fi +} + +# Slow links with short queues: the transfer lasts the whole test on any +# machine, and the blocked subflow always has data in flight. +sf_retry_init() +{ + local i + + for i in 1 3; do + tc -n $ns1 qdisc add dev ns1eth$i root netem \ + rate 4mbit limit 30 delay 1ms + tc -n $ns2 qdisc add dev ns2eth$i root netem \ + rate 4mbit limit 30 delay 1ms + done + ip netns exec $ns2 sysctl -q net.ipv4.tcp_retries2=3D3 + ip netns exec $ns2 sysctl -q net.ipv4.tcp_syn_retries=3D1 + ip netns exec $ns2 sysctl -q net.ipv4.tcp_syn_linear_timeouts=3D0 + pm_nl_set_limits $ns1 0 4 + pm_nl_set_limits $ns2 0 2 + pm_nl_add_endpoint $ns2 10.0.3.2 dev ns2eth3 flags subflow + # created here, not in the background job, for cleanup() + if [ -z "$cinfail" ]; then + cinfail=3D$(mktemp) + fi + if [ -z "$sinfail" ]; then + sinfail=3D$(mktemp) + fi +} + +sf_retry_cleanup() +{ + ip netns exec $ns2 nft flush chain ip filter OUTPUT + # big files: empty them, the next tests write their own content + : > "$cinfail" + : > "$sinfail" + : > "$cinsent" + : > "$cout" + : > "$sout" +} + set_userspace_pm() { local ns=3D$1 @@ -2585,6 +2826,148 @@ link_failure_tests() chk_stale_nr $ns2 1 -1 2 chk_link_usage $ns2 ns2eth3 $cinsent 50 fi + + # subflows closed after a silent link failure, then re-created: the + # additional one, then the initial one + if reset_with_events "subflow retry after link failure" && + continue_if has_subflow_retries && init_nft_filter; then + sf_retry_init + # killed at the end: the timeout only stops a stuck test + { timeout_test=3D600 test_linkfail=3D131072 \ + run_tests $ns1 $ns2 10.0.1.1 & } 2>/dev/null + local tests_pid=3D$! + + # the 128 MB files are created first, that can take a while + wait_counter_ge $((timeout_poll * 4)) \ + $ns1 "MPTcpExtMPJoinAckRx" 1 + sf_retry_after_block 10.0.3.2 + sf_retry_after_block 10.0.1.2 + mptcp_lib_kill_group_wait $tests_pid + kill_events_pids + + join_syn_tx=3D3 chk_join_nr 3 3 3 + chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_ESTABLISHED 3 + chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_CLOSED 2 error 2 + sf_retry_cleanup + fi + + # close the connection while a subflow is being re-created + if reset_with_events "subflow retry, close while connecting" && + continue_if has_subflow_retries && init_nft_filter; then + sf_retry_init + # A big msk send buffer, compared to the subflow ones: when the + # client is closed, some data is not given to any subflow yet, + # so the DATA_FIN, which would also close the subflow being + # re-created, is not sent. + ip netns exec $ns2 sysctl -q \ + net.ipv4.tcp_wmem=3D"1048576 65536 262144" + # The server reads until the client closes, and sends nothing: + # the client has nothing to read, and the connection stays + # established. The transfer is stopped on purpose, its result + # is not checked. + : > "$sinfail" + { timeout_test=3D600 test_linkfail=3D131072 server_in=3D"$sinfail" \ + run_tests $ns1 $ns2 10.0.1.1 >/dev/null & } 2>/dev/null + local tests_pid=3D$! + + local not_ready=3D"" syn_tx + if ! wait_counter_ge $((timeout_poll * 4)) \ + $ns1 "MPTcpExtMPJoinAckRx" 1; then + not_ready=3D"no additional subflow before the block" + else + # read before the block: the subflow can be re-created + # right after it + syn_tx=3D$(mptcp_lib_get_counter $ns2 \ + "MPTcpExtMPJoinSynTx") + if ! nft_drop_from 10.0.3.2; then + not_ready=3D"unable to drop the packets" + elif ! wait_counter_ge "${timeout_poll}" \ + $ns2 "MPTcpExtMPJoinSynTx" $((syn_tx + 1)); then + not_ready=3D"no subflow re-created before close" + fi + fi + # Block the other path too, so this data is never sent: only + # the close of the MPTCP socket can then stop the subflow being + # re-created. + if [ -z "${not_ready}" ] && ! nft_drop_from 10.0.1.2; then + not_ready=3D"unable to drop the packets" + fi + local fc_before + fc_before=3D$(fastclose_nr $ns2) + kill_client + chk_no_sf_connecting "${not_ready}" "${fc_before}" + mptcp_lib_kill_group_wait $tests_pid + kill_events_pids + + join_syn_tx=3D2 chk_join_nr 1 1 1 + chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_ESTABLISHED 1 + chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_CLOSED 1 error 1 + sf_retry_cleanup + fi + + # the only subflow is re-created: the connection is still closed after + # the close timeout, the new subflow cannot connect + if reset_with_events "subflow retry, no other subflow" && + continue_if has_subflow_retries && init_nft_filter; then + sf_retry_init + pm_nl_flush_endpoint $ns2 + ip netns exec $ns2 sysctl -q net.mptcp.close_timeout=3D5 + { timeout_test=3D600 test_linkfail=3D131072 \ + run_tests $ns1 $ns2 10.0.1.1 >/dev/null & } 2>/dev/null + local tests_pid=3D$! + + print_check "closed after the close timeout" + if ! wait_counter_ge $((timeout_poll * 4)) \ + $ns1 "MPTcpExtMPCapableACKRX" 1; then + fail_test "connection not established" + elif ! nft_drop_from 10.0.1.2; then + fail_test "unable to drop the packets" + # no other subflow: the first MP_JOIN SYN is the re-created one + elif ! wait_counter_ge "${timeout_poll}" \ + $ns2 "MPTcpExtMPJoinSynTx" 1; then + fail_test "no subflow re-created" + # closed with the connection, after 5 seconds + elif slowwait "${timeout_poll}" no_sf_connecting; then + print_ok + else + fail_test "subflow still connecting" + fi + mptcp_lib_kill_group_wait $tests_pid + kill_events_pids + + join_syn_tx=3D1 chk_join_nr 0 0 0 + chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_CLOSED 1 error 1 + sf_retry_cleanup + fi + + # the path of the only subflow comes back before the close timeout: + # the re-created subflow keeps the connection open + if reset_with_events "subflow retry, no other subflow, path back" && + continue_if has_subflow_retries && init_nft_filter; then + # The SYN retransmissions back off: long enough for the next one + # to be sent once the path is back, also on a slow machine. + local close_timeout=3D30 + + sf_retry_init + pm_nl_flush_endpoint $ns2 + ip netns exec $ns2 sysctl -q \ + net.mptcp.close_timeout=3D${close_timeout} + # no data at all while the only path is blocked: a longer poll + # timeout, so the transfer outlives the outage + { timeout_poll=3D$((timeout_poll * 4)) timeout_test=3D600 \ + test_linkfail=3D131072 \ + run_tests $ns1 $ns2 10.0.1.1 & } 2>/dev/null + local tests_pid=3D$! + + chk_sf_retry_path_back 10.0.1.2 ${close_timeout} + mptcp_lib_kill_group_wait $tests_pid + kill_events_pids + + join_syn_tx=3D1 chk_join_nr 1 1 1 + chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_ESTABLISHED 1 + chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_CLOSED 1 error 1 + sf_retry_cleanup + fi } =20 add_addr_timeout_tests() --=20 2.25.1