From nobody Thu Nov 5 07:29:03 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=1793517659; b=cah/z0Av6h4LVcVwdBtMgE5cfjT1+Lc0YAoM6gWkEhJvOlcLAjRCD51N1V3B6W9rFHSJ jehuv/IxzWdZCW342hsmwRQo8qYBKPfBipr4gCiWuIVt0aEBhq/2K3N9ln26wLCZoEeda 7Et8NhVaDo9LsW+X8qrb18FRrrzvbVmwFIIaqFPpVkT04RIiZuOeQ/b8Jc68DaszPHWFG x8Szfz8KB7lyneuzAva//8OCrsmvF3MCVKnb25VKEpa3p5kHS6bh2zucCWmsDAXh+GnLn Z6FphzCpjacSWx2ATk1IMXfCovCCeWgrmPhuSG1WGgJPLiTcYFtX4dWdft2V8kcYMpQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793517659; 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=lvLN24gtIiDD108HbQ1hU9mpKtt6mQ07/LEzVwndxzA=; b=n+K3Bn93nRLpw3MBO7hqQsZHybMW2WL2og9IFA14gCqUCvHHSqUTUCNMCVa64HaFAV66 G+qr8vH8BzbadApRia/qx3EXNHTRdInXWdTAlN/GvJf1JJKa0Rpole5ewbu7Qzv0mzmCU DqgbXExC8RkIK41OisJDwyqFZQxxmV9IdagOvtfarRSoSIQ4OoANuAERgg9314xPmmYVE xDe/fGuw1uZ9SdIzWbcQr1S6Fx9LnNZQDCZAh0zN6wHM9ndUq364zBb271fxtAOqK9rZI fzk6EUXqzF2wITf22n0+s/haMQs2kMzZ6t39oFdJdzzV3TNqLzbJiR4X1LfYo9U8OYw== 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=20260707 header.b=deyrGIRt; 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 9F3E3606A325 for ; Sun, 1 Nov 2026 07:20:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9F3E3606A325 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=20260707 header.b=deyrGIRt Received: by mail-dy1-f170.google.com with SMTP id 5a478bee46e88-3514b90bb89so4008191eec.1 for ; Sun, 01 Nov 2026 00:20:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793517658; x=1794122458; 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=lvLN24gtIiDD108HbQ1hU9mpKtt6mQ07/LEzVwndxzA=; b=deyrGIRtwoYHYvICC/6ZfjlvRi7JI9LQ3pUvZIeOoYdO57W+luFqGcqnRjLzx68jXY ucWpC+lQ9BEaSN0x47AbGZy6Uhl1lpUmV1l894/OzHNNV/dmIuvXSk0UpqOYvXjYhS8c Ypt3ELbEV62OJiej+h1vxi9OKsMGCpiKjGD0S49EXaAKyqT0/HcsA6tMTpovg0OZmYL8 O+ETWM7jrWREo/Tbc+1Y/uLTD4hUAlohmGtYNSYvoXLYUgHO8I6UYftu9R6ayqcx/Yis ouU1gAlXsuU5IHaW5cfhaQk1cxPsnRz8kgTEVuO5oWFhTNkCUDF2vDZ/Hh/XhrgsGT4C eR9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793517658; x=1794122458; 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=lvLN24gtIiDD108HbQ1hU9mpKtt6mQ07/LEzVwndxzA=; b=jVde6GE8HDsfTNw0fJFmzVeQbC8wb3zebhRHTVmzflq2TlQw9JGMzc4TCcFL2uniSF c22thrKGDieAGOxyA5UV5sBoZreZuHref1EVBOTfT5tRgfZU7zaGAIr3f3wn+GVLPqfG 1L/NmNtJLQBIUhSiDUqSfsWLdPIhCJ+EL/yOwf2Eqy++z9QFzrjO+663yLRUibpSkobz 2kmhYk6QzUmxsAoVs44/U5oQjyzx4eyxKu6dofaV0ulI5YKtaadFuFQ4UlxKPKpqLjvn D/ycPKdM2j3Sbe0r6SfNP65iRF5QANt9csjifMRdGS+m/R3ZxlrtOvPM/KAMPl9fB4JX Mb8g== X-Gm-Message-State: AFq9FYKLvHGnxZ5YkcDo3n5HaD6foEUsU9PFVqKIT21SHvMNk9dfg3XC EkHb4tDJqNzeb/Fcx5QErPL8iJcmGW/x3K9HD2sU3FXfKS9lOFAAoejB1r/mTQ== X-Gm-Gg: AYBFou3MHZB0bK42qnT3V7EX/4e+TH3J4CyWYrYOOgYNuTcYjktJ8hmV4kDYWW6jAMm NUCowP31Wxxy9wa/VyTHsRBfU7NLgnV2Qls6fArdAQ6eAVKJV5jERiPsgw/HvJJRKMeWPtmpROt ijoOQ9X4ac0+oXYAxSUN3wk24O3vsL74oGs6FEOWExGIy/q0psbTZ3DCwKgUICJFThLf+quWDhf KcotpiiDPiNIpnzk3kTeN8uUZeYEYK0RJTNLn33E3uaizL6pT3H7xZQP2CgnPQnzx+xM+W880Xi yx/C7mmZVSSrEG7gRrpHLwaFs6lWCcJymSN9+Z2Sdits386Y43gsHm04usb8L7Yx7LDIlkLzuOB HJijAYlMK8SUlz1XFA/88cZ/j7ElNZif8SPov2gXfSdY2w51sU87RftEu9SUQJuBhZFRji/S+U5 JGcx1PkQZHi38CIe5eRr2j3NHbSxAKiZJMAXwq+CYTLfvGQIj17bU6jOr+8czkxdw+GAViAOOXK exkKmdTqodT0nEPOYvyg0TNHvfG6cKYfP4dRBdB7hVEUuluSAfPK+u+Wjse0m3BFS7UBOmze1Rf dhYxZ4jGrX0YiAIl4LzjB6pUavHHLjtCAMLN+krtfwQmrmWdZyrbRwiAFoosl881E17D57F9H0j JAbDG1uOyABy374N+YBJ6Ii4blV2lsj3apLkxIO0aHq2lTLUG+p10d4FnwSnSIhXcH5mkfapXbw == X-Received: by 2002:a05:7022:5e09:b0:1a4:3169:cb with SMTP id a92af1059eb24-1ac5cfe5610mr9557267c88.17.1793517657572; Sun, 01 Nov 2026 00:20:57 -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 a92af1059eb24-1ac1854da78sm29851495c88.6.2026.11.01.00.20.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2026 00:20:57 -0700 (PDT) From: Anil Kaushik To: mptcp@lists.linux.dev Cc: Anil Kaushik Subject: [PATCH mptcp-next v14 1/6] selftests: mptcp: connect: retry write() on EAGAIN Date: Sun, 1 Nov 2026 07:20:46 +0000 Message-Id: <20261101072051.3853492-2-anilkaushikwireless@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261101072051.3853492-1-anilkaushikwireless@gmail.com> References: <20261101072051.3853492-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 1 ms retries as the timeout in ms: poll() does not check every cause of EAGAIN. Fixes: 048d19d444be ("mptcp: add basic kselftest for mptcp") Signed-off-by: Anil Kaushik --- Notes: v13: - say how many retries are done with a poll timeout 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:29:03 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793517661; b=SUyGzUQr24Mi1d7VySDAYW/RxopYlj+KTRrP8s+3e5R4MIgnkVUGDPWxQTKQ0AmHEiqK aizxLqLXavT9UAIShprQwSWYs6F6/cs4csl/14cFU5JvyUXLNjJV01eeV6Rv6iYGDaEcl ztIc1BDUjC+g1Zco+dfL4i9gy8y/cBHgZAOKY1jlLpX03MkePLxvF83A8g7AuYw/RENqw jIimc2yCnLGYA0XQRjlQxOdd4FovVCMWKZ25D7Di3tg2YhnmZR8vuIxLOmJ1TEUrA+1g5 +VkyB9V1XAzHCVbWTZF5YqY99iLQ7xGZhhEcuO9pV/SDMWfeX6nP4HgN30td82hys7w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793517661; 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=IagCUlJLwm8jDT8pA24YNNWITQvFjmfat0GD/9xIF6+8Oj8aj3zoASp1Hixns3rYEIRY 2DOu1ZQSlYa6VJ64WMktEyap3onMC6zL14xfFwYyDKiGjBeyetsEG7hTvuDp1L6/d9VM1 sX6d5xSXeklRDRQjJ6rLTjnILtNvzOemSUgfOaD1THK/tNYfQBx2deBHvBIYMGEtTI6Mf DIf1Xo5A0v/DKgNILqvEgOLrU4Ba+7XD2JcY3PGUEplbgm4dxqhhiXxr16Z6b0sDOMFzq Qqs8UhJS8fNJb1cNeKQ4pIClRut8D8BJm2hU371fhYH6eY3lDrEztwxVZD5TPpk9qNA== 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=20260707 header.b=Rc9xZCr+; arc=none smtp.remote-ip=74.125.82.45 Received: from mail-dl1-f45.google.com (mail-dl1-f45.google.com [74.125.82.45]) (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 B54A2606A325 for ; Sun, 1 Nov 2026 07:21:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B54A2606A325 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=20260707 header.b=Rc9xZCr+ Received: by mail-dl1-f45.google.com with SMTP id a92af1059eb24-1a2761c69fbso2432837c88.0 for ; Sun, 01 Nov 2026 00:21:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793517660; x=1794122460; 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=Rc9xZCr+VAY8qiIntVp6ZJ+U0WI4uDGs1nv5fjwJVNCAMgJ2chHf8YACrBdlFGyHmp uY4iVYD6z9OuzsnbiBIiTSPdpBLzWq3EEmHrVUSW9D5lLBRa2gJ+Ip4jow2zJ887k/yV ETX2JNrvCSxru99+U0AiCLGc3loXrX7ngFZ/XD2J7H8gLxTHDqvOPzn7Sxt05MKKakaq UxKmkae8RnylJNm3v75V6775ElrrMaVZwKipC55pBgOs1YE/j5Lz3qs+zlehzWCJCN6/ E9XyhW6l2rCeFWW+tKMkQuMrmjVlNUw7GXN6q8IPT4iHaHPF9Vfu5fOnpQA/QnVn6ST+ atqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793517660; x=1794122460; 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=osKsn2MsMMFVFtM1UQGvLeBHbWp2QZIOhgJhEGc1YOPPPtXahb65eiqEg7N1/Py1En TbS6TB5p3Ue8FyUHkmHGmpM0tpc6LUqonPx9BJKOX/xjT+r6cNoluXiktKyl9yrZlH/r 7XKNzBh1ADeMmbkltnjz5vv/hAyg5OEWDvCVyEZeo4L+kldE6WY3g+x6d+U9vqL7icjA LJcLjAyZuMB5hv81mlEdcjkTwT+s9JPw2qaRXWWJ427qb9j5L6okwNQ2tir0n3ppiisi E9YcsX/z9z5sduR2Z5vOEerOs6/IBfMedFrB4g9iNoSgsH6gVay39kehyowfP9VqPKSp yQhA== X-Gm-Message-State: AFq9FYIYCREssx7dotGl9C1DcYjdhOyorbYOihUDa11cfcuqzZa/Zvns B2PESlf9XzCLopjKqoIkWGuszCzkWlvvX7PWHGAWIsK5FISJFP8NdYE6Ovwtdw== X-Gm-Gg: AYBFou0BysKkrIDVzWjIlA3juwviruC02+VjbdVHCPgVkPlRmPCjuzSwaIUPHe0Xj6r nLrzHETrZWxTKaZDYvTtQ5wiTyjEtZzk9Q1VPt7XP/gBNW3FZuB8AZruhvlGBFUbfBUcb0K6Xde TKgfKEUiMNqCKDHvAG7V2YM6y7wJVr9cdHdR13DS66ecJKumdf/mLYO094OHJEhFZNBZfs/qIlG NQ5bhN5dcI361oX2D4uzL7sEOETEjSP87AlMAdUv+xq9YLHj26y+PMxSiop+0qlTlLYacpqUZqm v9swssVmbFl3/Yplyuse6KvR4x8PBpnbo1FfmNTdCAedw1xYyGL0uau/XKX+YFbjDoFmpkDbq/u v6xh/wcuC7ZBjdTaNbwQV+V9kQFy6HKY/+mVRP3cl6F3VRF41cmcMO3GRUjCAtObDG6d41zRbdI Un0UcmWCCkWEIoFk68xly/E7Z5xuVlEc3LWyrzfSNGcS41R6/LPodSNPLAQHoHLzwWSlF9lASB/ 27s82VRA8iHT5NkRMRm120DIKKadF7+U+5J35SHd3Pfk7Hix7w9nrC/Iyb4HigEiJBqsDowEIQf Jq1V1zRdJ/+87TVX9e6lDHcc6yIhQEwlh5m009BivHuzhxhVB5bzZPl3YmiHA37wRva/Yi2jyxD G1zoW0ziGY36jK6oE/j/t7SiAJBkOmIFYbE+COlfCKhyE94Vr8lvbS11WGTblVhAPr+bxulHk/A == X-Received: by 2002:a05:701b:4550:10b0:193:8116:f5bf with SMTP id a92af1059eb24-1ac59dd358fmr9627306c88.16.1793517659650; Sun, 01 Nov 2026 00:20:59 -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 a92af1059eb24-1ac1854da78sm29851495c88.6.2026.11.01.00.20.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2026 00:20:59 -0700 (PDT) From: Anil Kaushik To: mptcp@lists.linux.dev Cc: Anil Kaushik Subject: [PATCH mptcp-next v14 2/6] netlink: specs: mptcp: add the subflow-retries attribute Date: Sun, 1 Nov 2026 07:20:47 +0000 Message-Id: <20261101072051.3853492-3-anilkaushikwireless@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261101072051.3853492-1-anilkaushikwireless@gmail.com> References: <20261101072051.3853492-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:29:03 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793517663; b=nf+RRAwvEdn1KOCdOsfxBVbj4jLKRIDJNzP8Wd3HONh6IavR2XWdrh4bhs3gQJTkyA80 UHu8GB7C/h9SqcxJec1Fuo9OgZvv9hLgbpWDTjVc3P8en6tG2sFryJLyMjWex+015jBXm t1cPNs07hONHvYk8eXysfIL+NaTBYeeVkJGTsvjlntoG2FXU/ZQhgo/1SXLVVXpgr6B5M 3e4qgt9RoyfJqqIXd+Cib2es6cYWhncy4ldiRYujstwSORg8PLKQZb62H79VYfbvNRRPi QMjNzlM4vwuxZ0EKM7zuVBvHpsl3Chgv6W3ZRO8MZuOKftWgmLjPieWJd46Ea8DDzWA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793517663; 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=2uGc4MtCrmj+7j1dwjSsJVZHzwywOnAKL3e6vrCOkkF5aPyeKofzuM5+j+c1kSXBTJg9 F/sXpLK8JDT+ZbxBERogOviploB2LzckjQvznlxBdt7GlyCHgmtNg2WJIaq+n5VVe5XlM 1o4A/T3oq7krZI5Kj8dTZ8NXzz1FF1Pq9iZH5ibrFWFWYADyf4huRElpWObf+qbgnvGeI E1n6hsO5i6md8tBtzRoc7UTv2JEvE02ajwzKwoHWvf5RMOuzVBU4ldudL/Uqbdtn0Wq3Y qkpwfEUJ+Ql7I7edFjPrrKAtKyCQdytggu1bouzQ9M/GIpy/SwY+qE/vm6T2GDUOFcA== 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=20260707 header.b=smS7w95Y; arc=none smtp.remote-ip=74.125.82.50 Received: from mail-dl1-f50.google.com (mail-dl1-f50.google.com [74.125.82.50]) (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 C1C22606A327 for ; Sun, 1 Nov 2026 07:21:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C1C22606A327 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=20260707 header.b=smS7w95Y Received: by mail-dl1-f50.google.com with SMTP id a92af1059eb24-1b1ce85287aso33301c88.0 for ; Sun, 01 Nov 2026 00:21:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793517662; x=1794122462; 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=smS7w95Yi6umm6oCRRXiAQLmY/K24sWdVy7LBT2YNQkBZBu3QN790v7z4VOt6DRxET 5ShoFqQFkeG9eMuDGEH8x85CatpQDx02DnjgDz+pp+MVrPNTFLOyJ6zCudZYNNfIreXg E1jYWdmHGyqlfZuFvafAHCsoUQWNQ8usErdPXF3jUtXnN3U6DS5JetiXxS1a+yLAW+ok c1Z2APji9SnGUGyIIdNE5ScjjU45BpetEhg18dfuVWd+atvsnxCPDtGv7/jVX8p5VAd2 q8vIa3RPJtOfQwTP4+VgCoLRMTrqUpO6vlFDdKHJgL+mOpG72MJfltq1WQl0cQZO1JDK dEpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793517662; x=1794122462; 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=wNBTey9+hzHfX1+a3Sad4aYiPkTqcjhjGoHo67Vo2M2ZiTZfSDy8wmcMVwEtU75tTS 0/6RqKB5nHcRcvSFPFI2lfwhKr3k5/QXOjCgXDpQvpRZG3qLaPjmslEQ2hdRZH+zxx5D 79olG60IVtAPEfk2HmVRoftw5wcClVpBE0EsD/GxoK5/xSVutvX7zlWJ4mWqecTkiytm ZxFXNHKOXA1kCuQGQpujZEFln2J6Ck7Hyk5Z4oDHQrQosEt+uISHbRRX6U61iPu2vpS4 UMFOCskiFHY1NoUU997NRtkfmMczwU+P6DNPBpZx7hpZcCe3dliQ0yx5scW4O4I5isyD vNyw== X-Gm-Message-State: AFq9FYIzL9imh6u5wJeVtT8ULQbz8iBIinysNakquNaUzfHw1QmabjxL nxR7wsG86Y1IXQbkQ1Lz7S67sC/MiG6EhiJs9zpFW8N2t93W8nN3kKHmJk532g== X-Gm-Gg: AYBFou0/mPLoRNBoKGm4cXHMw+5rgj9f8CS0kL+h26PT37a0GNf2o3t0gZyjrj9Qrb2 uZMMPm2/QtkBQeKvx2FSb8aoM7+wmgvjly2m8fUsuiTZ9Kn4BzsXKi1KPU3/Yz9wkhbwr+ut+gZ jSIctVrvixl1xlLvZkzkAMVMCyeFEX5sqC9QsKi3TUG66TNr7F++AkHnSPNsUNfoctqv7rPNPYa BJqa3EddcZYA/6YqxJyg/VwyXQuZZw0W2FmQO6+uaOzYnON8iWwk+efWxm4z5daZC1MDIwzFCYw Eky06I86EJZsXkPtHfb956ZD57QoDudQroJvjHaHJahTLp6Ke1nqAHZe0eIpIdjqLqZotaU3ZlT /RE8Zc4Ma7C9wvPyVsGcj5ldvQpcQk7Yok8dn4QdLH2D06hOaHdrH/EqXT80nkwvbjNORTI1djJ Ztez/h4chN79KQOu6iK7DSR87WPLpbanZ2i0Op3WneqtbG09tGVIDtOCqAu3cRcueuWc4FKhy+v eAeNgSOJb9YKKWZJi7/PcfY80dsU2WDrriboaOq/b0ZP9M8JLv84JOVrHUJbkT5HCCwSzR5vANx qMSiqOfY7YsZHOzb5NvgbkKk6FtLO5aM6kBf2VkmfAOMbsMNpSBLMCJQnQt3zWNJ0g7YkaRiXAw /SLHdwLzvlZn8FHrhyjA/WRq5Pqp9g7NKXjxG/H0XZ5YSSSNbEv+WglQ13VXvxrqjeAvm5sVoVR I= X-Received: by 2002:a05:7022:f20b:b0:136:c443:80e5 with SMTP id a92af1059eb24-1ac56d94b0amr10494082c88.6.1793517661588; Sun, 01 Nov 2026 00:21:01 -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 a92af1059eb24-1ac1854da78sm29851495c88.6.2026.11.01.00.21.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2026 00:21:01 -0700 (PDT) From: Anil Kaushik To: mptcp@lists.linux.dev Cc: Anil Kaushik Subject: [PATCH mptcp-next v14 3/6] mptcp: pm: in-kernel: add the subflow-retries limit Date: Sun, 1 Nov 2026 07:20:48 +0000 Message-Id: <20261101072051.3853492-4-anilkaushikwireless@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261101072051.3853492-1-anilkaushikwireless@gmail.com> References: <20261101072051.3853492-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:29:03 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.54 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793517665; b=qTN2zxoUwSqMmRYj+0RUqckS/C5fAz7J/QbVfNKih9q2ef2Vm7d737jmu3t58krrFhdV FKUjmmp/o+awk5l7kgE/3711kxzpAMK4LGFKFLn+3JOg5M4QaD6c6VrkLY1p6uCJi1KrS 5SMDFSDtfCCDIz4hrvVBAK3PsZOu3jbMn+NeOOFHQ9BpIZsgNOJue/gupnHlzukxLriuP kqpu9SIXdrqPq1Xj5LJ9T8N7bXUIJLAkv0haCB5nxPB17odp3O3Ng+j2kODG5S0zwM5Nt wbt5BRWl+xwyuDVx9f6f93ceJNw7UtGHzE6dCUYoHIpdB+0hGgcuFdHQLzQF20dbQXQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793517665; 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=Gd7OY+ZYkyQwmU0ldGf7bsfCnDmoRMXoZVGY3ceRJWU=; b=oOJ4DitdxCO5dQbJV/lStqkuqQ22k1xCsy3xzrDtMVmk5gnCQJXN6u5ZsHmhpswdttCq gZp3XxIIl5aBbxiNlsr+R3BYYB4+ctx6l7n8R7N+ThDsgDHm8c99fDx0lTGUOqfVKKcf9 4m9B0QzgO5y4nbjj4U3obg5GvjDToM1NtskiPRRf1HI2dgB58JF6lZ0JAxub4W/ddRAle YyXHEtOHoFWjz0BoB9lH4XbmsaOXP/DzTXgS+0ECNZbGPM/9Sd8PlaXQWOU6TuoR0lytU +PbMTETFMQ37cM5LpPoRhBndunKn4yXyfkID2/16Qu1UkvaIH1QPP/Z7nAmNf8YC/gA== 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=20260707 header.b=QKZAWc3+; arc=none smtp.remote-ip=74.125.82.54 Received: from mail-dl1-f54.google.com (mail-dl1-f54.google.com [74.125.82.54]) (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 0BD35606A327 for ; Sun, 1 Nov 2026 07:21:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0BD35606A327 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=20260707 header.b=QKZAWc3+ Received: by mail-dl1-f54.google.com with SMTP id a92af1059eb24-1adbf62dd31so1982633c88.0 for ; Sun, 01 Nov 2026 00:21:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793517664; x=1794122464; 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=Gd7OY+ZYkyQwmU0ldGf7bsfCnDmoRMXoZVGY3ceRJWU=; b=QKZAWc3+kcZIAd34t6l8mZ/Ra8bHx3Vs3s3eetk1iv8zEUKKxvUBRWBLISB9Yfc7kZ 9nFQWTaFMGIrUn01cXcFQxmO41nTyhYb+W2r2drsCcEyi5JX8RoadwWsjucTyymG/IMr H9e8XsBbrvqkeKPPXudp3u38JN28gjKVo/MMLCYcpo+y/8JaRANezt/MRNb/tcy/n53Z GUCQSmovID6/GP1/R67A09T3QQKXz436WNrfqksqlykSCeugexZ4VGMqhMC48D9DEB5c +F1Hoq0c4ZesAvt5gzWZ18d3oy4Jf1d2whnC0gLS1mbaIfv231N9JIeL+H7TK4ZN5N2N 3k4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793517664; x=1794122464; 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=Gd7OY+ZYkyQwmU0ldGf7bsfCnDmoRMXoZVGY3ceRJWU=; b=lJWU/BqQRUgnWY1+kvrd6+9vA5x15VrHh38MLQ9aOl9t+8dBpCJvtyClsQ07cYBg2m U0gv9bub2Ca9RnPmJAZyP2uSzNJf66tAEvMnx80zKCdL1gnMOBZAkikFH/qnI5/oSfZw Wg6JiBkNmjiOaT6EgVwUMBvAieWkCRU+2PcYY0W19cd3JvCocdynFgE2Ki4PFVS3OJp4 9VHsqou5WjweEykzjozHInxcRct3lcgE/jUtTkEjKVdQZPiKDAjCnZXqOEGf0oZ5L7nb sUTk2ldY27+gwE0BCYk4NqR0NyGwUtvgo/jqEZTS7B7WJArnQ6JZ+rSCETG6U4pbtcIw /EyQ== X-Gm-Message-State: AFq9FYKtCDe1K2XoW/mT/VBjU5ujXhAdTDX7NU87+Yb0MjLJ9hOhFpoz 7rqDNVNre3HFyGjV2IszvDyenJI+eyitLD0iZfhc5MjAJOykA0qLCHrbFH3LqQ== X-Gm-Gg: AYBFou2QPJUgW/zQiSqst2Gi107z17RDvvSI+/IDEh7VyprVaWuq8h/rZKrxo07nBaI aJ2Q2VIaOAjVJfhllXzaiiiR1vzXk4nNHGvnoGRKJOMMsKLiehdSruU/5xmwm/PXjG5HXtagpvR O1lrPDHWrpixB91P5Zqw26gpbKEKbmx/6288x+P2kN0iFUKhYM4MIHM7x2eItFLmbGzbPsWfBhS 4koLKIBTmHMivenXjgezpph8F2tPZvfJOgmKvVjSjkr7enU9AVLnbp1VJDo8rVrZWVUNevoeSpz Y3KAsubUTZgRBMxlWvNeCNZm76ddyjrah57jrxdi6UH3p+eyV5Q1qn+Cw/QRp3aexcBOAswf6s1 zv5TQFWrjkI5mHpXBdqztxfQBsya3J9j2HBr+h96Z5GdBXJ1Nbdj5r9oCAGzXhPCRHlAjVN5piT p0dqA0l81oqejBgNG0R6jErHfHWbq3gN1ZBKtuJHgqGoyHINKb/bMjTVTmSlg8dsSp/8RR3fqHf MAZ5owLKIMozBywZr9UVgSFOBGZZErF9RlnV23GpjqwtVvRNpQbA0ts08wqkw9Dm2ayrDiFOi8R QjCYJITx3qnmJscwv/IRxZkmRbLPZqY7ArXHRC3IsAJPa0Umz3H+gAhlBqlRn6mWG7dtrcGLIZ9 tGQbN61ihJKn9poSoWJpWU5hgLNF8DBziOUZXqHYfMROuowDX68oGGHeJUPtokalp4Y2aGKUxMw == X-Received: by 2002:a05:7022:2606:b0:183:bebb:e93b with SMTP id a92af1059eb24-1ac563025cfmr10873086c88.6.1793517663568; Sun, 01 Nov 2026 00:21: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 a92af1059eb24-1ac1854da78sm29851495c88.6.2026.11.01.00.21.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2026 00:21:03 -0700 (PDT) From: Anil Kaushik To: mptcp@lists.linux.dev Cc: Anil Kaushik Subject: [PATCH mptcp-next v14 4/6] mptcp: pm: in-kernel: retry subflows closed after an error Date: Sun, 1 Nov 2026 07:20:49 +0000 Message-Id: <20261101072051.3853492-5-anilkaushikwireless@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261101072051.3853492-1-anilkaushikwireless@gmail.com> References: <20261101072051.3853492-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. This is only done while the connection is established and another subflow can send data: otherwise the connection is closed after the close timeout, as before. The re-created subflows not fully established yet are closed when no other subflow can send data anymore, when the connection is no longer established, e.g. after a DATA_FIN from the peer, or when the MPTCP socket is shut down for writing or closed, unless they got fully established in between. A closed one gets an MPTCP_EVENT_SUB_CLOSED event while the MPTCP socket is established, like a join that fails. 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. 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. A re-created subflow takes the place of the closed one in the subflows limit: while it is connecting, an endpoint not used yet is only tried if the limit allows one more subflow, or if the new subflow cannot be created. Subflows aborted locally, also by MPTCP, or using an address that has been removed are not retried. TCP only closes a subflow after a retransmission timeout set by tcp_retries2, 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: v14: - keep the slot of a closed additional subflow for the new one, so a join from the peer cannot take it in between (netdev Sashiko) - if the new subflow cannot be created, e.g. a local error when connecting, the PM tries the next endpoints, and a slot kept while the limit was lowered is released - the commit message and mptcp.rst say the subflows are only re-created while the connection is established, and that the ones being re-created are closed once it is no longer established - the commit message says the SUB_CLOSED event is only sent while the MPTCP socket is established, and that tcp_retries2 sets a timeout, not a number of retransmissions, also in mptcp.rst (netdev Sashiko) v13: - close again all the re-created subflows not fully established when no other subflow can send data, not only the ones still connecting: a joined one waiting for the 4th ACK could keep the connection open forever (sashiko.dev) - __mptcp_close_ssk() checks fully_established again under the ssk lock, and keeps a subflow that got fully established in between (netdev Sashiko on v11) - say that a re-created subflow keeps its place in the subflows limit, before an endpoint not used yet (netdev Sashiko on v12) - __mptcp_close_ssk() cleans the msk backlog only with MPTCP_CF_PUSH again: a re-created subflow it closes is not fully established, so it has no data there - say that only a shutdown for writing closes them, and that they get a SUB_CLOSED event v12: - when no other subflow can send data, only close the re-created subflows still connecting: a joined one is fully established soon, and stop once one got established (netdev Sashiko) - a subflow in CLOSE_WAIT does not keep the re-created ones open either: one helper for both checks (netdev Sashiko) - mptcp.rst: the initial subflow is not re-created if the peer does not accept joins to its initial address (netdev Sashiko) v11: - re-create a subflow only while another subflow can send data: the close timeout is then handled as before, no more re-arming nor stopping it (sashiko.dev) - close the re-created subflows not established yet from the worker, or when the msk is shut down or closed, never while iterating on the subflows: mptcp_close_ssk() only schedules the worker (sashiko.dev) - also close them once the msk is no longer established, whatever their TCP state, also when a DATA_FIN is handled outside the worker (sashiko.dev) - SUB_CLOSED event for them while the msk is established, like mptcp_close_ssk(): they can have been joined already - another subflow in CLOSE_WAIT, being closed, does not count as one that can send data 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 | 23 +++++ net/mptcp/pm.c | 50 +++++++++ net/mptcp/pm_kernel.c | 160 +++++++++++++++++++++++++++++ net/mptcp/protocol.c | 77 +++++++++++++- net/mptcp/protocol.h | 51 +++++++++ 5 files changed, 360 insertions(+), 1 deletion(-) diff --git a/Documentation/networking/mptcp.rst b/Documentation/networking/= mptcp.rst index b6753ffb9c9a..91b06f4f63a2 100644 --- a/Documentation/networking/mptcp.rst +++ b/Documentation/networking/mptcp.rst @@ -73,6 +73,29 @@ 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. It keeps this place while it is being created again: an +endpoint not used yet is only tried if the ``subflows`` limit allows one m= ore +subflow, or if the new one cannot be created. The initial one is not creat= ed +again if the peer does not accept joins to its initial address. This is a = single +connection attempt: an ICMP error, or a local error when connecting, ends = it, +and it is not created again. This is only done while the connection is +established and another subflow can send data: otherwise the connection is +closed after ``close_timeout``, as before, and the subflows being re-creat= ed are +closed too, as they are once the connection is no longer established, e.g.= after +a DATA_FIN from the peer. A subflow reset by the peer, or by anything on t= he +path, is not created again either. TCP only gives up on a subflow after a +retransmission timeout set by ``tcp_retries2``, about 15 minutes by defaul= t: +shorter outages are handled by TCP itself. A subflow that only receives da= ta +does not notice that its path stopped working: the application should then +enable TCP keepalive on the MPTCP socket (``SO_KEEPALIVE``, ``TCP_KEEPIDLE= ``, +``TCP_KEEPINTVL`` and ``TCP_KEEPCNT``), which MPTCP applies to all its sub= flows. + Packet Scheduler ---------------- =20 diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index d7c5b50b34cc..2772b97303bf 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -694,6 +694,37 @@ 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) +{ + struct sock *sk =3D (struct sock *)msk; + + if (!mptcp_pm_is_kernel(msk) || mptcp_pm_kernel_retry(msk, retry)) + return; + + /* Not re-created, e.g. a local error when connecting: its slot is free + * again, try the next endpoints, like mptcp_pm_subflow_check_next(). + */ + spin_lock_bh(&msk->pm.lock); + if (mptcp_is_fully_established(sk) && + mptcp_pm_nl_check_work_pending(msk)) + mptcp_pm_schedule_work(msk, MPTCP_PM_SUBFLOW_ESTABLISHED); + spin_unlock_bh(&msk->pm.lock); +} + void mptcp_pm_add_addr_received(const struct sock *ssk, const struct mptcp_addr_info *addr) { @@ -762,6 +793,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 +843,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..403362b78072 100644 --- a/net/mptcp/pm_kernel.c +++ b/net/mptcp/pm_kernel.c @@ -1610,6 +1610,166 @@ 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; +} + +static bool mptcp_pm_retry_other_subflow(struct mptcp_sock *msk) +{ + struct mptcp_subflow_context *subflow; + + mptcp_for_each_subflow(msk, subflow) { + if (mptcp_subflow_can_send(subflow)) + return true; + } + + return false; +} + +/* 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 while another subflow can send data: without one, the + * connection is closed after the close timeout, as before, see + * __mptcp_close_ssk(). + */ + if (!mptcp_pm_retry_other_subflow(msk)) + 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; + + /* The slot of an additional subflow is released when it is closed: keep + * it for the new one, a join from the peer could take it before. + */ + retry->keep_slot =3D subflow->request_join; + if (retry->keep_slot) { + spin_lock_bh(&msk->pm.lock); + msk->pm.extra_subflows++; + spin_unlock_bh(&msk->pm.lock); + } + + return true; +} + +/* Called with the msk socket lock held, after the subflow has been closed: + * true if a new subflow has been created + */ +bool 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; + u8 limit; + + spin_lock_bh(&msk->pm.lock); + limit =3D mptcp_pm_get_limit_extra_subflows(msk); + if (retry->keep_slot) { + /* the limit can have been lowered in the meantime */ + allowed =3D msk->pm.extra_subflows <=3D limit; + if (!allowed) + __mptcp_pm_close_subflow(msk); + } else { + /* the initial subflow takes one of the additional subflows */ + allowed =3D msk->pm.extra_subflows < limit; + if (allowed) + msk->pm.extra_subflows++; + } + spin_unlock_bh(&msk->pm.lock); + + /* on error, the slot is released, see __mptcp_subflow_connect() */ + if (!allowed || + __mptcp_subflow_connect(sk, &retry->local, &retry->remote)) + return false; + + /* 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; + return 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..cb1350ba1a41 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -736,6 +736,10 @@ static void mptcp_check_data_fin(struct sock *sk) if (!__mptcp_check_fallback(msk)) mptcp_send_ack(msk); mptcp_close_wake_up(sk); + + /* not always called from the worker, which closes them */ + if (mptcp_retry_subflows_stale(msk)) + mptcp_schedule_work(sk); } } =20 @@ -2637,6 +2641,7 @@ bool __mptcp_retransmit_pending_data(struct sock *sk) =20 /* flags for __mptcp_close_ssk() */ #define MPTCP_CF_PUSH BIT(1) +#define MPTCP_CF_RETRY BIT(2) =20 /* be sure to send a reset only if the caller asked for it, also * clean completely the subflow status when the subflow reaches @@ -2695,6 +2700,26 @@ static void __mptcp_close_ssk(struct sock *sk, struc= t sock *ssk, * subflow close. */ lock_sock_nested(ssk, SINGLE_DEPTH_NESTING); + + /* a re-created subflow, see mptcp_close_retry_subflows(): the ssk lock + * defers the 4th ACK, so it cannot get fully established meanwhile + */ + if (flags & MPTCP_CF_RETRY) { + if (READ_ONCE(subflow->fully_established)) { + release_sock(ssk); + return; + } + + /* like mptcp_close_ssk(): it can have joined already */ + if (sk->sk_state =3D=3D TCP_ESTABLISHED && + !subflow->close_event_done) { + subflow->close_event_done =3D true; + mptcp_event(MPTCP_EVENT_SUB_CLOSED, msk, ssk, + GFP_KERNEL); + } + mptcp_pm_subflow_check_next(msk, subflow); + } + subflow->closing =3D 1; =20 if (flags & MPTCP_CF_PUSH) @@ -2788,6 +2813,34 @@ static void __mptcp_close_ssk(struct sock *sk, struc= t sock *ssk, } } =20 +/* Re-created subflows not established yet are useless once the msk is + * closed or shut down for writing, or no other subflow can send data, see + * mptcp_retry_subflows_stale(). Not called while iterating on the subflow= s. + */ +static void mptcp_close_retry_subflows(struct sock *sk, bool stale) +{ + 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); + + if (!subflow->retry || READ_ONCE(subflow->fully_established)) + continue; + + /* another one got established in the meantime */ + if (stale && !mptcp_retry_subflows_stale(msk)) + break; + + /* Checked again under the ssk lock: it is kept if it got fully + * established in between. Otherwise, it has no data in the msk + * backlog, and the MPTCP retransmissions cover what it sent. No + * need to push the pending data again. + */ + __mptcp_close_ssk(sk, ssk, subflow, MPTCP_CF_RETRY); + } +} + void mptcp_close_ssk(struct sock *sk, struct sock *ssk, struct mptcp_subflow_context *subflow) { @@ -2806,6 +2859,12 @@ void mptcp_close_ssk(struct sock *sk, struct sock *s= sk, mptcp_pm_subflow_check_next(mptcp_sk(sk), subflow); =20 __mptcp_close_ssk(sk, ssk, subflow, MPTCP_CF_PUSH); + + /* the caller can iterate on the subflows: the worker closes the + * re-created ones + */ + if (mptcp_retry_subflows_stale(mptcp_sk(sk))) + mptcp_schedule_work(sk); } =20 static unsigned int mptcp_sync_mss(struct sock *sk, u32 pmtu) @@ -2823,6 +2882,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 +2895,10 @@ 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); } =20 } @@ -3185,6 +3249,9 @@ static void mptcp_worker(struct work_struct *work) if (test_and_clear_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags)) __mptcp_close_subflow(sk); =20 + if (mptcp_retry_subflows_stale(msk)) + mptcp_close_retry_subflows(sk, true); + if (mptcp_close_tout_expired(sk)) { struct mptcp_subflow_context *subflow, *tmp; =20 @@ -3516,6 +3583,9 @@ bool __mptcp_close(struct sock *sk, long timeout) goto cleanup; } =20 + /* before __mptcp_wr_shutdown() disconnects them */ + mptcp_close_retry_subflows(sk, false); + 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, @@ -4140,7 +4210,12 @@ static void mptcp_shutdown(struct sock *sk, int how) { pr_debug("sk=3D%p, how=3D%d\n", sk, how); =20 - if ((how & SEND_SHUTDOWN) && mptcp_close_state(sk)) + if (!(how & SEND_SHUTDOWN)) + return; + + /* before the state change and __mptcp_wr_shutdown(), as on close */ + mptcp_close_retry_subflows(sk, false); + if (mptcp_close_state(sk)) __mptcp_wr_shutdown(sk); } =20 diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 4aa4aedb2ba7..0b2b9299a032 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; @@ -919,6 +921,37 @@ static inline bool __mptcp_subflow_active(struct mptcp= _subflow_context *subflow) return __tcp_can_send(mptcp_subflow_tcp_sock(subflow)); } =20 +/* Can send data, and is not being closed, e.g. in CLOSE_WAIT */ +static inline bool mptcp_subflow_can_send(struct mptcp_subflow_context *su= bflow) +{ + struct sock *ssk =3D mptcp_subflow_tcp_sock(subflow); + + return __mptcp_subflow_active(subflow) && + inet_sk_state_load(ssk) =3D=3D TCP_ESTABLISHED; +} + +/* Re-created subflows not established yet, while no other subflow can send + * data, or once the msk is no longer established: they cannot join anymor= e, + * see mptcp_finish_join(), or must not keep the connection open. + */ +static inline bool mptcp_retry_subflows_stale(struct mptcp_sock *msk) +{ + struct mptcp_subflow_context *subflow; + struct sock *sk =3D (struct sock *)msk; + bool retry =3D false; + + mptcp_for_each_subflow(msk, subflow) { + if (sk->sk_state =3D=3D TCP_ESTABLISHED && + mptcp_subflow_can_send(subflow)) + return false; + + retry |=3D subflow->retry && + !READ_ONCE(subflow->fully_established); + } + + return retry; +} + void mptcp_subflow_set_active(struct mptcp_subflow_context *subflow); =20 bool mptcp_subflow_active(struct mptcp_subflow_context *subflow); @@ -1139,6 +1172,19 @@ 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 keep_slot; +}; + +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 +1306,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); +bool 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:29:03 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=1793517666; b=HBagkh6poZroEZ7jfA1AfnEnYx2Hyk7aG0lpb1+vpPKlsFLUmZYLKLzUtulHDPlbXsQc ClTg+gZPTNdk1Hyr6+OV8z2J10+XgZhwpI1AUMJTJ2Hxg4/Puz+ZTtKb/Fl2f60exGauW pjo0Wtut6jwFCmQJ1SnoXixg0iK8qVy7/rYZaZjStDnGF2NtCZ9VaGjsS8To/sluDGlbH 31FBaKoxTXq9kTZA0Co49HYr0qc0GjELM9eoNx8bU2N4XAjwIJgE2GSgjlJ8xvjmG/ymA RDjt5S36S2mxOT75EEkzBjfzndTNaILPO4dMh3bPv34/Zg+L09nMb4liPRjBK40Brwg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793517666; 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=bk08wlQLOckMDa/tQlUY0Gs+7pq28CqTbcZ5/8r0npg=; b=g/VlX8iVuNdllsRglIh1RBqHzXwwtXfHXWJHkPinIM7QAkZMirpKFWQNdE5fNzdCWtaj 1GohoE7pgemhlKa3VU2VmZssUK5EQsgUnCnTKSOK3/8ghDPDhxuRuCze01hxy4Ch4K9Ah Uppmmwso+7QPUmwlNBLcQ0nSwjVD1psepWddGvGop1tu2Tzkwex5nOuuei4waXlIcG0Gl EMjquQuCKpjU5Oj8w7xbPcNJjcQs1QLjhW3dE+pb2wsf0Eh8k/WJH4kLosITfm6Rerg7X 6EKSYteFQvHdANlnpslxJXlrZCxTDWIIsjCT9dkcky8PaLD6WwEapD+r9AF8dJxXw/w== 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=20260707 header.b=XmKwBUdk; 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 8B874606A327 for ; Sun, 1 Nov 2026 07:21:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8B874606A327 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=20260707 header.b=XmKwBUdk Received: by mail-dy1-f171.google.com with SMTP id 5a478bee46e88-36a0f27c9f4so3676465eec.1 for ; Sun, 01 Nov 2026 00:21:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793517666; x=1794122466; 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=bk08wlQLOckMDa/tQlUY0Gs+7pq28CqTbcZ5/8r0npg=; b=XmKwBUdkbo8n9UzBtWyscJEB661MdVSyToO1VY2IJ+fcRKBXlMOgyL694On1b5oKlP Zn35uz30DglljsbJ7DcucazifGT8O5h7JPuhBs0McAyt1wQsFINYYfPoU2pgaA33L90b qNsB0XrFVPGy7gJXG8Bj8W/c4NokcZeDHViQpa17bKXTWDBKCsWL0X7BsRYDcXIznASZ AbvZ19glirB5wwSaSbDdGW20yDxzmw7QiBdb7K1LH76DrkEvFTjsDKRAnbWpmd8jSMqH jBh4nST4/eUmsRIzKiB9Qh8s89bVrVJQWWmW6vD5kBMElym91abRmxs4uQbWfTMuVllR jLCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793517666; x=1794122466; 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=bk08wlQLOckMDa/tQlUY0Gs+7pq28CqTbcZ5/8r0npg=; b=hYltb5wmDp9SollT03R85ww1vPKDbMpVOnNHo+czUFJAz2AE0Vb4Om7TFNlSMLL9JC dv/ycnIJaYqtosSCFM1Cc0V5EHNumHGi3adeAA7/96jZ0z2tWdPA43VR4hOhp7mauyeq hJyhQheJBtJgyIUn5PYalLq9PnpXBQuW/T1u83+PD2yFLLhrDVKyPp16bMZwvg/HWNZ6 YQYNsNPr9XKPkwv4f7QQb+grT0lqaT0hiMLz12pLBNnP/xY4V+vzrWWMZwTpoxEFZk1I kmF8TjEQx3XVjBsuoJTAwYsUoTzoWdnT6Ctt5txcyfOjzfEMx34gyBXiFc+UDHmPkc+7 rf4Q== X-Gm-Message-State: AFq9FYKL+Tj+G/vp6fsRiwmY6JZpm8XZyUdsp3BvBDmHE8EinOX4sG0C SiY2Swq95mBk6AcvLNjXkX6g/EzVjtL+2X2DBjXJHGpSeInXZbOcnpW2TsPgaA== X-Gm-Gg: AYBFou2xN4eLlchbdvZMkEaLD1YQhqoGaMv/AuMSOirNeCzVa+UjR9QZQKcc2QU3ArU /zWpzYJO+/kDbKheS6SxLrJGO178no0bUfHOM09eYQZJiujs3/C2zU5DW43R4SQ+NdLgcfoL6Bn Q3Z9pNa33fZmF/O3vedXYdU0LfF+IrO4FBmvHURucz9Or3sAK9JUM3QfZrsVtG31zEWFWzGukFs xgvI49wlimEChurb56izuLyPJWaHInORdy+EW/P7t7plNQ/7/AqCnjG2VvKw9jnNVpYj/Ckerb9 DaPoS5MY27MHkmAlrzWlo1imd/WZZeKeRu3puAbmLako/K7hSQCApIG9Eo5OAlwFIQBl6/VFYII izBEK0TnPCFZg3626sRNE3WVzVghVWz0FafxzzHBHkEl9coh5uE8ODjSd3EALuq6DHR6zA3/hKD LiDomdRwowRlrrlsF7j9Hf/evWgL/sSfsGXAObz32hMJG75FrI3uFYAU3hVXLLzIlhhRCCbwL2X iuWRzYjzsNG0Ce5MAMOoyfuR0qGPJii8+w05IaUtLUYtxvTIRcNAngiUTWsqdiFjOEQdQjjLkBK Kj9tyEg2nNN2NU+R01lERcqaTQ6hJ9eFHh//8Xp5HrTlgvIjpEG0LTwVhnjGkUurEz43lOssYG1 CPkMHzox1WYIgpgD/7zLNb/FgS3wHZY+n+JzJQEmZrB/UZVX8kpcqoX/k1m5gx4mA2L0v1wYP6w == X-Received: by 2002:a05:7022:ea46:20b0:144:c128:4c4d with SMTP id a92af1059eb24-1ac5da76f4cmr10792716c88.38.1793517665495; Sun, 01 Nov 2026 00:21: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 a92af1059eb24-1ac1854da78sm29851495c88.6.2026.11.01.00.21.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2026 00:21:05 -0700 (PDT) From: Anil Kaushik To: mptcp@lists.linux.dev Cc: Anil Kaushik Subject: [PATCH mptcp-next v14 5/6] selftests: mptcp: pm_nl_ctl: support the subflow-retries limit Date: Sun, 1 Nov 2026 07:20:50 +0000 Message-Id: <20261101072051.3853492-6-anilkaushikwireless@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261101072051.3853492-1-anilkaushikwireless@gmail.com> References: <20261101072051.3853492-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, that it can be set, and that it is kept when only the other limits are 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: v13: - get_limits_nb only reads the two limits set_limits restores v12: - check the limit is kept when only the other limits are set (netdev Sashiko) 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 | 55 ++++++++++++++++++- tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 34 +++++++++--- 2 files changed, 79 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testin= g/selftests/net/mptcp/pm_netlink.sh index 21bfe1311f11..80e100d105a2 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 @@ -71,7 +76,23 @@ get_limits_nb() { ip -n "${ns1}" mptcp limits | awk '{ print $2" "$4 }' else ip netns exec "${ns1}" ./pm_nl_ctl limits | \ - awk '{ printf "%s ", $2 }' + awk 'NR <=3D 2 { printf "%s ", $2 }' + fi +} + +# 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 } =20 @@ -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,33 @@ 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 given: unchanged + set_limits ${max_limits} ${max_limits} + check "get_limits" "$(format_limits ${max_limits} ${max_limits} 0)" \ + "subflow retries kept" + + # 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:29:03 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.179 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793517669; b=r+Xq2fpIWFLz1Uz/Wg+mKMdGGvRmXzAzOwrhnm3lEl7M2BQrqMmTlulcEc3rXJ2td7bX KYxpk12zzhxQWvsEbAWCR9wqb2CyD21ElQVqadLxU9vp0RGZgtUbp2+siZtuon6yJ1Z4T Ur/9J/Uk4m9Syyy1O3OhNUOnHuDThI2kr9tpRDftBA9hh2XsMUNki3VtpeS8T9gmCkT74 FcWGYrpXEBfPK/zF7FmRS64tKu44ardysmmqCXPMga0xNWFctqfJwAFP0Qcood4W5f9La UqicErcrTgE6MQZWdprSQX2QUdMcp516uvh0bAf8TKtA6Ka/beoOKHu3QvA6ZTX+Enw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793517669; 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=vgJuZ5+WTimnOJr1ILDbkJrgX2lQ/uIBZDP16hESEoM=; b=Y6JUwGNI0Hy3PXI4e0gh91YKXZ+KAw77+J+Bg0hRkVWSJq2L7TOjufCoNGKkDMpJWikv UYmOX0GmZmQWcSVwLehcl5BuB26iL7NKU9EpZljNHxUgdjzx6YJB2073GypuABriMYOwY 3FNy6fbSfUe0p8BTIIA72YDGk5+ZtJpM0biKs26yLGmIvYEC46+BEcbtwXbxAPoEk8AQl d+wc5ymYANPnE05MwA8HjNLC3ymLhG5GNHxfsS48ERYHerPGmda4lNOM8VBLkbztNk0zO aoHbn9lKyryXAFMIYI0/BEpF8ZDyVYyJkXGOjl/sjX6sG8w2JaP8Q8ei6Qlv0FMbYGg== 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=20260707 header.b=DS7bmXpT; arc=none smtp.remote-ip=74.125.82.179 Received: from mail-dy1-f179.google.com (mail-dy1-f179.google.com [74.125.82.179]) (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 DC6F6606A32D for ; Sun, 1 Nov 2026 07:21:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DC6F6606A32D 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=20260707 header.b=DS7bmXpT Received: by mail-dy1-f179.google.com with SMTP id 5a478bee46e88-33bf40b0c8bso421121eec.0 for ; Sun, 01 Nov 2026 00:21:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793517668; x=1794122468; 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=vgJuZ5+WTimnOJr1ILDbkJrgX2lQ/uIBZDP16hESEoM=; b=DS7bmXpTt+XEnFIHXnilGmQaTyxlLa7PyG0j9TQ1De10Z21dut1OjTDKbwVZTXpLUS NwISJLgkKmjU//nZ4w2GYLbwe2EXMQg7RWC8js1RZBFbP8I3QZkuj3uh2B5+3lHmi7tX 4KdOXL/4HcBnqScEhYfJ2iwHZ1kbveV1mKNLfLBphXpfHdlUtK1TqONatF82Z4qp+2S8 fnIOx73B+JPEosijUab1HdAxzGrgA21fccY/+nGMtkRUKI9rTI9lJsekO4mhGJcc1S6h 6dtdz+1+rPcBEuCzPoLeYmfCkK7XH/aONSrahLBhPmshSpy0ph90zAlR8ocIQL/yIs8o ND7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793517668; x=1794122468; 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=vgJuZ5+WTimnOJr1ILDbkJrgX2lQ/uIBZDP16hESEoM=; b=hI7im36oxR9wl9/U6w5uXcPJErfF0TAR42s8qzTo2IOXbY+Yb3775h6irjwq4Z4N+A ThJkzvyLQvNIPtGSNhgPxOV26qudovVFHlJ2YtC8iT7ClLCm9Yl3//yi3Q2tzNEAuuZv 6KIqsqe11rLPt3kB84wL4cAfDxpL/2VQb/hxbctDlTiLm5XdW+xkGiR2T9EqOOYNHyQP nOX5v0UMfqA1lYnOtMsbuh6Qh16FXbeuFrirIPGLBsvlz+unTd2DBDpSNdJgMVy4XLuF sIumDleP8SYRPcX/CULIKrgUclVxlrut/0APThxEvWpS5YwuM1FzccbPFT5/jkCxol8D f/iA== X-Gm-Message-State: AFq9FYI4lvb3IRjhtPLvzBiJKJmu0b+g4uH2GxLhnv+V+nPU2arCgqOX c4e8EVww9Db1mLyk6iYerkvhuB4vdwLVpKIlIjOR/kkaEVg1bj6r+1xHEyQsRA== X-Gm-Gg: AYBFou3Sy/3L150+tqPocQkxTCde0khxdWJjim/5+TedI5YzDjxIKWS7wpCbO7dDOK/ YzoAdKsPYfm/DSVBSrrOAAvgjOGzI9u7H/9PZjIYYRqHSKKrJI/LpFg6E/50RKQVluBzjaXN072 vN5y//7qXPiFPqjcg1C9ndSDESSmpN5DzuuiSWRS7In8gPQd6STWz9PQ3XzkDz2ZVfSyOKfamcd 4ojDdRlc0fHQQs4DtYRN3JajlVB7Qj6vatYzv5ShpC9evcpRWqRSIv9272c2NnpT4iCO6poowvp 7zZoI0XmEwHh7wLeWPNW6BBBUncvJz8ZWlFum+K6X5s8eG3GG1cEaFLZVDEjCllncXk0JOTQo6U szlrQl7X1cWDuulOqRXSXvBGBDdxidwmVr1dEbbTNlzItFSfPiWyhA6alXlUADS85b+8Ri1ESwl XIy5D1PdB3nWtXesYa78hKalSnP7iNm/HdNEZYUzRVUHDkR+AmxqhCbEqu1/r95ORn02qq+uLMg 5rglSntDck8Jl5ffRPwRf8VfFUWv5lUU/zZI6U5in6rb+ihMV3tQ7+xZqSgMvsQAX/AFH0OULsC rt839xvoaKrmsnEjD/nTqpAe5Av8BqITCrPT7fg5VFwlUA85QWucNceOUtQsxkJDr+NPJ5ALqAC QFOqtOWk4gTg4DJHqhaaUVeQ4KVb3fR5XRCXdeggXZmLA6vicy5mo7+h2bC0F+7ctnJCJb1qW7w == X-Received: by 2002:a05:7022:f409:b0:143:26eb:18e9 with SMTP id a92af1059eb24-1ac5d5aae14mr12836923c88.28.1793517667437; Sun, 01 Nov 2026 00:21:07 -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 a92af1059eb24-1ac1854da78sm29851495c88.6.2026.11.01.00.21.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2026 00:21:07 -0700 (PDT) From: Anil Kaushik To: mptcp@lists.linux.dev Cc: Anil Kaushik Subject: [PATCH mptcp-next v14 6/6] selftests: mptcp: join: validate subflow retry after link failure Date: Sun, 1 Nov 2026 07:20:51 +0000 Message-Id: <20261101072051.3853492-7-anilkaushikwireless@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20261101072051.3853492-1-anilkaushikwireless@gmail.com> References: <20261101072051.3853492-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 checks the only subflow is not re-created: there is no other subflow to send data. A fourth test removes the address of the additional subflow while its packets are dropped: the subflow times out, the new one cannot be created, bind() fails, and the PM uses the next endpoint instead. 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: v14: - new test: the subflow cannot be re-created, the next endpoint is used instead - check the join counters before killing the transfer, which can send MP_RST, counted with -C (netdev Sashiko) - tcp_retries2 is only lowered while a path is blocked in the first test, so the other path cannot time out on losses v13: - wait for the SUB_CLOSED event before stopping the listener (netdev Sashiko on v12) - the first test stops if no additional subflow got established, the third one waits for the SUB_CLOSED event, and say why the tcp_wmem min value is above the max v12: - wait for the client side of a re-created subflow to be fully established before going on: the close would close it too otherwise (netdev Sashiko) - the third test only checks the subflow is not re-created, say only that (netdev Sashiko) v11: - the third test checks the only subflow is not re-created, and the path-back test is gone: a subflow is only re-created while another one can send data - the close test keeps the initial subflow while checking: without the fix, it would no longer pass when the initial subflow closes after a few retransmissions; a SUB_CLOSED event for the re-created subflow 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 | 407 +++++++++++++++++- 1 file changed, 399 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..b95a96f975cd 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,208 @@ 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 }' +} + +# the client got the 4th ACK of the MP_JOIN +sf_fully_established() +{ + ip netns exec $ns2 ss -tniH state established src "${1}" | + grep -q "tcp-ulp-mptcp flags:[A-Za-z]*e" +} + +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") + # a short timeout only while the path is blocked: the other one must + # not time out on losses + ip netns exec $ns2 sysctl -q net.ipv4.tcp_retries2=3D3 + 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 + ip netns exec $ns2 sysctl -q net.ipv4.tcp_retries2=3D15 + # 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 + + # before a close, which would close it too if not fully established + if ! slowwait "${timeout_poll}" sf_fully_established "${1}"; then + fail_test "no fully 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 . +} + +# 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 + + # link 4: the next endpoint of the "creation error" test + for i in 1 3 4; 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 +2797,185 @@ 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 + if wait_counter_ge $((timeout_poll * 4)) \ + $ns1 "MPTcpExtMPJoinAckRx" 1; then + sf_retry_after_block 10.0.3.2 + sf_retry_after_block 10.0.1.2 + else + print_check "additional subflow" + fail_test "no additional subflow before the blocks" + fi + # before the kill, which can send MP_RST (checked with -C) + join_syn_tx=3D3 chk_join_nr 3 3 3 + mptcp_lib_kill_group_wait $tests_pid + kill_events_pids + + 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. The min value is above the max on + # purpose: __mptcp_sync_sndbuf() adds it to the subflow ones. + 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. The initial subflow is no longer closed after a + # few retransmissions: that would close it too. + ip netns exec $ns2 sysctl -q net.ipv4.tcp_retries2=3D15 + 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) + # before the kill, which can send MP_RST (checked with -C) + join_syn_tx=3D2 chk_join_nr 1 1 1 + kill_client + chk_no_sf_connecting "${not_ready}" "${fc_before}" + mptcp_lib_kill_group_wait $tests_pid + # the listener could be stopped before it got the last event + wait_event ns2 MPTCP_LIB_EVENT_SUB_CLOSED 2 + kill_events_pids + + chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_ESTABLISHED 1 + # the re-created subflow, closed with the MPTCP socket + chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_CLOSED 2 error 1 + sf_retry_cleanup + fi + + # the only subflow is not re-created + 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 + { 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 "not re-created" + 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" + elif ! wait_counter_ge "${timeout_poll}" \ + $ns2 "TcpExtTCPAbortOnTimeout" 1; then + fail_test "subflow not closed" + else + # the worker decides right after it reports the close + wait_event ns2 MPTCP_LIB_EVENT_SUB_CLOSED 1 + sleep 1 + local syn_tx + syn_tx=3D$(mptcp_lib_get_counter $ns2 \ + "MPTcpExtMPJoinSynTx") + if [ "${syn_tx}" !=3D 0 ]; then + fail_test "subflow re-created" + else + print_ok + fi + fi + # before the kill, which can send MP_RST (checked with -C) + join_syn_tx=3D0 chk_join_nr 0 0 0 + mptcp_lib_kill_group_wait $tests_pid + kill_events_pids + + chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_CLOSED 1 error 1 + sf_retry_cleanup + fi + + # the subflow cannot be re-created: the next endpoint takes its place + if reset_with_events "subflow retry, creation error" && + continue_if has_subflow_retries && init_nft_filter; then + sf_retry_init + pm_nl_set_limits $ns2 0 1 + pm_nl_add_endpoint $ns2 10.0.4.2 dev ns2eth4 flags subflow + ip netns exec $ns2 sysctl -q net.ipv4.tcp_retries2=3D15 + { 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 "next endpoint used" + if ! wait_counter_ge $((timeout_poll * 4)) \ + $ns1 "MPTcpExtMPJoinAckRx" 1; then + fail_test "no additional subflow before the block" + elif [ -z "$(sf_from 10.0.3.2)" ]; then + fail_test "no subflow from 10.0.3.2 before the block" + else + # The subflow times out, then the new one cannot be + # created: its address is gone, bind() fails. + ip netns exec $ns2 sysctl -q net.ipv4.tcp_retries2=3D3 + if ! nft_drop_from 10.0.3.2; then + fail_test "unable to drop the packets" + elif ! ip -n $ns2 addr del 10.0.3.2/24 dev ns2eth3; then + fail_test "unable to remove 10.0.3.2" + elif ! wait_counter_ge "${timeout_poll}" $ns2 \ + "MPTcpExtMPJoinSynTxBindErr" 1; then + fail_test "subflow from 10.0.3.2 not re-created" + elif ! wait_counter_ge "${timeout_poll}" $ns1 \ + "MPTcpExtMPJoinAckRx" 2; then + fail_test "next endpoint not used" + elif ! slowwait "${timeout_poll}" \ + sf_fully_established 10.0.4.2; then + fail_test "10.0.4.2 not fully established" + else + print_ok + fi + ip netns exec $ns2 sysctl -q net.ipv4.tcp_retries2=3D15 + fi + # before the kill, which can send MP_RST (checked with -C) + join_syn_tx=3D2 join_bind_err=3D1 chk_join_nr 2 2 2 + mptcp_lib_kill_group_wait $tests_pid + kill_events_pids + + chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_ESTABLISHED 2 + 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