From patchwork Fri Nov 25 22:29:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 26150 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4325599wrr; Fri, 25 Nov 2022 14:31:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf50kFbQDOxCPPHOBawjsGtkIv2FF2Wz9UbJTfHX8o+exnisKVGwDsgI+fXWv+LO1/Hy+9Vn X-Received: by 2002:a63:4087:0:b0:477:15c8:ff67 with SMTP id n129-20020a634087000000b0047715c8ff67mr20766404pga.275.1669415493327; Fri, 25 Nov 2022 14:31:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669415493; cv=none; d=google.com; s=arc-20160816; b=iyvRRehb7omzYjJXVwwNNVVOAvdYFMk8riC7ae+vvDMD6SuXZK3wMq42jjl1jPVvp/ UalNy8XjRwhLlCxUDb62RHyd5gBIgRMUNf0sULX+JuzoWSy82d4xvCJ9SJ6yGK61foLV QpT0IGSzsp9hRj1KNRFk67NsMXiR50hYkCRyt3v68QS5hlSQlWpWXpO2xLkYJ6lOrJ7f cRtgQN3I87akhRy9HXNz3381AbIIWZkynY19J+nAWgTPkC2KPZdQAPDr+mUlRw6Cq4/b x5Mra957P/jxm84+GbHF7OOlQGTuKP6bJNRQn9XjJ9PHtHK7JXJOA3tU89rJxncEic6/ lXhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gBCA9x7cMHFPqIe5fGwepfqiKMVw0+m7IHknfbCdlF0=; b=CWl1ClHyFqpelt1pdhbOSCi7gUVKEZTYTIZ8KhZWULg3H2rWRbaLjsiQi85guPz0ma 6XLLPxwRamPCrff0YSRaqAEuwtfhO9/+jACQW0gkg1uEL797JZMWr44OaKuavaiRLQX+ 4I45dJqfMS5/lplag5UIKVRyC89dgTpGq6kvEDn20WM0F1tU7A3EbmquTLJHzTbJNPHm +2bRXJFQcS0bLMRgaqYrTFcj9DnzIoGn4+9ivLirrjAgPt/r8oNu7jfUEamu4Opzse/E SQeMMHFyhlKpZUQxmH4wWGYJ3pulJRMIp6LsuT4qj82s6PlwptX0SRyls5nzf1xW7+18 Wgtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=c4GJegnF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tessares.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q140-20020a632a92000000b00476e98ca7d5si5827579pgq.785.2022.11.25.14.31.20; Fri, 25 Nov 2022 14:31:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=c4GJegnF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229868AbiKYWa1 (ORCPT + 99 others); Fri, 25 Nov 2022 17:30:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229796AbiKYWaX (ORCPT ); Fri, 25 Nov 2022 17:30:23 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15BEE2EF2E for ; Fri, 25 Nov 2022 14:30:22 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id ud5so13074244ejc.4 for ; Fri, 25 Nov 2022 14:30:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; 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; bh=gBCA9x7cMHFPqIe5fGwepfqiKMVw0+m7IHknfbCdlF0=; b=c4GJegnFhscWlswG9LjL8CSsHpMrKyPlAnk/rkgzodpxvraVmNjjszAdKN3CsoeQP5 cuaWCe1O1vAcNBFyy19bPjx3pU5U7w+es/uQ2+o5o3UY1Fqo3+hMjcG40nS6Zv39REoj g7LLy7n4V5IwL6+fv4UhFuvMlxcyVo7zfFrFQeyGYueuURdJnVG7hOextaFaZUm06L4i hKUkezauVV7SdAy89wIun4w3MnhHqYu8hp23UiAicyvkaYthXTN5feji+m8IBF5VJuUW jNyFdHIQ+gTI6eG8GKPqT4AfdrQTqiipuBvQlTLcvHYoJYc4IIbjiJFWJ7h+qIO8EYGV ALVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gBCA9x7cMHFPqIe5fGwepfqiKMVw0+m7IHknfbCdlF0=; b=FBroz44qLzNcts6tDO6wZN6BYewCl92N9uPa2NMSDW6eu6giKjhMw2nozy+Sfpq7U0 Us5eAkXpwLRhLs8WiSzLY/jrp6BiHy9/ddmzoh9+8rfCjHyd0OL+f6gYestIxEc2ifZV rMDURZcOA9c3asZlBs4DaaxnVF5mXYfaKNp4jEz19BFq4+9+LQiFLX/cBfvKR/GcP6/3 8o37Ix7amk0WJk57pQMwsDo6Ejb64fAjIeZFsQBQTEqVTA3o4oHk0x6s3Rj1sI+3LYgT ed9dobsN1OQwJ/I8lHKBprLX/6EWK368x1WgXTpi/csDKf76KrHqfZYqUlVfTlaW0deS DWIA== X-Gm-Message-State: ANoB5pnaZOFQQyw31Y497EDZrDmrBkJ6V5qKofmM9ag6FcBPY4C1n62u chVIlA729RAa5Ec7bfou3xxYoA== X-Received: by 2002:a17:906:5293:b0:7b9:631c:451a with SMTP id c19-20020a170906529300b007b9631c451amr14565134ejm.283.1669415420533; Fri, 25 Nov 2022 14:30:20 -0800 (PST) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id q1-20020a056402248100b0046267f8150csm2254612eda.19.2022.11.25.14.30.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Nov 2022 14:30:20 -0800 (PST) From: Matthieu Baerts To: Mat Martineau , Matthieu Baerts , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Dmytro Shytyi , Benjamin Hesmans , netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/8] mptcp: add MSG_FASTOPEN sendmsg flag support Date: Fri, 25 Nov 2022 23:29:47 +0100 Message-Id: <20221125222958.958636-2-matthieu.baerts@tessares.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221125222958.958636-1-matthieu.baerts@tessares.net> References: <20221125222958.958636-1-matthieu.baerts@tessares.net> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1505; i=matthieu.baerts@tessares.net; h=from:subject; bh=A6FMBCW63WCmAXAOc+ddPtBLco+9STQpRswEd8AeUr0=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBjgUHPa4vNEORZStSCr2EV2UfU8z3wnaTzRh2RWb3b PqdgihGJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY4FBzwAKCRD2t4JPQmmgc8BrD/ wM8u7SAV3orCOwAotH2p43JebnN3OvywrxZXGzPSe3U7xONwt+YTQTVeZrg/gsPdcGGFPGLkgCUljz adJbw8b35ljOseooC0t9ep5Z4UdfnXi27QUde7uu+0BlfdfrIVEavcr/cCk1kiI4MaE8GIXTjV+Q7J SgaE0nnHuLMhHe20uZfcTQLSKOR83V9DAgkmYBPefWfeADEoKJWhdcjgLDAyWcz0+YN00sA72G6OmG m0/59Cvy+0U9lRKlMRefLQweAqKnsyLfmfl8g/+RIHtWn96rijUlIPcK53w8taPmjj7/6TIXYlQFHM jlrD16pqbrDdwqVanTAf85KGSZTAEmHuI7ifJ7755jiMF1HjfHclVxP7AoRuVP1S4oodO9wGW2aOPh +VHUGVKA4Pn/UGnqVzRi0OvqV9bN/uPAwJ5Bn7XaHRvXN8/GURbDZ+Mw9jda+JN5m34dLkf3KEbFdV /vvmKmQKKM2IW819kcfVxcA1LVUlPpf+dXM4MK1KNmFBBCUKgyxHKNSVOIol+uRifFSSWH4k4i+aln KEjV8d8UDY/nz1K94TJdh1E2XRlCIUyqs7i6SSvCdU4WaXixerANvP2+PPB4SAdGcWTL5MTNqXpICa wC8ASt63uAC2Rl8FYcwgEQqqxUbU96dBEjOhz3dX6IO8bTT0X1322A7Ft2Mw== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750509020223227692?= X-GMAIL-MSGID: =?utf-8?q?1750509020223227692?= From: Dmytro Shytyi Since commit 54f1944ed6d2 ("mptcp: factor out mptcp_connect()"), all the infrastructure is now in place to support the MSG_FASTOPEN flag, we just need to call into the fastopen path in mptcp_sendmsg(). Co-developed-by: Benjamin Hesmans Signed-off-by: Benjamin Hesmans Acked-by: Paolo Abeni Signed-off-by: Dmytro Shytyi Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 3796d1bfef6b..37876e06d4c4 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1711,17 +1711,14 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) int ret = 0; long timeo; - /* we don't support FASTOPEN yet */ - if (msg->msg_flags & MSG_FASTOPEN) - return -EOPNOTSUPP; - /* silently ignore everything else */ - msg->msg_flags &= MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL; + msg->msg_flags &= MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | MSG_FASTOPEN; lock_sock(sk); ssock = __mptcp_nmpc_socket(msk); - if (unlikely(ssock && inet_sk(ssock->sk)->defer_connect)) { + if (unlikely(ssock && (inet_sk(ssock->sk)->defer_connect || + msg->msg_flags & MSG_FASTOPEN))) { int copied_syn = 0; ret = mptcp_sendmsg_fastopen(sk, ssock->sk, msg, len, &copied_syn); From patchwork Fri Nov 25 22:29:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 26151 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4325627wrr; Fri, 25 Nov 2022 14:31:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf4EkHBckCd5rZnqtM7aZfMFTgbB66riTr2byLCm49pw+97hXX4K4oZHkzKr06HvV4HyzaPN X-Received: by 2002:a17:902:9686:b0:189:24b3:c54 with SMTP id n6-20020a170902968600b0018924b30c54mr20960832plp.96.1669415497669; Fri, 25 Nov 2022 14:31:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669415497; cv=none; d=google.com; s=arc-20160816; b=cfakt69vIcZ7RHQ7wMq55X6ObI67pSAMQVP6CL+18jrJWkfjpXjK5uQaprfbxvNwRM WuilJVzoXjeLbHp7hK3WKwb095mCPpmFmFCxk0S/wDMj+qTXhNiFgHsGt6VaCjRVQ/hh yXPD7jpmEu5LLH6idS/ahVbwOAurOzdCcBBEhJBcFQBFkV+WxunzSwSze1LQnQHFP/fs EA69+304Z1d519YvgEuc1SAONI9jPD8XiaHtwNCL6oQxGAtYHIW/xrW1NOvlA8YYdBnC sVFsTyZNFAI5lER7qqAyXEJRG9pdFBKrZyoAl0CS59ce8svh4/e0UP4gtdnut2RkuhaQ o10g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=smKymeBBa7IBeUrFR8EANYkCpmEzimtdY237ZPCzBos=; b=nrPcZxBItnLfc1u+MNS6NJpaZ4zU5Q0cCn+P9hI66C5Ipbu5MuarXgV8htw/LQmWYt GhTdiKcI4jR++xyWwug7sHexhNnXIKIiXV+17fZNl8TpJsZQE4DAAwwPTEU7nLoh1aJ3 pGqvdvdNyyKoU3FXUGMb8apdFy4qfNvJ5LJndllq1lvtBt5V+ja3OVvbu5wo6l8zWPR+ +e137xjljRb7jW9aRuOB/pC4WsqVOm0c5N21G0bKAqAW+WlsMDQ4uM2OTizucFIw0gpu 9qpfePGZeWSp48z0nFTSBl9eD9pekX+pPJ8rXQKF5rz/60nmVJW8YodwL94q7Zw3GAjn wEhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=cJYbFoQd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tessares.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bw22-20020a056a00409600b0056c882d3d06si4959642pfb.199.2022.11.25.14.31.24; Fri, 25 Nov 2022 14:31:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=cJYbFoQd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229949AbiKYWai (ORCPT + 99 others); Fri, 25 Nov 2022 17:30:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229819AbiKYWaZ (ORCPT ); Fri, 25 Nov 2022 17:30:25 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DAF02EF3E for ; Fri, 25 Nov 2022 14:30:23 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id i10so13049405ejg.6 for ; Fri, 25 Nov 2022 14:30:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; 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; bh=smKymeBBa7IBeUrFR8EANYkCpmEzimtdY237ZPCzBos=; b=cJYbFoQdv55knTfHLQrHZieq61wqn0EYtegTu+u1gXSgMnsRcvpqsNGxzeuNmu7BZD pDoXmiXDEIbrjMMLpxGAl7x59J+mNCaBv3Xw7nmOw2cQiTzYCeGJ5QgYNsA6EcS5e2LL SdVMKBZWbRG6T5IfofnhK3dE+7zDTleSdE8oba4kledHZdgkYr5JFT6gVK/xX9FaCNZg gQEvk/IAe1Dvsq3CPPlUJaRxaipenGrMpxS1d2jdINi3UF2IsfITkM2FHlxwf2Ho/kQD Jj+CANmOEQUy+lNKCtXOuRXLfRxrgbD3jv2iEPAbrujN2uLG3y/rj296IjHjJGXNgCbT mRbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=smKymeBBa7IBeUrFR8EANYkCpmEzimtdY237ZPCzBos=; b=1f8Dc0hDF+wJX2z6fMH4lC562SAA5qJKr14yAsjdQrNmfLorU5B8zj1Lqgoipdv85I AmLl2mekpTPSrWyoG5RLMAtQmMJT0ira7O7wHMKEREC7jzNWdFPvRjzJshsMJLs/Q8h0 m+Ki9PQzrBby8jogdGUsHymJKdv3q58SRPKab+pP3zLVYSF0OAo/CdmZCZZ+BZjsGqMm Bb4fxL6WHyog/fcHW8ytzocoobkgXGDy8uRc1nuCff23MTEJNTfOLMPtU3EfqkIMl6jX AN5EbVxUQd/RJjMvQDe9c8TmmdW+HuyhPFFzwB5iVNqhMeD8iNYcVwBEzPDgVA9P0H/u HdpA== X-Gm-Message-State: ANoB5pmexHH7u1klLDAW8maa/cpRzDdgH7Paz1/tzmI/FPByWOl4igLw 9qWWGZJ/vBom8TQ0/bY05GxSKA== X-Received: by 2002:a17:906:660e:b0:78d:b43c:81be with SMTP id b14-20020a170906660e00b0078db43c81bemr24506505ejp.600.1669415421794; Fri, 25 Nov 2022 14:30:21 -0800 (PST) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id q1-20020a056402248100b0046267f8150csm2254612eda.19.2022.11.25.14.30.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Nov 2022 14:30:21 -0800 (PST) From: Matthieu Baerts To: Mat Martineau , Matthieu Baerts , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/8] mptcp: track accurately the incoming MPC suboption type Date: Fri, 25 Nov 2022 23:29:48 +0100 Message-Id: <20221125222958.958636-3-matthieu.baerts@tessares.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221125222958.958636-1-matthieu.baerts@tessares.net> References: <20221125222958.958636-1-matthieu.baerts@tessares.net> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1843; i=matthieu.baerts@tessares.net; h=from:subject; bh=J6Pasy5rywxbTiBcJF5r2K+UumRyCmzkUNlg31Z58ec=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBjgUHP5Alj7g+lojdWNJTyMzRKAHbHZihRsnaAGFAQ ghjyeE+JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY4FBzwAKCRD2t4JPQmmgc/RqD/ oDcgBqCUCwGoAi1hXNdqvmfSR1QREb7BGwoVgLgzzTivGWiXmi1+0R0+OE+dQjTpVDm3OTlOK+vTpt xzGX/63VwCA2HPMrVzgn9KfmcLVUnKk7ArkHgJ23f4K0t53YL7VVtiA+G8r00uFkYKabZ9XrWt7z0q sdsGgGwPU45fE9/GSUJ0eBtiXKRe1ergC2S1wiJvJdsuuYApCrbdoKGUqGDmPOOUpHBypcOmM4cuX3 9tsew1nFvKMOH+fj/O+S3N5P6NMT5n7CZ9r/h1KAdGkDsQAMwkhh7bsiLE7OBV+ADuRCWDWUHKVZzp tHWw5+615hOM+qLWxX0IWeLGIZFzS3hQxOeldTTOX02395rhdMUOCexUZ/hPAfEmpLeBBjjPE3X3ZV YbwL5tV7ahrthy7uaC/s76Qxamk7Ra2+KTChdzOtZLDkchjxHzxj3Z7Nui6yO/B9w8tEYmJ/WbyFA0 633oN/YdeLYiiv9jZGCt2E4HKW0a5YY8JppUbi7fdn2K4yYs1XMS9yfqCOU3zMIGzVbpHow6AXx++w kAdsWXv5ZqMC70+uF2+mElkZo2dB1jKewhCDMO6V35cCXFGbQr0P7W7zPwZAXAH+MTIgJKnlrnbHg4 r/CW+lNDCicVF4ioYlF3EoVteIXT3ieon9AIsNcPIKn1QDZUlyV1Iiqa8qPw== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750509024760794654?= X-GMAIL-MSGID: =?utf-8?q?1750509024760794654?= From: Paolo Abeni Currently in the receive path we don't need to discriminate between MPC SYN, MPC SYN-ACK and MPC ACK, but soon the fastopen code will need that info to properly track the fully established status. Track the exact MPC suboption type into the receive opt bitmap. No functional change intended. Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/options.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 30d289044e71..784a205e80da 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -26,6 +26,7 @@ static void mptcp_parse_option(const struct sk_buff *skb, { u8 subtype = *ptr >> 4; int expected_opsize; + u16 subopt; u8 version; u8 flags; u8 i; @@ -38,11 +39,15 @@ static void mptcp_parse_option(const struct sk_buff *skb, expected_opsize = TCPOLEN_MPTCP_MPC_ACK_DATA; else expected_opsize = TCPOLEN_MPTCP_MPC_ACK; + subopt = OPTION_MPTCP_MPC_ACK; } else { - if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_ACK) + if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_ACK) { expected_opsize = TCPOLEN_MPTCP_MPC_SYNACK; - else + subopt = OPTION_MPTCP_MPC_SYNACK; + } else { expected_opsize = TCPOLEN_MPTCP_MPC_SYN; + subopt = OPTION_MPTCP_MPC_SYN; + } } /* Cfr RFC 8684 Section 3.3.0: @@ -85,7 +90,7 @@ static void mptcp_parse_option(const struct sk_buff *skb, mp_opt->deny_join_id0 = !!(flags & MPTCP_CAP_DENY_JOIN_ID0); - mp_opt->suboptions |= OPTIONS_MPTCP_MPC; + mp_opt->suboptions |= subopt; if (opsize >= TCPOLEN_MPTCP_MPC_SYNACK) { mp_opt->sndr_key = get_unaligned_be64(ptr); ptr += 8; From patchwork Fri Nov 25 22:29:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 26152 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4325699wrr; Fri, 25 Nov 2022 14:31:47 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Pqvt+AFW4wzVwcq8ijBoL55a+uoUIjMiBQJ+Ye1i8YITIfRI30Esf+xAlvf+JfRiMzFrC X-Received: by 2002:a17:902:b682:b0:188:f8bd:9589 with SMTP id c2-20020a170902b68200b00188f8bd9589mr24193428pls.91.1669415507126; Fri, 25 Nov 2022 14:31:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669415507; cv=none; d=google.com; s=arc-20160816; b=YbLJF/nN/Myr9ymjyDaPElM8dc0l84Ty8deyATEAuFj+91tdy5B+LLmaj47SEV4SBm 0CM0sRfGSh6k2fEEyjTMXAYS+srwSUyoQ88rBntCdYMxTK346DCs8Qe8kWBReJoiBjVw /1D0YIqOUCmh2ZbPdmHHmWDF0pjZ5Yl+BBvFae7ACRV5jp39E8/NN9rlxfbMLjEB9w2U rIQ42l9VcXe1W2ByeUYE1tHnaDnm/0kVYbSQuOfLE9oGn8wOMRM6o5fGHAQiTITdgo7/ +GGIvWB7+yYDMhfgQzWoMVAjWzREni96nDLn5MHqaFN3PQ48+/7EIFjvpbrket/hbR0d 2jzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=g6lT3FZILfL+dT/ClXXJliaYvhVNzCsNrT4CNSWSYFQ=; b=dCy0YsMyRKbVcNwPU6nYe946ESGm9Jz/cohAuSmqIIeVoGhav+7u0b+myf7YBxlbzI bUeeIxLNiyUmaFJULwR8pLKHeGPwGdjTz6RIQOFftfplSNFluA7/gkZY6vyL4mFCFrsR 3rrPWoR3Ufb0o81LEJrTqgFZxpckawdE+cfw5Fd+v5uAWzn51tkWUkaErCOImYgCiKWA e4lwsmgryvzDC8Px40QL/Cq8lNj7wWSFikq/4ojzDBQbx99lX8Lc4k7MdZz/19pdcR+E hEfBgKGOlrgLj5h4QBq1CsWwAFVYpSXD7F5RtIiBZ4d4qCdZ2UcJmdVfJTL9XrNbV70G ITLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=fVMdLuD2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tessares.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v13-20020a63464d000000b004770fe95989si4841730pgk.496.2022.11.25.14.31.34; Fri, 25 Nov 2022 14:31:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=fVMdLuD2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229991AbiKYWak (ORCPT + 99 others); Fri, 25 Nov 2022 17:30:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229835AbiKYWaZ (ORCPT ); Fri, 25 Nov 2022 17:30:25 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D3582E9E0 for ; Fri, 25 Nov 2022 14:30:24 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id ud5so13074426ejc.4 for ; Fri, 25 Nov 2022 14:30:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; 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; bh=g6lT3FZILfL+dT/ClXXJliaYvhVNzCsNrT4CNSWSYFQ=; b=fVMdLuD2sjzyXcJ5c+yrqCkXZQawn2evU+9L96MlHiUXWiFO9WEGvWRPyOM2X6fFw2 SwCUGLZzN7vTE1wFL0lc8ElabwGGgy8zS+NjcSGyDjj9/H0TM432uhR5Yh82cXUmgtk6 hEES8Ap5FwUTIuEzKyxwNNDYOLI7ATavsr83TcNpVgQLXshOmHZkgNVXe0x2lKPJtL4s mGXEjk7S8PiA1qOFv1geBSfHZAH/HnSXeQOg+bWOmqyBSXJA7T/0R7bsrI6AxhMgPfha jiQ5kcBtiBGUB/gELeR/4st+GxHIZivm+kz5cMUAWu48Ftl9E3zsJRezf9tNDsD3l2C5 I2uQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g6lT3FZILfL+dT/ClXXJliaYvhVNzCsNrT4CNSWSYFQ=; b=dCaPuwce54bRfnOcTgG+in/qUGRRCQw+Fus3pJMirhmlBciPPY4Jy1CUIquFScL2wU 7ky5OrHn53KHmW6OGDRqoIFzI0gGVaOMJGhiISHFNQXycbZq3l9us4egSkMdUJsXBklo +IQv/ZUp+J3LL4K5SS3lzHD2GHPJNGcwaQqbkkw//OiPgw5ozzqAtCfyVdW72miLPPsu AElS9enZyXrQ1pi6mswHcmzhCUOgIA0+Tfr2TWl/TLWc2EpydH027nyP0xit79C/pefD HoY/ibhamTW8jyShulNy8bI/We3sJsuSAPcz3EZn/VV4HpuV5yZ4yNouUeZb2PAshpHs KEqQ== X-Gm-Message-State: ANoB5pnuDW2tD7HrSUZNbofa+IEM52rfCv1ANbfczZe8v1QAm42nshhb 0KSRBVC3IPr2vrzfLG8xDfhhWg== X-Received: by 2002:a17:906:78c:b0:78d:9c18:7307 with SMTP id l12-20020a170906078c00b0078d9c187307mr36585172ejc.23.1669415423722; Fri, 25 Nov 2022 14:30:23 -0800 (PST) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id q1-20020a056402248100b0046267f8150csm2254612eda.19.2022.11.25.14.30.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Nov 2022 14:30:23 -0800 (PST) From: Matthieu Baerts To: Mat Martineau , Matthieu Baerts , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/8] mptcp: consolidate initial ack seq generation Date: Fri, 25 Nov 2022 23:29:49 +0100 Message-Id: <20221125222958.958636-4-matthieu.baerts@tessares.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221125222958.958636-1-matthieu.baerts@tessares.net> References: <20221125222958.958636-1-matthieu.baerts@tessares.net> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=10336; i=matthieu.baerts@tessares.net; h=from:subject; bh=1CGfFv+DlDhoY8aqKvjqlsXYaA49AqsSsU44nEr4dQo=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBjgUHPQZRhYSYkZrfaYBrSFq4PiitStlqTeEbLVyK7 +7nntCqJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY4FBzwAKCRD2t4JPQmmgc7MMEA DD1CjxEOK/YMwS0TwAWfCo0NvdPmTCGMjUjGtzUGqWsyanZUQmL93PCXjfT9f/XUxfkq03Vt0lc3GU KPDxGR9lOAbyYRJpHqC2t2IkGd74Qa3137qZbINy2LwX2ejK7aXicxAl2uYeAd9PUpKxEpN0pHURG/ /AwHs3HfgGhOEvsgAuJ6khYueEoFinzvYiCNpXj+Q4/ekQSqQIUlXOW31q2pccZ6FOtch1z5ERCz4T ziUs96tl3ylkDwTOgMc28A9jYibwvyMwKE1cr8cvACFA8Lzc+6K60zLsqHFpOaLXt4pAF3oqzyRUv7 wE34/boM8PfbBIYtxDnkvRlZbr+zdixGDFmOZc0MXYYpwUD2HI/lizeo3slY1ypjMqw7czXsjDa3sR UZxHlCpuHI4TsRP4VHSiRCm8WLPhAacsF6nFeJ8MbAa4WjDk6W96/xOJWKf5EglAA3pwx2B4Iq088N 1SiPTsk14gw9mGYnMQebW05udnw5TQJ61G8GKBZb5OowfdRF8S1cF5Jv8M3M0nAsUinAEfTujcXUCL Atr25wF6vdj8VnhDISQOyN1rt+zVEAIYQ+DMJ2ASMqmf76D8/Q3XJcrVRBOv0qmhk5qAImpD6AN/YP b/Ww0+qeJRLAEhlmPGUsxmlfGbUfxUD1UJSzScP91mVEiT2CUTtKOSWLgcRw== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750509034830972186?= X-GMAIL-MSGID: =?utf-8?q?1750509034830972186?= From: Paolo Abeni Currently the initial ack sequence is generated on demand whenever it's requested and the remote key is handy. The relevant code is scattered in different places and can lead to multiple, unneeded, crypto operations. This change consolidates the ack sequence generation code in a single helper, storing the sequence number at the subflow level. The above additionally saves a few conditional in fast-path and will simplify the upcoming fast-open implementation. Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/options.c | 5 ++-- net/mptcp/protocol.c | 19 +-------------- net/mptcp/protocol.h | 9 ++++--- net/mptcp/subflow.c | 57 +++++++++++++++++++++++++++----------------- 4 files changed, 45 insertions(+), 45 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 784a205e80da..ae076468fcb9 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -953,8 +953,9 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk, return subflow->mp_capable; } - if (((mp_opt->suboptions & OPTION_MPTCP_DSS) && mp_opt->use_ack) || - ((mp_opt->suboptions & OPTION_MPTCP_ADD_ADDR) && !mp_opt->echo)) { + if (subflow->remote_key_valid && + (((mp_opt->suboptions & OPTION_MPTCP_DSS) && mp_opt->use_ack) || + ((mp_opt->suboptions & OPTION_MPTCP_ADD_ADDR) && !mp_opt->echo))) { /* subflows are fully established as soon as we get any * additional ack, including ADD_ADDR. */ diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 37876e06d4c4..00de7f4fce10 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3046,7 +3046,6 @@ struct sock *mptcp_sk_clone(const struct sock *sk, struct mptcp_subflow_request_sock *subflow_req = mptcp_subflow_rsk(req); struct sock *nsk = sk_clone_lock(sk, GFP_ATOMIC); struct mptcp_sock *msk; - u64 ack_seq; if (!nsk) return NULL; @@ -3072,15 +3071,6 @@ struct sock *mptcp_sk_clone(const struct sock *sk, msk->wnd_end = msk->snd_nxt + req->rsk_rcv_wnd; msk->setsockopt_seq = mptcp_sk(sk)->setsockopt_seq; - if (mp_opt->suboptions & OPTIONS_MPTCP_MPC) { - msk->can_ack = true; - msk->remote_key = mp_opt->sndr_key; - mptcp_crypto_key_sha(msk->remote_key, NULL, &ack_seq); - ack_seq++; - WRITE_ONCE(msk->ack_seq, ack_seq); - atomic64_set(&msk->rcv_wnd_sent, ack_seq); - } - sock_reset_flag(nsk, SOCK_RCU_FREE); /* will be fully established after successful MPC subflow creation */ inet_sk_state_store(nsk, TCP_SYN_RECV); @@ -3353,7 +3343,6 @@ void mptcp_finish_connect(struct sock *ssk) struct mptcp_subflow_context *subflow; struct mptcp_sock *msk; struct sock *sk; - u64 ack_seq; subflow = mptcp_subflow_ctx(ssk); sk = subflow->conn; @@ -3361,22 +3350,16 @@ void mptcp_finish_connect(struct sock *ssk) pr_debug("msk=%p, token=%u", sk, subflow->token); - mptcp_crypto_key_sha(subflow->remote_key, NULL, &ack_seq); - ack_seq++; - subflow->map_seq = ack_seq; + subflow->map_seq = subflow->iasn; subflow->map_subflow_seq = 1; /* the socket is not connected yet, no msk/subflow ops can access/race * accessing the field below */ - WRITE_ONCE(msk->remote_key, subflow->remote_key); WRITE_ONCE(msk->local_key, subflow->local_key); WRITE_ONCE(msk->write_seq, subflow->idsn + 1); WRITE_ONCE(msk->snd_nxt, msk->write_seq); - WRITE_ONCE(msk->ack_seq, ack_seq); - WRITE_ONCE(msk->can_ack, 1); WRITE_ONCE(msk->snd_una, msk->write_seq); - atomic64_set(&msk->rcv_wnd_sent, ack_seq); mptcp_pm_new_connection(msk, ssk, 0); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 6a09ab99a12d..b5abea3d1a9c 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -467,7 +467,7 @@ struct mptcp_subflow_context { send_fastclose : 1, send_infinite_map : 1, rx_eof : 1, - can_ack : 1, /* only after processing the remote a key */ + remote_key_valid : 1, /* received the peer key from */ disposable : 1, /* ctx can be free at ulp release time */ stale : 1, /* unable to snd/rcv data, do not use for xmit */ local_id_valid : 1, /* local_id is correctly initialized */ @@ -477,7 +477,10 @@ struct mptcp_subflow_context { u64 thmac; u32 local_nonce; u32 remote_token; - u8 hmac[MPTCPOPT_HMAC_LEN]; + union { + u8 hmac[MPTCPOPT_HMAC_LEN]; /* MPJ subflow only */ + u64 iasn; /* initial ack sequence number, MPC subflows only */ + }; u8 local_id; u8 remote_id; u8 reset_seen:1; @@ -603,7 +606,7 @@ unsigned int mptcp_stale_loss_cnt(const struct net *net); int mptcp_get_pm_type(const struct net *net); void mptcp_copy_inaddrs(struct sock *msk, const struct sock *ssk); void mptcp_subflow_fully_established(struct mptcp_subflow_context *subflow, - struct mptcp_options_received *mp_opt); + const struct mptcp_options_received *mp_opt); bool __mptcp_retransmit_pending_data(struct sock *sk); void mptcp_check_and_set_pending(struct sock *sk); void __mptcp_push_pending(struct sock *sk, unsigned int flags); diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 437a283ba6ea..470e12ce0950 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -392,11 +392,33 @@ static void mptcp_set_connected(struct sock *sk) mptcp_data_unlock(sk); } +static void subflow_set_remote_key(struct mptcp_sock *msk, + struct mptcp_subflow_context *subflow, + const struct mptcp_options_received *mp_opt) +{ + /* active MPC subflow will reach here multiple times: + * at subflow_finish_connect() time and at 4th ack time + */ + if (subflow->remote_key_valid) + return; + + subflow->remote_key_valid = 1; + subflow->remote_key = mp_opt->sndr_key; + mptcp_crypto_key_sha(subflow->remote_key, NULL, &subflow->iasn); + subflow->iasn++; + + WRITE_ONCE(msk->remote_key, subflow->remote_key); + WRITE_ONCE(msk->ack_seq, subflow->iasn); + WRITE_ONCE(msk->can_ack, true); + atomic64_set(&msk->rcv_wnd_sent, subflow->iasn); +} + static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) { struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); struct mptcp_options_received mp_opt; struct sock *parent = subflow->conn; + struct mptcp_sock *msk; subflow->icsk_af_ops->sk_rx_dst_set(sk, skb); @@ -404,6 +426,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) if (subflow->conn_finished) return; + msk = mptcp_sk(parent); mptcp_propagate_sndbuf(parent, sk); subflow->rel_write_seq = 1; subflow->conn_finished = 1; @@ -416,19 +439,16 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPCAPABLEACTIVEFALLBACK); mptcp_do_fallback(sk); - pr_fallback(mptcp_sk(subflow->conn)); + pr_fallback(msk); goto fallback; } if (mp_opt.suboptions & OPTION_MPTCP_CSUMREQD) - WRITE_ONCE(mptcp_sk(parent)->csum_enabled, true); + WRITE_ONCE(msk->csum_enabled, true); if (mp_opt.deny_join_id0) - WRITE_ONCE(mptcp_sk(parent)->pm.remote_deny_join_id0, true); + WRITE_ONCE(msk->pm.remote_deny_join_id0, true); subflow->mp_capable = 1; - subflow->can_ack = 1; - subflow->remote_key = mp_opt.sndr_key; - pr_debug("subflow=%p, remote_key=%llu", subflow, - subflow->remote_key); + subflow_set_remote_key(msk, subflow, &mp_opt); MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPCAPABLEACTIVEACK); mptcp_finish_connect(sk); mptcp_set_connected(parent); @@ -466,7 +486,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) subflow->mp_join = 1; MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_JOINSYNACKRX); - if (subflow_use_different_dport(mptcp_sk(parent), sk)) { + if (subflow_use_different_dport(msk, sk)) { pr_debug("synack inet_dport=%d %d", ntohs(inet_sk(sk)->inet_dport), ntohs(inet_sk(parent)->inet_dport)); @@ -474,7 +494,7 @@ static void subflow_finish_connect(struct sock *sk, const struct sk_buff *skb) } } else if (mptcp_check_fallback(sk)) { fallback: - mptcp_rcv_space_init(mptcp_sk(parent), sk); + mptcp_rcv_space_init(msk, sk); mptcp_set_connected(parent); } return; @@ -637,13 +657,12 @@ static void subflow_drop_ctx(struct sock *ssk) } void mptcp_subflow_fully_established(struct mptcp_subflow_context *subflow, - struct mptcp_options_received *mp_opt) + const struct mptcp_options_received *mp_opt) { struct mptcp_sock *msk = mptcp_sk(subflow->conn); - subflow->remote_key = mp_opt->sndr_key; + subflow_set_remote_key(msk, subflow, mp_opt); subflow->fully_established = 1; - subflow->can_ack = 1; WRITE_ONCE(msk->fully_established, true); } @@ -1198,16 +1217,8 @@ static bool subflow_check_data_avail(struct sock *ssk) if (WARN_ON_ONCE(!skb)) goto no_data; - /* if msk lacks the remote key, this subflow must provide an - * MP_CAPABLE-based mapping - */ - if (unlikely(!READ_ONCE(msk->can_ack))) { - if (!subflow->mpc_map) - goto fallback; - WRITE_ONCE(msk->remote_key, subflow->remote_key); - WRITE_ONCE(msk->ack_seq, subflow->map_seq); - WRITE_ONCE(msk->can_ack, true); - } + if (unlikely(!READ_ONCE(msk->can_ack))) + goto fallback; old_ack = READ_ONCE(msk->ack_seq); ack_seq = mptcp_subflow_get_mapped_dsn(subflow); @@ -1480,6 +1491,7 @@ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc, mptcp_pm_get_flags_and_ifindex_by_id(msk, local_id, &flags, &ifindex); + subflow->remote_key_valid = 1; subflow->remote_key = msk->remote_key; subflow->local_key = msk->local_key; subflow->token = msk->token; @@ -1873,6 +1885,7 @@ static void subflow_ulp_clone(const struct request_sock *req, new_ctx->ssn_offset = subflow_req->ssn_offset; new_ctx->mp_join = 1; new_ctx->fully_established = 1; + new_ctx->remote_key_valid = 1; new_ctx->backup = subflow_req->backup; new_ctx->remote_id = subflow_req->remote_id; new_ctx->token = subflow_req->token; From patchwork Fri Nov 25 22:29:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 26154 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4325837wrr; Fri, 25 Nov 2022 14:32:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf76PSOL6GtOBfYtuCjRCCsi7EvldYhcyfAM+/8ceVYAFLeo3kt4wRH88izxGB867zUAZM/7 X-Received: by 2002:a17:902:d4c5:b0:189:5e92:d457 with SMTP id o5-20020a170902d4c500b001895e92d457mr7906540plg.166.1669415527346; Fri, 25 Nov 2022 14:32:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669415527; cv=none; d=google.com; s=arc-20160816; b=EWycL+BLG+XtirbXmWFbt6Vq9dP1AO0gL5IHhbpPT17hYm2YwRUinqQSQTHRnzWWfv kIrqoEwO/QQLQmganVTbiX2kHCqaQvPmM+RWth3wJEHh/FCL4Y39+Pyl0GfVFufzi7AS h900hgsyUA2hjiVcgHU+24BPTuqLX0kjOk0ToS9yfWmagbIVF8JCGvo2REQeBOfTx+tf 6hA7by1UDJMjG0H6DlgDr+m+IoUnJmMO/NVYGTPKuJgBWfRTNrrVqtIcULJUTcDuW8ri pu/ilFKF5dsGF10fGnypyWqoBEbHYLiZEBv/+0z1SSEimtKn5NSOEWrH8Z0vZEWzoSmd RNgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3+iaKMj6vM07FzBDqChWLVnPYDyo0Nn9qPkX/3MkG3E=; b=zxqatL0rv76akx+g/SV+CT2YVyEeV0ID7mhpmcNmUzpZGMBWrfSqBYwP6vO7r20Egh 3iXy+zbT1qbuuToKwi4nyK/UFp85jNhtZQDFD1+itr1Tu+P7A5ZvnHZadcxx0Y4ZGJV3 icOiqPauruKTvu0ptQ1A6NdjwET+/NC4MYK0zruW5eU4hm5a5OfSNpndZcUlmb8jdg5L AoehzmC34e/KQHFYR+mi2/XwBOg/Dru0v8BksogbNXnOvhrtNWybZCPO8jet76K2t33l Hbg8YMk6Rnv2kv+Je8Cp8TfINOoatKDhaB2dkvLpAytxox32OT/NtMMIba16ydJuvl0R WyHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=6OgZaR2n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tessares.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 31-20020a63125f000000b004774b5b58cesi3521817pgs.876.2022.11.25.14.31.51; Fri, 25 Nov 2022 14:32:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=6OgZaR2n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230012AbiKYWao (ORCPT + 99 others); Fri, 25 Nov 2022 17:30:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229875AbiKYWah (ORCPT ); Fri, 25 Nov 2022 17:30:37 -0500 Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D11B303DA for ; Fri, 25 Nov 2022 14:30:26 -0800 (PST) Received: by mail-ed1-x52c.google.com with SMTP id e13so8043655edj.7 for ; Fri, 25 Nov 2022 14:30:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; 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; bh=3+iaKMj6vM07FzBDqChWLVnPYDyo0Nn9qPkX/3MkG3E=; b=6OgZaR2nQdc6rEQXwfoAcYKQhdg7Ctyin9pg3pUVi2fxz/fg46y/29DSKmXnC43RY6 LP9LxxRlU/YIhVE1bRT6pZTQGaykUSH3onQrR6AeXDRGYy09+qNbGDzN5PJq8ioQndez fGoOi1zucvr8SwkugTzkQH2Tw/dLOm3t4fIurw9gI/ubbkcE4N6CagOPWNYa/6hAwTuM i7GawJpEG4l+uye6o50ERLfTygP5guTbLWQ0vTLzrZ/6H+LZI/X6KopvjzPeO5/1GhBr jTSgZlPIG7Rrprl3S69/QhN/KfjYeza0ILtxBluWs+lJgQqd7NFSagmid+nM310JkmC5 gvNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3+iaKMj6vM07FzBDqChWLVnPYDyo0Nn9qPkX/3MkG3E=; b=bLyvFHEcYHDjTOLpswXaBAupctgnGDenneFt2o39Glk+cm1Zhfu0+m89/QoZvwbx9V QvJDYi5WojtMBe9O+UcmrwwxSWzSUzRMgsMJLVIJpZrzFfvi7ew5WLGZaebiY6mH3qlN C2uC9pk66IizbCK4Sp7EkFOBt6ShydXnj38SMajRoDQcW49T1W7yGOo/QIjHN3mL/AHL XBLyGaYxLJAuF+hnyAvpcvSFUIAC0RXy+ACLQfHukJoU7NzrQnS3CwEfvlcC4E7mjV/N E/gZ5orSEFbEP4vLxWr1qnncWtCGpEIA0Zg8S70JVm8+YPqunbMVfc0iS/oKw5O1vjze sivA== X-Gm-Message-State: ANoB5pmplQRFFPBP+hvM/OKZqTFaxJrOutJXzNuu2pBCvOk18OtoUuVn 1xBxxumJih4VNL1qUzmyaMgCuw== X-Received: by 2002:aa7:c7c4:0:b0:467:4a80:719b with SMTP id o4-20020aa7c7c4000000b004674a80719bmr20818257eds.174.1669415425720; Fri, 25 Nov 2022 14:30:25 -0800 (PST) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id q1-20020a056402248100b0046267f8150csm2254612eda.19.2022.11.25.14.30.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Nov 2022 14:30:25 -0800 (PST) From: Matthieu Baerts To: Mat Martineau , Matthieu Baerts , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Dmytro Shytyi , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, mptcp@lists.linux.dev Subject: [PATCH net-next 4/8] mptcp: implement delayed seq generation for passive fastopen Date: Fri, 25 Nov 2022 23:29:50 +0100 Message-Id: <20221125222958.958636-5-matthieu.baerts@tessares.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221125222958.958636-1-matthieu.baerts@tessares.net> References: <20221125222958.958636-1-matthieu.baerts@tessares.net> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=7192; i=matthieu.baerts@tessares.net; h=from:subject; bh=LzNK76T2xhDCrjtYhvmmyVzad5gtt3rl6eOeAbZ4HpY=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBjgUHPfkkPLmIR4DfOXhjCycprC2hlqfrj+njIAVPu IT0uQ7OJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY4FBzwAKCRD2t4JPQmmgcz9gD/ 0dgTUCsYbxFNJeyyTZcv7c2uj7NVuPjJJ9R2YGWhkpgAIDRunLfyEKeJ7+3x0fUv6ITA+8UXRJTyP9 toGuj+XeOqk3v6KhcDjP58v42jRN9HdFnjlCPgX+N3zZwfrO4HWs/ix97ajq7GxqgYkyFafwdCxnDp lfMsXHXea7rK3f0/UySE6UdGj6aV0Rr0NgDyVwUF7yMJYeIrjqVVpPN7WE3Id4N9fe13WC3ZPZtfO9 fDfefwfsLocr5Bxhx1oWUnhhs34MyTZPVhHVD2UlOf9xmwWuhf5K3N+iAjR50BHvRBd3nm93MFczUZ IMYxIuqVyTMC1GvNd19RUbsajltR3+B5SpX8LKu46UGRPPPVlRSiNdQj2fCZ4DSWYWiO6APkAKSpnR 4P12Nd6oVx5LI28jgEpRfl1KqKtNLORG/19RaAlpRCXLzNM6r9jm6y0b+yrT+zga0gihOwup1d9ClL ip05Ftw0Tqa0pHXEajObG97+3W5clw5YUl7Hj5615zp2CG78IxuWFn29BTYpu3sOwFEybz6HIUNLWX RALDryaVLMOiCYZ9Nmw/8wplMXRtn5efaZ1aGGkPpvdRTfjOAR0tu2v52/Y5Ceqm1vJR+mwnXZiwmx 66afhU1E0cM4PGgqHoyz/Vwo1TS4ICWDKynqjC9jXE5k5larSEpcPWKkqNCQ== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750509055926063701?= X-GMAIL-MSGID: =?utf-8?q?1750509055926063701?= From: Dmytro Shytyi With fastopen in place, the first subflow socket is created before the MPC handshake completes, and we need to properly initialize the sequence numbers at MPC ACK reception. Co-developed-by: Paolo Abeni Signed-off-by: Paolo Abeni Co-developed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts Signed-off-by: Dmytro Shytyi Signed-off-by: Matthieu Baerts --- net/mptcp/Makefile | 2 +- net/mptcp/fastopen.c | 28 ++++++++++++++++++++++++++++ net/mptcp/options.c | 9 ++++++--- net/mptcp/protocol.c | 9 --------- net/mptcp/protocol.h | 16 +++++++++++++++- net/mptcp/subflow.c | 5 ++++- 6 files changed, 54 insertions(+), 15 deletions(-) create mode 100644 net/mptcp/fastopen.c diff --git a/net/mptcp/Makefile b/net/mptcp/Makefile index 6e7df47c9584..a3829ce548f9 100644 --- a/net/mptcp/Makefile +++ b/net/mptcp/Makefile @@ -2,7 +2,7 @@ obj-$(CONFIG_MPTCP) += mptcp.o mptcp-y := protocol.o subflow.o options.o token.o crypto.o ctrl.o pm.o diag.o \ - mib.o pm_netlink.o sockopt.o pm_userspace.o + mib.o pm_netlink.o sockopt.o pm_userspace.o fastopen.o obj-$(CONFIG_SYN_COOKIES) += syncookies.o obj-$(CONFIG_INET_MPTCP_DIAG) += mptcp_diag.o diff --git a/net/mptcp/fastopen.c b/net/mptcp/fastopen.c new file mode 100644 index 000000000000..19c332af0834 --- /dev/null +++ b/net/mptcp/fastopen.c @@ -0,0 +1,28 @@ +// SPDX-License-Identifier: GPL-2.0 +/* MPTCP Fast Open Mechanism + * + * Copyright (c) 2021-2022, Dmytro SHYTYI + */ + +#include "protocol.h" + +void mptcp_fastopen_gen_msk_ackseq(struct mptcp_sock *msk, struct mptcp_subflow_context *subflow, + const struct mptcp_options_received *mp_opt) +{ + struct sock *sk = (struct sock *)msk; + struct sk_buff *skb; + + mptcp_data_lock(sk); + skb = skb_peek_tail(&sk->sk_receive_queue); + if (skb) { + WARN_ON_ONCE(MPTCP_SKB_CB(skb)->end_seq); + pr_debug("msk %p moving seq %llx -> %llx end_seq %llx -> %llx", sk, + MPTCP_SKB_CB(skb)->map_seq, MPTCP_SKB_CB(skb)->map_seq + msk->ack_seq, + MPTCP_SKB_CB(skb)->end_seq, MPTCP_SKB_CB(skb)->end_seq + msk->ack_seq); + MPTCP_SKB_CB(skb)->map_seq += msk->ack_seq; + MPTCP_SKB_CB(skb)->end_seq += msk->ack_seq; + } + + pr_debug("msk=%p ack_seq=%llx", msk, msk->ack_seq); + mptcp_data_unlock(sk); +} diff --git a/net/mptcp/options.c b/net/mptcp/options.c index ae076468fcb9..5ded85e2c374 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -939,7 +939,7 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk, subflow->mp_join && (mp_opt->suboptions & OPTIONS_MPTCP_MPJ) && !subflow->request_join) tcp_send_ack(ssk); - goto fully_established; + goto check_notify; } /* we must process OoO packets before the first subflow is fully @@ -950,6 +950,8 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk, if (TCP_SKB_CB(skb)->seq != subflow->ssn_offset + 1) { if (subflow->mp_join) goto reset; + if (subflow->is_mptfo && mp_opt->suboptions & OPTION_MPTCP_MPC_ACK) + goto set_fully_established; return subflow->mp_capable; } @@ -961,7 +963,7 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk, */ subflow->fully_established = 1; WRITE_ONCE(msk->fully_established, true); - goto fully_established; + goto check_notify; } /* If the first established packet does not contain MP_CAPABLE + data @@ -980,11 +982,12 @@ static bool check_fully_established(struct mptcp_sock *msk, struct sock *ssk, if (mp_opt->deny_join_id0) WRITE_ONCE(msk->pm.remote_deny_join_id0, true); +set_fully_established: if (unlikely(!READ_ONCE(msk->pm.server_side))) pr_warn_once("bogus mpc option on established client sk"); mptcp_subflow_fully_established(subflow, mp_opt); -fully_established: +check_notify: /* if the subflow is not already linked into the conn_list, we can't * notify the PM: this subflow is still on the listener queue * and the PM possibly acquiring the subflow lock could race with diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 00de7f4fce10..a12ee763e52c 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -36,15 +36,6 @@ struct mptcp6_sock { }; #endif -struct mptcp_skb_cb { - u64 map_seq; - u64 end_seq; - u32 offset; - u8 has_rxtstamp:1; -}; - -#define MPTCP_SKB_CB(__skb) ((struct mptcp_skb_cb *)&((__skb)->cb[0])) - enum { MPTCP_CMSG_TS = BIT(0), MPTCP_CMSG_INQ = BIT(1), diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index b5abea3d1a9c..618ac85abaaf 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -126,6 +126,15 @@ #define MPTCP_CONNECTED 6 #define MPTCP_RESET_SCHEDULER 7 +struct mptcp_skb_cb { + u64 map_seq; + u64 end_seq; + u32 offset; + u8 has_rxtstamp:1; +}; + +#define MPTCP_SKB_CB(__skb) ((struct mptcp_skb_cb *)&((__skb)->cb[0])) + static inline bool before64(__u64 seq1, __u64 seq2) { return (__s64)(seq1 - seq2) < 0; @@ -471,7 +480,9 @@ struct mptcp_subflow_context { disposable : 1, /* ctx can be free at ulp release time */ stale : 1, /* unable to snd/rcv data, do not use for xmit */ local_id_valid : 1, /* local_id is correctly initialized */ - valid_csum_seen : 1; /* at least one csum validated */ + valid_csum_seen : 1, /* at least one csum validated */ + is_mptfo : 1, /* subflow is doing TFO */ + __unused : 8; enum mptcp_data_avail data_avail; u32 remote_nonce; u64 thmac; @@ -829,6 +840,9 @@ void mptcp_event_addr_announced(const struct sock *ssk, const struct mptcp_addr_ void mptcp_event_addr_removed(const struct mptcp_sock *msk, u8 id); bool mptcp_userspace_pm_active(const struct mptcp_sock *msk); +void mptcp_fastopen_gen_msk_ackseq(struct mptcp_sock *msk, struct mptcp_subflow_context *subflow, + const struct mptcp_options_received *mp_opt); + static inline bool mptcp_pm_should_add_signal(struct mptcp_sock *msk) { return READ_ONCE(msk->pm.addr_signal) & diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 470e12ce0950..21cf26edb79a 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -664,6 +664,9 @@ void mptcp_subflow_fully_established(struct mptcp_subflow_context *subflow, subflow_set_remote_key(msk, subflow, mp_opt); subflow->fully_established = 1; WRITE_ONCE(msk->fully_established, true); + + if (subflow->is_mptfo) + mptcp_fastopen_gen_msk_ackseq(msk, subflow, mp_opt); } static struct sock *subflow_syn_recv_sock(const struct sock *sk, @@ -779,7 +782,7 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk, /* with OoO packets we can reach here without ingress * mpc option */ - if (mp_opt.suboptions & OPTIONS_MPTCP_MPC) + if (mp_opt.suboptions & OPTION_MPTCP_MPC_ACK) mptcp_subflow_fully_established(ctx, &mp_opt); } else if (ctx->mp_join) { struct mptcp_sock *owner; From patchwork Fri Nov 25 22:29:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 26155 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4326238wrr; Fri, 25 Nov 2022 14:33:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Zfcj9223RA2EpjqVKPF9eMXCjin6m8NcDH22vLvhfn0r1w1B7/uKelow78yHgIZkyx3EE X-Received: by 2002:a63:e618:0:b0:470:15cd:d425 with SMTP id g24-20020a63e618000000b0047015cdd425mr17478301pgh.27.1669415581239; Fri, 25 Nov 2022 14:33:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669415581; cv=none; d=google.com; s=arc-20160816; b=0VroC1B75nvhWFlKJ5EoR10iZsfA6BUwI2ShbG1KH4F+BSucYpbLQZ8bY1mUya8bHK vKMsl51Sn0BmyXVVOD5kqeD/Wt8ejQpTEqgiX11YuunqOmsjnhbykzCLASz7MYRme3Qq gKOZnQ3sMkOyMKAnZQ+vDAhhWMSUybEtl2X3tLLdR2UqmGk3bsCMzyOO/6FEs9kICVZj 4XTJi9uEyO6Qdzbaf774zTZT7jSnj6w/xqTVRXK4CvF2KqamXTaITt2z5s5iF6vb5qB+ dwfQmY+nwAqAMGK4Enn4S3V28DyWGkOD6kUs/BAUzTArAkUeqo6JKXZa/fWAEb0SM9bP /xYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CwbiTPzS3ycYqcRTF5ns89gbcE3hlofTchYdWSdIHzs=; b=hCsybuAv7oTRtU9Aw+gUulOcJbsgzhF/xvcc/DULop4VI3FXSm4pOoFXrpMLKxzRBF qWS1gTVpg7Iq2PrZGkTTxoHZa+VuPFnUnGaJAGIRQM2UvEX3xIKTC3fu6z6qOplksR9M AbKAozKGmQNb59R+6+ri4kZj0osTEXMIYdQJRMa7yU61BQ034nN5GjBsJJySsPFd9ex1 0GzIstFGBdTwwQq0Y0U1tr5si2dL2ngHvASUs2mceYyiq1hyyzOcjSgngeMHrZke/qRR DfzovivrLak96yCby67tjheP9dP/jFsyI5YMtXfWO08q/khEVImR142n60/6T+EelwQA 8gnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=dr2wjAd4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tessares.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x5-20020a654145000000b0042b807728e3si3648702pgp.762.2022.11.25.14.32.48; Fri, 25 Nov 2022 14:33:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=dr2wjAd4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230022AbiKYWar (ORCPT + 99 others); Fri, 25 Nov 2022 17:30:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229925AbiKYWai (ORCPT ); Fri, 25 Nov 2022 17:30:38 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93C4858024 for ; Fri, 25 Nov 2022 14:30:29 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id fy37so13005527ejc.11 for ; Fri, 25 Nov 2022 14:30:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; 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; bh=CwbiTPzS3ycYqcRTF5ns89gbcE3hlofTchYdWSdIHzs=; b=dr2wjAd4gkwx+qYAtXISU4a8RG6hRFOYZoFmqFNU6SaL98Blbwc7dc0T5r169CVAVo SJjt4RdA2bP92GkTgHeNLWQdCy6d7nnesUwT/kvtdx47MWUUhTqRXOd8Ndvtg/z+dD+V 38Mm11HKR1Do/MM3zAGeyldzbGwqI+dGLmQWyl6+Su7Y1SMXcTgZSNydfInI9watehPJ Dc1kVCZ9YdLEiEcO5IAui8rojV+A/uR/P0ur3YOIm6rPSXWDzJue77p5Kn7jKG6hKENg pmCcZ77YRLYLtIbxwqqHgp/JbGbn08ceEljjUqVC9SwoK72sdSpnVwlS0yhZuMeCBtx2 O3+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CwbiTPzS3ycYqcRTF5ns89gbcE3hlofTchYdWSdIHzs=; b=bxhiAfY6hpCh9n3sveTLNEdvoc7NimrQz7HmaYKNLdb2paGoCMNpkVUSyjrGDEU5kQ +8rO34pDW7u8cTknmftP/+BOFzaNW2PTg8i4OgI+oYdrKKHP5b0GB0BMN1ie5KAIvB5D aJLFSjIxLo6n/Ur7gJaaAXov4nCkdXbHTNWEf8Ehzu+sP69+aHJw4iPlqwllrRcKnkuA 685rM5ON7RCey1mUWWgjeQa3ToiGn1OqDYihgWJQJrBzotwfdyUgimTcqUEPmuMcCpbR wSBxG1rCqsltohhUtRt5nZx7Rhvk36kkEO6fFE8IJMMcfszOPj7YWRG7iyXdJt1ybFCs VIFg== X-Gm-Message-State: ANoB5pmA0FRyOG4a70QvLWdc3VGHofINtJ7wXoGj4aNKXRgq+Se9f+ps cwBSe0ii8snqCPg892UCPxKcSw== X-Received: by 2002:a17:906:7f05:b0:7af:a2d4:e95c with SMTP id d5-20020a1709067f0500b007afa2d4e95cmr34927417ejr.666.1669415427505; Fri, 25 Nov 2022 14:30:27 -0800 (PST) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id q1-20020a056402248100b0046267f8150csm2254612eda.19.2022.11.25.14.30.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Nov 2022 14:30:27 -0800 (PST) From: Matthieu Baerts To: Mat Martineau , Matthieu Baerts , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Dmytro Shytyi , netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH net-next 5/8] mptcp: add subflow_v(4,6)_send_synack() Date: Fri, 25 Nov 2022 23:29:51 +0100 Message-Id: <20221125222958.958636-6-matthieu.baerts@tessares.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221125222958.958636-1-matthieu.baerts@tessares.net> References: <20221125222958.958636-1-matthieu.baerts@tessares.net> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6996; i=matthieu.baerts@tessares.net; h=from:subject; bh=fdHE6VR0e50V3X4U9+VV9KhWPpVVAiIAwbBlfqLVJp8=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBjgUHP3MXt3FbPPsm+gevtwbsKKSJstEFM/rU6ZzUm 6Tmo8giJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY4FBzwAKCRD2t4JPQmmgcwbMEA DLIGqNOZL8Z7PBRtg5eTSLam0r2PV8s8wx7018znKHUSypysd7eiiM/YVsRPayrkWCfXcfDO32CHVz 7xNqxpkoP8CWcEY0tQHUHJfz9qfApswpBmmng1IcC9Rr0o5xt3cx4YXi33c/dcdo98h3bMNusIp0gc reIUux4e04ciaF6nm0NGsAoXkb6kZ8pLw7ouaWuuS8xT9n3fEQOPNEKlZua3It02ltFswIBH1nqYkz ljvPTcwun77le5LjTma922mtesD5SVtoZsZxcP/aB2hJ5HvCF2++/sph1GdKHSpFB3HKdHjp9UfRTf q8S1GObmWvuwOt1gNgcB+bq7sSJdXEZgZVVakmxYFHsCYMOZ6ESTA4WycMUrENU0wqoL6RyDH1gber c3y6+F62/xiDujNdkFT/qvhF3bZRT4upioYyT8F3WvchTSqZCTYd1vVr0jP1qT94b2JJFZLAko8Jri h3vL5uFV88iF2NEB632PwyojhD57wljYrBw57Sf+FCw9Z8/brn+euXG+FGrjulprQUscXPBo5S81V3 uiX8NcBSrXpKdNmw+3/hQNYOgxqZEIBChwevVgc0c1iSX0+W65x5wx712wBScYGWHeZ53t7VTCOGEM I4fb/1bCES0swP3NBLtiFcb6J6NcTXfNlbNhcmu0aFdeeqbQIcvy5KdMIl+w== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750509112498692249?= X-GMAIL-MSGID: =?utf-8?q?1750509112498692249?= From: Dmytro Shytyi The send_synack() needs to be overridden for MPTCP to support TFO for two reasons: - There is not be enough space in the TCP options if the TFO cookie has to be added in the SYN+ACK with other options: MSS (4), SACK OK (2), Timestamps (10), Window Scale (3+1), TFO (10+2), MP_CAPABLE (12). MPTCPv1 specs -- RFC 8684, section B.1 [1] -- suggest to drop the TCP timestamps option in this case. - The data received in the SYN has to be handled: the SKB can be dequeued from the subflow sk and transferred to the MPTCP sk. Counters need to be updated accordingly and the application can be notified at the end because some bytes have been received. [1] https://www.rfc-editor.org/rfc/rfc8684.html#section-b.1 Co-developed-by: Paolo Abeni Signed-off-by: Paolo Abeni Co-developed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts Signed-off-by: Dmytro Shytyi Signed-off-by: Matthieu Baerts --- net/mptcp/fastopen.c | 45 ++++++++++++++++++++++++++++++++++++++++++++ net/mptcp/protocol.c | 2 +- net/mptcp/protocol.h | 3 +++ net/mptcp/subflow.c | 43 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+), 1 deletion(-) diff --git a/net/mptcp/fastopen.c b/net/mptcp/fastopen.c index 19c332af0834..d237d142171c 100644 --- a/net/mptcp/fastopen.c +++ b/net/mptcp/fastopen.c @@ -6,6 +6,51 @@ #include "protocol.h" +void mptcp_fastopen_subflow_synack_set_params(struct mptcp_subflow_context *subflow, + struct request_sock *req) +{ + struct sock *ssk = subflow->tcp_sock; + struct sock *sk = subflow->conn; + struct sk_buff *skb; + struct tcp_sock *tp; + + tp = tcp_sk(ssk); + + subflow->is_mptfo = 1; + + skb = skb_peek(&ssk->sk_receive_queue); + if (WARN_ON_ONCE(!skb)) + return; + + /* dequeue the skb from sk receive queue */ + __skb_unlink(skb, &ssk->sk_receive_queue); + skb_ext_reset(skb); + skb_orphan(skb); + + /* We copy the fastopen data, but that don't belong to the mptcp sequence + * space, need to offset it in the subflow sequence, see mptcp_subflow_get_map_offset() + */ + tp->copied_seq += skb->len; + subflow->ssn_offset += skb->len; + + /* initialize a dummy sequence number, we will update it at MPC + * completion, if needed + */ + MPTCP_SKB_CB(skb)->map_seq = -skb->len; + MPTCP_SKB_CB(skb)->end_seq = 0; + MPTCP_SKB_CB(skb)->offset = 0; + MPTCP_SKB_CB(skb)->has_rxtstamp = TCP_SKB_CB(skb)->has_rxtstamp; + + mptcp_data_lock(sk); + + mptcp_set_owner_r(skb, sk); + __skb_queue_tail(&sk->sk_receive_queue, skb); + + sk->sk_data_ready(sk); + + mptcp_data_unlock(sk); +} + void mptcp_fastopen_gen_msk_ackseq(struct mptcp_sock *msk, struct mptcp_subflow_context *subflow, const struct mptcp_options_received *mp_opt) { diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index a12ee763e52c..cd9ad6e461b1 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -191,7 +191,7 @@ static void mptcp_rfree(struct sk_buff *skb) mptcp_rmem_uncharge(sk, len); } -static void mptcp_set_owner_r(struct sk_buff *skb, struct sock *sk) +void mptcp_set_owner_r(struct sk_buff *skb, struct sock *sk) { skb_orphan(skb); skb->sk = sk; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 618ac85abaaf..8b4379a2cd85 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -633,6 +633,7 @@ void mptcp_sock_graft(struct sock *sk, struct socket *parent); struct socket *__mptcp_nmpc_socket(const struct mptcp_sock *msk); bool __mptcp_close(struct sock *sk, long timeout); void mptcp_cancel_work(struct sock *sk); +void mptcp_set_owner_r(struct sk_buff *skb, struct sock *sk); bool mptcp_addresses_equal(const struct mptcp_addr_info *a, const struct mptcp_addr_info *b, bool use_port); @@ -842,6 +843,8 @@ bool mptcp_userspace_pm_active(const struct mptcp_sock *msk); void mptcp_fastopen_gen_msk_ackseq(struct mptcp_sock *msk, struct mptcp_subflow_context *subflow, const struct mptcp_options_received *mp_opt); +void mptcp_fastopen_subflow_synack_set_params(struct mptcp_subflow_context *subflow, + struct request_sock *req); static inline bool mptcp_pm_should_add_signal(struct mptcp_sock *msk) { diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 21cf26edb79a..fb3361f4b1e5 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -307,7 +307,48 @@ static struct dst_entry *subflow_v4_route_req(const struct sock *sk, return NULL; } +static void subflow_prep_synack(const struct sock *sk, struct request_sock *req, + struct tcp_fastopen_cookie *foc, + enum tcp_synack_type synack_type) +{ + struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); + struct inet_request_sock *ireq = inet_rsk(req); + + /* clear tstamp_ok, as needed depending on cookie */ + if (foc && foc->len > -1) + ireq->tstamp_ok = 0; + + if (synack_type == TCP_SYNACK_FASTOPEN) + mptcp_fastopen_subflow_synack_set_params(subflow, req); +} + +static int subflow_v4_send_synack(const struct sock *sk, struct dst_entry *dst, + struct flowi *fl, + struct request_sock *req, + struct tcp_fastopen_cookie *foc, + enum tcp_synack_type synack_type, + struct sk_buff *syn_skb) +{ + subflow_prep_synack(sk, req, foc, synack_type); + + return tcp_request_sock_ipv4_ops.send_synack(sk, dst, fl, req, foc, + synack_type, syn_skb); +} + #if IS_ENABLED(CONFIG_MPTCP_IPV6) +static int subflow_v6_send_synack(const struct sock *sk, struct dst_entry *dst, + struct flowi *fl, + struct request_sock *req, + struct tcp_fastopen_cookie *foc, + enum tcp_synack_type synack_type, + struct sk_buff *syn_skb) +{ + subflow_prep_synack(sk, req, foc, synack_type); + + return tcp_request_sock_ipv6_ops.send_synack(sk, dst, fl, req, foc, + synack_type, syn_skb); +} + static struct dst_entry *subflow_v6_route_req(const struct sock *sk, struct sk_buff *skb, struct flowi *fl, @@ -1945,6 +1986,7 @@ void __init mptcp_subflow_init(void) subflow_request_sock_ipv4_ops = tcp_request_sock_ipv4_ops; subflow_request_sock_ipv4_ops.route_req = subflow_v4_route_req; + subflow_request_sock_ipv4_ops.send_synack = subflow_v4_send_synack; subflow_specific = ipv4_specific; subflow_specific.conn_request = subflow_v4_conn_request; @@ -1958,6 +2000,7 @@ void __init mptcp_subflow_init(void) #if IS_ENABLED(CONFIG_MPTCP_IPV6) subflow_request_sock_ipv6_ops = tcp_request_sock_ipv6_ops; subflow_request_sock_ipv6_ops.route_req = subflow_v6_route_req; + subflow_request_sock_ipv6_ops.send_synack = subflow_v6_send_synack; subflow_v6_specific = ipv6_specific; subflow_v6_specific.conn_request = subflow_v6_conn_request; From patchwork Fri Nov 25 22:29:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 26153 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4325834wrr; Fri, 25 Nov 2022 14:32:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf5vuwZoQtg4a2GgiQEJKqeZRkn+13xFCA2ZL4Mw4Szon+ObV/OkiIQxLovqqpjRtC7YxBW5 X-Received: by 2002:a17:90a:5aa2:b0:218:e3ea:e6b3 with SMTP id n31-20020a17090a5aa200b00218e3eae6b3mr14998502pji.42.1669415526650; Fri, 25 Nov 2022 14:32:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669415526; cv=none; d=google.com; s=arc-20160816; b=Pacr+CA13mz/30kwrIKnr47luq8pwVBRlrqThmp1cg0xNE7lynKJvBNxxgp8BtN+aX mBDjrezhRwH2iUehNmY5A3B6zvjRT7JOe+3t0nsvXYipANSuxgBm3aK+hyHO1IYgnX6I x/Z2ba9UR0t/nPTauKXkChgi+ZkmnoPC4s29iO8ETbYRpqIT2uuxi5BwzlwTKD95e8Pu HXrYntuQ6/9iKDNZqXwWQ6N3ZCLdL68+gnlwKwcRFZjMf6sxtzcayViGil8WuuRmtjiQ FBXtkYRoUddOQjIG7Ok+KcZAyUJAQVaPJTAZtw1MFy5dOgqXTRguRxNylog6nYwmE+z9 pLrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1Cb2y/UtN3+Ws3JUnmppragcoaJ4ENOeTCAI1eAVlFM=; b=F6MwVwIBOIXx78k4EdmSti35xyGwbCd/y4EZ8bdLJ7vMBA29j1bbqNPrdlOKZ7aA6f EMpgVl8d1CznTJdbC6K/5eDUyqZKoS0rkP/YQweee566/cHoD+PkhUELObNDB1M2O+8Y LDx6xZ9PjMoB8ZgRrAbva+D9BewIzZPicSk8UzwVsH/N2Nr8TD5ciX0fZ+sZXpQY1+tJ QJsf2WV7zY2Yn0oxdEog79G6PkxzC+wVks679jN46vMzQHOM/CxDwIEQfehdHfeQwG3m kQrjEhSTlYOJ4bUN1jvYwNDJHs0+ibkoN2YKqar0UlIyqrbYw8erU2QU4vv+kvXmPF1p iU5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=01N2xfDv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tessares.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 1-20020a630701000000b00476cb3a08fcsi5294523pgh.338.2022.11.25.14.31.53; Fri, 25 Nov 2022 14:32:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=01N2xfDv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229953AbiKYWaw (ORCPT + 99 others); Fri, 25 Nov 2022 17:30:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229926AbiKYWai (ORCPT ); Fri, 25 Nov 2022 17:30:38 -0500 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93D1E58025 for ; Fri, 25 Nov 2022 14:30:29 -0800 (PST) Received: by mail-ej1-x62d.google.com with SMTP id ho10so13078930ejc.1 for ; Fri, 25 Nov 2022 14:30:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; 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; bh=1Cb2y/UtN3+Ws3JUnmppragcoaJ4ENOeTCAI1eAVlFM=; b=01N2xfDvgcjSbGMjylrmgTjJ9Bc13QikP569jRTFgVhoc0H6iuPm/1R0hjQQHj83rq 1ttFxwNLBg8Bw886+QyslUvLZmXpq0mfr63ty1INQU77HyPsQxMMU4w8W2FJOvpgLnkD Ak4AWRy7qbeU99I3JOSRpJ1gJWy1uizWVoco8DYHdN5zS/lS4saQeNHutAu/F47VYlzs +8uUIFuko+RZA0EWgTq9f9RFh+67jtKVpWLZtj+oHiOYTK+vknsSmYJnlLfXYDGxNuUV nTr/o2kJZ3OS9xuwh0XlyZPoBE1d5ZfbjHgtVtyFqQbfpntAWIxTL6TbNQtrvzb22sGi Oxaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1Cb2y/UtN3+Ws3JUnmppragcoaJ4ENOeTCAI1eAVlFM=; b=X+EqklqHa+Ov8hEuWjXPaChEBNO7sLD4cYxqnTexfXRxwQbxAykuiL/s3iRY9XK5ZS ajTWcsqZv6RFpbvtasW/c0a2N7mOm60uTLxldWjh/KmGJEjbhjrp7kdxZfhxL9zs0qMG 0KFHSaRAqMdNt2nQCOqyE57y48BgsI4Dv9uqWJWnCscQROJykm+FAZQljbGrKBn4sH+j I8cHfn+mdD5wTwpM0WJ41EwxqrngAPKYpoeERGDPhY1BmLmUTHIUBJI5WE2082ZZDi8F Os+UVcl99CETTSJr+Y1cBz+hrvNV37n9NtkvkOJkLnGHLnATweBZmvVJaGChN/0D+UW7 YEXQ== X-Gm-Message-State: ANoB5pnteuWndRnNIB34RVC1Mh4PeVeLG8g3agLItdzMBYMx7cXBuhV/ VYIviZKto5tL8tfqMYYcpe1goA== X-Received: by 2002:a17:907:7796:b0:7b6:6086:75bc with SMTP id ky22-20020a170907779600b007b6608675bcmr23083760ejc.181.1669415428977; Fri, 25 Nov 2022 14:30:28 -0800 (PST) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id q1-20020a056402248100b0046267f8150csm2254612eda.19.2022.11.25.14.30.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Nov 2022 14:30:28 -0800 (PST) From: Matthieu Baerts To: Mat Martineau , Matthieu Baerts , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Dmytro Shytyi , netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH net-next 6/8] mptcp: add TCP_FASTOPEN sock option Date: Fri, 25 Nov 2022 23:29:52 +0100 Message-Id: <20221125222958.958636-7-matthieu.baerts@tessares.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221125222958.958636-1-matthieu.baerts@tessares.net> References: <20221125222958.958636-1-matthieu.baerts@tessares.net> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2069; i=matthieu.baerts@tessares.net; h=from:subject; bh=3lYgndFAWxyUdVThAOH1DTU2iT5OHzt+/flIs4qdSmA=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBjgUHPHz7z7nQQ/ZU7tkAMYEJqt9sIdN822xr0gpN1 21RZWhCJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY4FBzwAKCRD2t4JPQmmgc0MmEA CPNfsIncIXq8fq2Gcg3wKHNfyVoZVZ6L/UTzsRsHUbaGrGp8amjthHO0ps6pAeK3a63cQmJZmI5i4z fPWVZvjt3sMd5Kuef01BgG7k/Ey4y0Rq0/2RewMYtsVmVDC8TxQFNt28Lbb2mVYlF5nHLOlgE6tXuR 4Opi8wfxggdLOO7+epC1gttpqqkX+td76vBL/ltaB3UO7PnJuwfIuwVUFn1IuHpj1H3Y21kCMQoTay LKBwRdScBYqBwLQk5B/9cyNwB5GvlaqXkR3dI7kMHuUy8l1md6ekv3m0829EQbp+vsPuLc7h9tj/bo MY8PkUimbNGfovbxjZrSXTpsI0xzIiCAD+p5t8Fyr3T3hCGDux/7qzuWrfoZWmKlg7O9Wf2hlFZK+y sv+veiRWLnNUHLwM6mQBFi48oqOl0msDj8o7RQAfNcN7jwmDAL8wYUR20wHzspcb+9E+mmqoVwp6QW h0ENTBEDuoXkDaAvPKrUHwvdLuYm5Mj/WmFw71SY5s3xFyR1tevNVQjHu/GwOx9xsZsSm2YSvlAZuI 1z3DVR+gd7hdQfAVDV1tepjtlUCd3YkkWwlx64oYRJmDcKI+WAxc16zQijOACIm98c15NTFXJ0dVlV njTk1sIkK3F/6pg6HJcIT2LcXE7BbFfYSa6i14O2SxPFe6i0ZlQeg2CWXeTw== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750509055371442989?= X-GMAIL-MSGID: =?utf-8?q?1750509055371442989?= From: Dmytro Shytyi The TCP_FASTOPEN socket option is one way for the application to tell the kernel TFO support has to be enabled for the listener socket. The only thing to do here with MPTCP is to relay the request to the first subflow like it is already done for the other TCP_FASTOPEN* socket options. Acked-by: Paolo Abeni Signed-off-by: Dmytro Shytyi Signed-off-by: Matthieu Baerts --- net/mptcp/sockopt.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index f62f6483ef77..c1bca711c35c 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -559,6 +559,7 @@ static bool mptcp_supported_sockopt(int level, int optname) case TCP_NOTSENT_LOWAT: case TCP_TX_DELAY: case TCP_INQ: + case TCP_FASTOPEN: case TCP_FASTOPEN_CONNECT: case TCP_FASTOPEN_NO_COOKIE: return true; @@ -569,7 +570,7 @@ static bool mptcp_supported_sockopt(int level, int optname) /* TCP_REPAIR, TCP_REPAIR_QUEUE, TCP_QUEUE_SEQ, TCP_REPAIR_OPTIONS, * TCP_REPAIR_WINDOW are not supported, better avoid this mess */ - /* TCP_FASTOPEN_KEY, TCP_FASTOPEN are not supported because + /* TCP_FASTOPEN_KEY is not supported because * fastopen for the listener side is currently unsupported */ } @@ -801,6 +802,7 @@ static int mptcp_setsockopt_sol_tcp(struct mptcp_sock *msk, int optname, /* See tcp.c: TCP_DEFER_ACCEPT does not fail */ mptcp_setsockopt_first_sf_only(msk, SOL_TCP, optname, optval, optlen); return 0; + case TCP_FASTOPEN: case TCP_FASTOPEN_CONNECT: case TCP_FASTOPEN_NO_COOKIE: return mptcp_setsockopt_first_sf_only(msk, SOL_TCP, optname, @@ -1166,6 +1168,7 @@ static int mptcp_getsockopt_sol_tcp(struct mptcp_sock *msk, int optname, case TCP_INFO: case TCP_CC_INFO: case TCP_DEFER_ACCEPT: + case TCP_FASTOPEN: case TCP_FASTOPEN_CONNECT: case TCP_FASTOPEN_NO_COOKIE: return mptcp_getsockopt_first_sf_only(msk, SOL_TCP, optname, From patchwork Fri Nov 25 22:29:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 26157 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4326542wrr; Fri, 25 Nov 2022 14:33:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Aosf9S2iuF7i+zrfe0Hq91vMIVljDjp8bosaDGW12TO2u2d0ZtZgM5lDSXneoz2yLS+jC X-Received: by 2002:a17:90b:394c:b0:213:1935:9744 with SMTP id oe12-20020a17090b394c00b0021319359744mr43107364pjb.207.1669415631597; Fri, 25 Nov 2022 14:33:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669415631; cv=none; d=google.com; s=arc-20160816; b=auJbX9BTcFJjTN8mPEomoHsPqS+sT6/Od1IZlZComwQg+QqXqAGc3QW9pJnvPk+dG/ TSoezP4/jDgGiE1SP3r1RPNXzKv9EZS0OI2WwO4NdWYMKnL7TJcSwahMfkcdBnmFzOk4 0cjKsfsIh3/1dMUBov5H335dmMeewcny3QEUfT/fnB8XSZ1xZUM4ZVkxslkK1JMf2GV8 Ns5SQoxCd0GxOgj5f3tWsnsSkspvq5msnAGC/S9yD7/rZOAE473ucN8cT618eOmTiQB2 /gNumghln1fWxs6c+IqxwSiGLsoF0epCL8gmy2P16t6v4hSDaGpJKi9dVIbMY+4txEb3 FgLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=E1JR5Int83weGmlDAZ8KCrVS6bbZMLt4JJ3mk20BbRU=; b=b3O26NSlXFXwudZsAtZQFPtR9SZE5yGKuvakZixyWRGmA5DnIgMpN+8aKI5BMgqbXw Y0GC9M4tEoeZr39gn7PjV7/vYa7+PX2FY9/ynvShR1Mm0edMNSOjAIEH132ihph5/Z2T ooaWdGbUAFGv7hzFhFHSg96vydyu+XakV7gBUwPa9bPNaQKdkgkrgyWK5QCSvRHqGr8h sIa2FBBbwa4etNwaIAC9gv3VtjGmybBCU0A2Zds4HyK+wcXq0cxZ7MYH6bWJBbhbpdgF Xvp833yj6mFsg7ofW5J2BSawVdh2jb+KaCVWap61K7/eLw1TWzCaVngCaTxn93bq9h0O W1mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=RWKW8xV7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tessares.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bw22-20020a056a00409600b0056c882d3d06si4959642pfb.199.2022.11.25.14.33.38; Fri, 25 Nov 2022 14:33:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=RWKW8xV7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230119AbiKYWbV (ORCPT + 99 others); Fri, 25 Nov 2022 17:31:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230007AbiKYWak (ORCPT ); Fri, 25 Nov 2022 17:30:40 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD44758BC0 for ; Fri, 25 Nov 2022 14:30:32 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id bj12so12974334ejb.13 for ; Fri, 25 Nov 2022 14:30:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; 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; bh=E1JR5Int83weGmlDAZ8KCrVS6bbZMLt4JJ3mk20BbRU=; b=RWKW8xV74p4li70/5s11jS4IMkdN4+7dKoqNldNA7UJtb4Za3VO0dPs8G39JsRzUGu +o2P9Km+PZyYTlHfnUUdTKa5bATCZFfcIjWnOSZdXnDQPc4TWFPESbOzozEsovGsAsO+ m2ZIFsnekdYcooRTDcsm7DgJG4Pbt9HdW3BL1y5SL6kVPS8ljHrqaC4btj82QFfIWqPE N7BhXB7YCjZjQ8zLls9AH++MPQYD7OgxBJ3A1CNbBKyxsxB2vpY2dBX1UZbuaNNmPJlH HJkNHkHzMn1nxu/GjCRkugB4ZzETsKPR5mCKklI+cwQV1cXPHowQ2LgX+uDsHqEqAEaS lA/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E1JR5Int83weGmlDAZ8KCrVS6bbZMLt4JJ3mk20BbRU=; b=dS/Ihr2nO+BQVTVYwp2PEQ+o0/DKfyRSVfh3qx1vhLRup0sKPkD4+B5gokBL+aWmDF ui+qK5PIr9v5MIb97tUEBpzDTgy+xCkQCo1+U5qhaJociTq+fviU+/HV5oCSX6Ulerm7 rpKGzk9zj7gXTo+31z6X5T7+WKKyjwle8i0waG96tU01PbKJYSvrJ9SsZEJADMP7+AYq RXUciqXboLxfGjQi1n8V5xJcHPr+IZjTVqiek2+L3c5t0Fd6AdbdazyWpQrOLTRIVgY9 6txYMCS15qPJcQownE1eqkYgEtnwXLIGFAYVIOTUa7b5cvBVr6tQVzDLuvkgCStW0RlF d84A== X-Gm-Message-State: ANoB5pmcr96+3oGIIlcrCHBGCaQVX4UFf5oa27TZKTPGVEkezOxFIut4 SrLKZbsCYdIID4mfykH/032xKg== X-Received: by 2002:a17:906:4dcb:b0:7bb:d6e5:6b1c with SMTP id f11-20020a1709064dcb00b007bbd6e56b1cmr7575596ejw.104.1669415431000; Fri, 25 Nov 2022 14:30:31 -0800 (PST) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id q1-20020a056402248100b0046267f8150csm2254612eda.19.2022.11.25.14.30.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Nov 2022 14:30:30 -0800 (PST) From: Matthieu Baerts To: Mat Martineau , Matthieu Baerts , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH net-next 7/8] mptcp: add support for TCP_FASTOPEN_KEY sockopt Date: Fri, 25 Nov 2022 23:29:53 +0100 Message-Id: <20221125222958.958636-8-matthieu.baerts@tessares.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221125222958.958636-1-matthieu.baerts@tessares.net> References: <20221125222958.958636-1-matthieu.baerts@tessares.net> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1958; i=matthieu.baerts@tessares.net; h=from:subject; bh=8soZSefjdC1P5SPfpTSfBA9V7b6DGdkwS8pfXBGPBIk=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBjgUHQCot9Zm8fgwY3GN6Emj0jLhXjYgKZQVRSfcZm +EK5pgGJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY4FB0AAKCRD2t4JPQmmgc81PEA DdalZkgR4/ghd4mFPTlTnp7uG0BFTlS1tyM3PG7S6Fgr/APXIEq9KJ5ZiNbWgvK3KuAIJcI/TZmWLF Jei7MndFIqbYYZ49hnG2G36CivbeR362ir2Mb9dpOq7UWq1oJ5b0LN5r8NZmwkdC+/JH13l7XZMHXj RizEcuS7gMc6jtg8KtoDTE6QWaOh9RiYMWRkEcyT5TW0qwHF80x6BJLJmtUs85891b4Vi3N+vMtuij hgpk1KfGLCczOwK7duRP5EjC7OtPTZk9HLqDjlKohLpMJM3ei2UlgcWqeF+MYstQ5BTGbBnEs9/HVM OzrzmQvi6QRJsjNyoG+7njrN3zV6y165jtOtjoNlfbWyXGPEuZuzhV2JX2XBJWyvjGFeRWJeojule6 N7ZihmUMUwpX9RYZUy8HtutZceHwGeio8rDKtHsYjDGpJxlR+Zvx+6NazM5xHNxMzUbKmdXAJXDxRd JSsynUxdJYJvofBsauB+qQgvQAUSBuBgLGvKcYzscJD0JjDxlxIcjW4KUBZczzhtGX/0Ib0kdeERiq xjUDT4xm95kQGnNS1zH3JAarn8TXzbMrIB20A1i0qE0nRJy4DWqwi5IH54t+qxn7ZdX1udL8GmSF5i /IARWmzBFTbJUkqj5LBKFiiD3iAfU5kxzeTuKnDs8o/G4DC2XxSJunl6C7cg== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750509165365191860?= X-GMAIL-MSGID: =?utf-8?q?1750509165365191860?= The goal of this socket option is to set different keys per listener, see commit 1fba70e5b6be ("tcp: socket option to set TCP fast open key") for more details about this socket option. The only thing to do here with MPTCP is to relay the request to the first subflow like it is already done for the other TCP_FASTOPEN* socket options. Acked-by: Paolo Abeni Signed-off-by: Matthieu Baerts --- net/mptcp/sockopt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index c1bca711c35c..a47423ebb33a 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -561,6 +561,7 @@ static bool mptcp_supported_sockopt(int level, int optname) case TCP_INQ: case TCP_FASTOPEN: case TCP_FASTOPEN_CONNECT: + case TCP_FASTOPEN_KEY: case TCP_FASTOPEN_NO_COOKIE: return true; } @@ -570,9 +571,6 @@ static bool mptcp_supported_sockopt(int level, int optname) /* TCP_REPAIR, TCP_REPAIR_QUEUE, TCP_QUEUE_SEQ, TCP_REPAIR_OPTIONS, * TCP_REPAIR_WINDOW are not supported, better avoid this mess */ - /* TCP_FASTOPEN_KEY is not supported because - * fastopen for the listener side is currently unsupported - */ } return false; } @@ -804,6 +802,7 @@ static int mptcp_setsockopt_sol_tcp(struct mptcp_sock *msk, int optname, return 0; case TCP_FASTOPEN: case TCP_FASTOPEN_CONNECT: + case TCP_FASTOPEN_KEY: case TCP_FASTOPEN_NO_COOKIE: return mptcp_setsockopt_first_sf_only(msk, SOL_TCP, optname, optval, optlen); @@ -1170,6 +1169,7 @@ static int mptcp_getsockopt_sol_tcp(struct mptcp_sock *msk, int optname, case TCP_DEFER_ACCEPT: case TCP_FASTOPEN: case TCP_FASTOPEN_CONNECT: + case TCP_FASTOPEN_KEY: case TCP_FASTOPEN_NO_COOKIE: return mptcp_getsockopt_first_sf_only(msk, SOL_TCP, optname, optval, optlen); From patchwork Fri Nov 25 22:29:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 26156 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp4326315wrr; Fri, 25 Nov 2022 14:33:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf4mf6zab9nqluygEJ5aDcInJ0qK6HKQuc3MYpG8t7HI9B6QiiB3t9BOnke4VbyCBeU+Df6C X-Received: by 2002:a63:c14e:0:b0:470:4f30:6d80 with SMTP id p14-20020a63c14e000000b004704f306d80mr24750467pgi.285.1669415596093; Fri, 25 Nov 2022 14:33:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669415596; cv=none; d=google.com; s=arc-20160816; b=OqezAWviT+sRYc4mjkoKJn85sB9BuQepnQCAhtBEIwKio/qbK0iIyPNtEZqVlXb8l0 XKwnL0iwytuziHD6i44T3pI8w8KwkaH/EZiJuBUEb/RulErxMhj+AyxUs3nGvbFo15l+ CKepMTSqQBfur/HUEhEzr4C6iC7bbpOBueZqyjSaIvaU8KZhXMvIWhqtFfaSZ9dx9mWB isDGYGSYtXX0E9Lm4kTj5pquSKq2NnPgkgTZIOodCHellagRnx9A0Ba7+DpH2oad/dpF TUJre1LX3Saon+cXdzYCiq5/Xb+XX5W42aQhlxQPeEm8mwRILuqnMARTTZoArvR3hiLG OOlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9FW1FPeLZx4mDcycLi1OiKzB79mBTY0nX1izjOvx9Nc=; b=htVI3XMzcJXmIXbyRqCCWcwoOnes9QdYdzRQHEqmHcWPrnDQuwZiPWoeb+FHI1MLFX q1uUxcaaPb4K9OMnZSRiULKF4ETkiOeTuzPtvMKKOG1Oz+V6EDKgVTJ8uJOEqs8WJAPs gT1p8PL7p6bj3CZrlEycp98ffjutbuKm67j+DQJ/VgmOauLCPdfKQUZrEckF1ULLDS2t YVfChUAn8HNJbadbJAQ9nFr07Nk+Q4yG7tfqQ+GQGw005KC5yNF0lUoy0qfXSVS33ZAt PF7HVSfbs6t8NuFb+I6hn4yWz+ooM6DKY47OFnMidWrTlSQh+AqBYdmJRU4MZeUVnvNa nTYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=8tSprGLZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tessares.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n190-20020a6340c7000000b00473d2108706si5368024pga.199.2022.11.25.14.33.01; Fri, 25 Nov 2022 14:33:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=8tSprGLZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229994AbiKYWbd (ORCPT + 99 others); Fri, 25 Nov 2022 17:31:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230061AbiKYWbD (ORCPT ); Fri, 25 Nov 2022 17:31:03 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98F5458BCD for ; Fri, 25 Nov 2022 14:30:34 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id x2so8069577edd.2 for ; Fri, 25 Nov 2022 14:30:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; 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; bh=9FW1FPeLZx4mDcycLi1OiKzB79mBTY0nX1izjOvx9Nc=; b=8tSprGLZ8nCj3kaBjQQcHtEI/jJAfe8hfnr+qrlgBPsAn2tXDIcCbfcMyZHkQRO/Ne rf0c/a8cph7AYSBG2EdzrlfVbcMyBkumiUw8ljPnzn3+7x/RmseIOMOhREa7vDXd+lO6 dIDUfEBW76Fi3a02PZhEwELv+9UO+S7dupup+7iVIE3CQudKJH0DMOas8Stew/zTUyLI EDnPymooraXi5sHrKe7LxiSBIWQU14XuCbpIv1HnV4/TUgAdV5eAcuBf7ZUYCSD72A/S bIWVoXvmHg6ULtMO9td8teCtDdqxwMslAEwtoFabUJTiAwfpzAONUYof/h+7BSxZ3sDM UsJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9FW1FPeLZx4mDcycLi1OiKzB79mBTY0nX1izjOvx9Nc=; b=YZ251Kc3xYwanTPpzLVGQDqo3OPJ4ox7rFM6iwQEhAm95X59mdf8jH2Tfto8hQBf4R CL06gEADNHmLMaR0AcufLNfK+zz4Jdg8w2mgN8rJNRMwCcPYNZLjyulKW2FiifTffYyx 3FiRmayDLXeULxWLelkEMz4PCetia6Ltqd2BVfWkc2fs2LMoHHiaGyb5nNW8OjeVGOS2 kMLm5wViniaRaEvSW2Ov+Jcu8mwSGfMvT+XDnbfIublLu/erI1GAZ7pig5N7w747WUZr nBzpylhFG/lMEEs58lMIIdWY3o/CV9wfCPiWgyfS3zK9IN9CaHFCjjWsFm6m1tYPUO5s 8m6Q== X-Gm-Message-State: ANoB5pld9dTj9XrU7rBEE4lXqfj4sWfdqp7cGkHnuTfzQ88yutTEgwfY 9sDfXIoplCXh6wJh7UfysJEiPg== X-Received: by 2002:a05:6402:ea0:b0:463:a83c:e019 with SMTP id h32-20020a0564020ea000b00463a83ce019mr20782813eda.253.1669415432901; Fri, 25 Nov 2022 14:30:32 -0800 (PST) Received: from vdi08.nix.tessares.net (static.219.156.76.144.clients.your-server.de. [144.76.156.219]) by smtp.gmail.com with ESMTPSA id q1-20020a056402248100b0046267f8150csm2254612eda.19.2022.11.25.14.30.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Nov 2022 14:30:32 -0800 (PST) From: Matthieu Baerts To: Mat Martineau , Matthieu Baerts , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: Dmytro Shytyi , netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 8/8] selftests: mptcp: mptfo Initiator/Listener Date: Fri, 25 Nov 2022 23:29:54 +0100 Message-Id: <20221125222958.958636-9-matthieu.baerts@tessares.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221125222958.958636-1-matthieu.baerts@tessares.net> References: <20221125222958.958636-1-matthieu.baerts@tessares.net> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=13376; i=matthieu.baerts@tessares.net; h=from:subject; bh=/yNrNZcdW7bNIcSFQjgLzGv5H2U4OMElFjPASvCJmLg=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBjgUHQEWiDtRCFe+QHpCjVwW+BaTtDLjIGTeMP0jyN qOX0wvmJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCY4FB0AAKCRD2t4JPQmmgcxauEA DtDSvYnW8cVflXM4b5GHzHSRoYiscvMk54R/UToyGKqw/W7K0jJmt3CFEXjU3557D86eLdWee69v/2 unV7zfWcxGLK76dNjGpsnyxxqP8Ji3NUTGSUgxwI7+DOkdrFSQ1vq97+Vrxd6hAqRZ9dMsnSDCbDA4 nfmRXesJa817IBuRkOoM0Q3Q/rUE+nmMUrOKEygxkObZzUi8aY3Cyq3q6gAcAzEfHP5NoH39/kCZ4d xam9EnxdOCzHgPe3st6b+ZwBwcOamCfW6ARibftEZYi30rJFPzl1XqQfILu81qgOkEClZH80nvl6bb ivH+1YHSVXIGDJLslYsdUwAreIakL8cEA0NwGIRRydMc8sXYOZVzeYoFrtSHU9L7R7oaa8hKbjawt5 hpvkrXNaSglIwXqHF39ZOkaY2lBshEyoO7k6to3ielVrudRBqmDKuukdwcYW2vaXWAFKk6Yq3GOJeh 7jXmzJYU/Aa5uKd0uOrAJu2i4fWQ/NKaw4BLVpp2BkqSv/wzZ2qBj+BCSzkCDDDO6xRD7kfLpR2+SQ cfg+dIWTzuc0xXxg0vxp28wTV0bEN+KZMnWQQ0gh1xOyAPWyVj54JhCGs2dHNnExZz4Vnz4N2SeCgt wGfkvnIhWxsod+9Ld6Ba+iHG+E2J0OEOCeM/yt/okDYA6sz1IKzGQ0QO4rfQ== X-Developer-Key: i=matthieu.baerts@tessares.net; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750509128439264261?= X-GMAIL-MSGID: =?utf-8?q?1750509128439264261?= From: Dmytro Shytyi This patch first adds TFO support in mptcp_connect.c. This can be enabled via a new option: -o MPTFO. Once enabled, the TCP_FASTOPEN socket option is enabled for the server side and a sendto() with MSG_FASTOPEN is used instead of a connect() for the client side. Note that the first SYN has a limit of bytes it can carry. In other words, it is allowed to send less data than the provided one. We then need to track more status info to properly allow the next sendmsg() starting from the next part of the data to send the rest. Also in TFO scenarios, we need to completely spool the partially xmitted buffer -- and account for that -- before starting sendfile/mmap xmit, otherwise the relevant tests will fail. Co-developed-by: Paolo Abeni Signed-off-by: Paolo Abeni Signed-off-by: Dmytro Shytyi Signed-off-by: Matthieu Baerts --- .../selftests/net/mptcp/mptcp_connect.c | 171 +++++++++++++----- .../selftests/net/mptcp/mptcp_connect.sh | 21 +++ 2 files changed, 150 insertions(+), 42 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c index e54653ea2ed4..8a8266957bc5 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c @@ -83,6 +83,7 @@ struct cfg_cmsg_types { struct cfg_sockopt_types { unsigned int transparent:1; + unsigned int mptfo:1; }; struct tcp_inq_state { @@ -90,6 +91,13 @@ struct tcp_inq_state { bool expect_eof; }; +struct wstate { + char buf[8192]; + unsigned int len; + unsigned int off; + unsigned int total_len; +}; + static struct tcp_inq_state tcp_inq; static struct cfg_cmsg_types cfg_cmsg_types; @@ -232,6 +240,14 @@ static void set_transparent(int fd, int pf) } } +static void set_mptfo(int fd, int pf) +{ + int qlen = 25; + + if (setsockopt(fd, IPPROTO_TCP, TCP_FASTOPEN, &qlen, sizeof(qlen)) == -1) + perror("TCP_FASTOPEN"); +} + static int do_ulp_so(int sock, const char *name) { return setsockopt(sock, IPPROTO_TCP, TCP_ULP, name, strlen(name)); @@ -300,6 +316,9 @@ static int sock_listen_mptcp(const char * const listenaddr, if (cfg_sockopt_types.transparent) set_transparent(sock, pf); + if (cfg_sockopt_types.mptfo) + set_mptfo(sock, pf); + if (bind(sock, a->ai_addr, a->ai_addrlen) == 0) break; /* success */ @@ -330,13 +349,15 @@ static int sock_listen_mptcp(const char * const listenaddr, static int sock_connect_mptcp(const char * const remoteaddr, const char * const port, int proto, - struct addrinfo **peer) + struct addrinfo **peer, + int infd, struct wstate *winfo) { struct addrinfo hints = { .ai_protocol = IPPROTO_TCP, .ai_socktype = SOCK_STREAM, }; struct addrinfo *a, *addr; + int syn_copied = 0; int sock = -1; hints.ai_family = pf; @@ -354,14 +375,34 @@ static int sock_connect_mptcp(const char * const remoteaddr, if (cfg_mark) set_mark(sock, cfg_mark); - if (connect(sock, a->ai_addr, a->ai_addrlen) == 0) { - *peer = a; - break; /* success */ + if (cfg_sockopt_types.mptfo) { + if (!winfo->total_len) + winfo->total_len = winfo->len = read(infd, winfo->buf, + sizeof(winfo->buf)); + + syn_copied = sendto(sock, winfo->buf, winfo->len, MSG_FASTOPEN, + a->ai_addr, a->ai_addrlen); + if (syn_copied >= 0) { + winfo->off = syn_copied; + winfo->len -= syn_copied; + *peer = a; + break; /* success */ + } + } else { + if (connect(sock, a->ai_addr, a->ai_addrlen) == 0) { + *peer = a; + break; /* success */ + } + } + if (cfg_sockopt_types.mptfo) { + perror("sendto()"); + close(sock); + sock = -1; + } else { + perror("connect()"); + close(sock); + sock = -1; } - - perror("connect()"); - close(sock); - sock = -1; } freeaddrinfo(addr); @@ -571,14 +612,14 @@ static void shut_wr(int fd) shutdown(fd, SHUT_WR); } -static int copyfd_io_poll(int infd, int peerfd, int outfd, bool *in_closed_after_out) +static int copyfd_io_poll(int infd, int peerfd, int outfd, + bool *in_closed_after_out, struct wstate *winfo) { struct pollfd fds = { .fd = peerfd, .events = POLLIN | POLLOUT, }; - unsigned int woff = 0, wlen = 0, total_wlen = 0, total_rlen = 0; - char wbuf[8192]; + unsigned int total_wlen = 0, total_rlen = 0; set_nonblock(peerfd, true); @@ -638,19 +679,19 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd, bool *in_closed_after } if (fds.revents & POLLOUT) { - if (wlen == 0) { - woff = 0; - wlen = read(infd, wbuf, sizeof(wbuf)); + if (winfo->len == 0) { + winfo->off = 0; + winfo->len = read(infd, winfo->buf, sizeof(winfo->buf)); } - if (wlen > 0) { + if (winfo->len > 0) { ssize_t bw; /* limit the total amount of written data to the trunc value */ - if (cfg_truncate > 0 && wlen + total_wlen > cfg_truncate) - wlen = cfg_truncate - total_wlen; + if (cfg_truncate > 0 && winfo->len + total_wlen > cfg_truncate) + winfo->len = cfg_truncate - total_wlen; - bw = do_rnd_write(peerfd, wbuf + woff, wlen); + bw = do_rnd_write(peerfd, winfo->buf + winfo->off, winfo->len); if (bw < 0) { if (cfg_rcv_trunc) return 0; @@ -658,10 +699,10 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd, bool *in_closed_after return 111; } - woff += bw; - wlen -= bw; + winfo->off += bw; + winfo->len -= bw; total_wlen += bw; - } else if (wlen == 0) { + } else if (winfo->len == 0) { /* We have no more data to send. */ fds.events &= ~POLLOUT; @@ -717,10 +758,26 @@ static int do_recvfile(int infd, int outfd) return (int)r; } -static int do_mmap(int infd, int outfd, unsigned int size) +static int spool_buf(int fd, struct wstate *winfo) +{ + while (winfo->len) { + int ret = write(fd, winfo->buf + winfo->off, winfo->len); + + if (ret < 0) { + perror("write"); + return 4; + } + winfo->off += ret; + winfo->len -= ret; + } + return 0; +} + +static int do_mmap(int infd, int outfd, unsigned int size, + struct wstate *winfo) { char *inbuf = mmap(NULL, size, PROT_READ, MAP_SHARED, infd, 0); - ssize_t ret = 0, off = 0; + ssize_t ret = 0, off = winfo->total_len; size_t rem; if (inbuf == MAP_FAILED) { @@ -728,7 +785,11 @@ static int do_mmap(int infd, int outfd, unsigned int size) return 1; } - rem = size; + ret = spool_buf(outfd, winfo); + if (ret < 0) + return ret; + + rem = size - winfo->total_len; while (rem > 0) { ret = write(outfd, inbuf + off, rem); @@ -772,8 +833,16 @@ static int get_infd_size(int fd) return (int)count; } -static int do_sendfile(int infd, int outfd, unsigned int count) +static int do_sendfile(int infd, int outfd, unsigned int count, + struct wstate *winfo) { + int ret = spool_buf(outfd, winfo); + + if (ret < 0) + return ret; + + count -= winfo->total_len; + while (count > 0) { ssize_t r; @@ -790,7 +859,8 @@ static int do_sendfile(int infd, int outfd, unsigned int count) } static int copyfd_io_mmap(int infd, int peerfd, int outfd, - unsigned int size, bool *in_closed_after_out) + unsigned int size, bool *in_closed_after_out, + struct wstate *winfo) { int err; @@ -799,9 +869,9 @@ static int copyfd_io_mmap(int infd, int peerfd, int outfd, if (err) return err; - err = do_mmap(infd, peerfd, size); + err = do_mmap(infd, peerfd, size, winfo); } else { - err = do_mmap(infd, peerfd, size); + err = do_mmap(infd, peerfd, size, winfo); if (err) return err; @@ -815,7 +885,7 @@ static int copyfd_io_mmap(int infd, int peerfd, int outfd, } static int copyfd_io_sendfile(int infd, int peerfd, int outfd, - unsigned int size, bool *in_closed_after_out) + unsigned int size, bool *in_closed_after_out, struct wstate *winfo) { int err; @@ -824,9 +894,9 @@ static int copyfd_io_sendfile(int infd, int peerfd, int outfd, if (err) return err; - err = do_sendfile(infd, peerfd, size); + err = do_sendfile(infd, peerfd, size, winfo); } else { - err = do_sendfile(infd, peerfd, size); + err = do_sendfile(infd, peerfd, size, winfo); if (err) return err; @@ -839,7 +909,7 @@ static int copyfd_io_sendfile(int infd, int peerfd, int outfd, return err; } -static int copyfd_io(int infd, int peerfd, int outfd, bool close_peerfd) +static int copyfd_io(int infd, int peerfd, int outfd, bool close_peerfd, struct wstate *winfo) { bool in_closed_after_out = false; struct timespec start, end; @@ -851,21 +921,24 @@ static int copyfd_io(int infd, int peerfd, int outfd, bool close_peerfd) switch (cfg_mode) { case CFG_MODE_POLL: - ret = copyfd_io_poll(infd, peerfd, outfd, &in_closed_after_out); + ret = copyfd_io_poll(infd, peerfd, outfd, &in_closed_after_out, + winfo); break; case CFG_MODE_MMAP: file_size = get_infd_size(infd); if (file_size < 0) return file_size; - ret = copyfd_io_mmap(infd, peerfd, outfd, file_size, &in_closed_after_out); + ret = copyfd_io_mmap(infd, peerfd, outfd, file_size, + &in_closed_after_out, winfo); break; case CFG_MODE_SENDFILE: file_size = get_infd_size(infd); if (file_size < 0) return file_size; - ret = copyfd_io_sendfile(infd, peerfd, outfd, file_size, &in_closed_after_out); + ret = copyfd_io_sendfile(infd, peerfd, outfd, file_size, + &in_closed_after_out, winfo); break; default: @@ -999,6 +1072,7 @@ static void maybe_close(int fd) int main_loop_s(int listensock) { struct sockaddr_storage ss; + struct wstate winfo; struct pollfd polls; socklen_t salen; int remotesock; @@ -1033,7 +1107,8 @@ int main_loop_s(int listensock) SOCK_TEST_TCPULP(remotesock, 0); - copyfd_io(fd, remotesock, 1, true); + memset(&winfo, 0, sizeof(winfo)); + copyfd_io(fd, remotesock, 1, true, &winfo); } else { perror("accept"); return 1; @@ -1130,6 +1205,11 @@ static void parse_setsock_options(const char *name) return; } + if (strncmp(name, "MPTFO", len) == 0) { + cfg_sockopt_types.mptfo = 1; + return; + } + fprintf(stderr, "Unrecognized setsockopt option %s\n", name); exit(1); } @@ -1166,11 +1246,18 @@ void xdisconnect(int fd, int addrlen) int main_loop(void) { - int fd, ret, fd_in = 0; + int fd = 0, ret, fd_in = 0; struct addrinfo *peer; + struct wstate winfo; + + if (cfg_input && cfg_sockopt_types.mptfo) { + fd_in = open(cfg_input, O_RDONLY); + if (fd < 0) + xerror("can't open %s:%d", cfg_input, errno); + } - /* listener is ready. */ - fd = sock_connect_mptcp(cfg_host, cfg_port, cfg_sock_proto, &peer); + memset(&winfo, 0, sizeof(winfo)); + fd = sock_connect_mptcp(cfg_host, cfg_port, cfg_sock_proto, &peer, fd_in, &winfo); if (fd < 0) return 2; @@ -1186,14 +1273,13 @@ int main_loop(void) if (cfg_cmsg_types.cmsg_enabled) apply_cmsg_types(fd, &cfg_cmsg_types); - if (cfg_input) { + if (cfg_input && !cfg_sockopt_types.mptfo) { fd_in = open(cfg_input, O_RDONLY); if (fd < 0) xerror("can't open %s:%d", cfg_input, errno); } - /* close the client socket open only if we are not going to reconnect */ - ret = copyfd_io(fd_in, fd, 1, 0); + ret = copyfd_io(fd_in, fd, 1, 0, &winfo); if (ret) return ret; @@ -1210,6 +1296,7 @@ int main_loop(void) xerror("can't reconnect: %d", errno); if (cfg_input) close(fd_in); + memset(&winfo, 0, sizeof(winfo)); goto again; } else { close(fd); diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh index 621af6895f4d..60198b91a530 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -762,6 +762,23 @@ run_tests_peekmode() run_tests_lo "$ns1" "$ns1" dead:beef:1::1 1 "-P ${peekmode}" } +run_tests_mptfo() +{ + echo "INFO: with MPTFO start" + ip netns exec "$ns1" sysctl -q net.ipv4.tcp_fastopen=2 + ip netns exec "$ns2" sysctl -q net.ipv4.tcp_fastopen=1 + + run_tests_lo "$ns1" "$ns2" 10.0.1.1 0 "-o MPTFO" + run_tests_lo "$ns1" "$ns2" 10.0.1.1 0 "-o MPTFO" + + run_tests_lo "$ns1" "$ns2" dead:beef:1::1 0 "-o MPTFO" + run_tests_lo "$ns1" "$ns2" dead:beef:1::1 0 "-o MPTFO" + + ip netns exec "$ns1" sysctl -q net.ipv4.tcp_fastopen=0 + ip netns exec "$ns2" sysctl -q net.ipv4.tcp_fastopen=0 + echo "INFO: with MPTFO end" +} + run_tests_disconnect() { local peekmode="$1" @@ -901,6 +918,10 @@ run_tests_peekmode "saveWithPeek" run_tests_peekmode "saveAfterPeek" stop_if_error "Tests with peek mode have failed" +# MPTFO (MultiPath TCP Fatopen tests) +run_tests_mptfo +stop_if_error "Tests with MPTFO have failed" + # connect to ns4 ip address, ns2 should intercept/proxy run_test_transparent 10.0.3.1 "tproxy ipv4" run_test_transparent dead:beef:3::1 "tproxy ipv6"