From patchwork Fri Aug 11 15:57:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 134611 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1252445vqi; Fri, 11 Aug 2023 10:36:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG2LN/dMeeXI6ojG4zlxYlpnBMmVZWd90JuPPVKzsVoFwpmOK0kdbRdJFm+y3Lsl92tUr8t X-Received: by 2002:a05:6a20:729c:b0:13e:a442:c899 with SMTP id o28-20020a056a20729c00b0013ea442c899mr3861791pzk.37.1691775402157; Fri, 11 Aug 2023 10:36:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691775402; cv=none; d=google.com; s=arc-20160816; b=JM1/dwy7twjgZ3jpgUBMgjLZ148Czq7GEU5qKeLovoB9gHqvfY9bOI6DAPpBamW/e9 mlCewPFSiWRadc35eue0b7/XvKBcsvY8KF8lvJybW4fL8X0a9M/BNGfHd2lYmsCawYMW 7zZymcoJ6HS4XKjbXCfKoCfwCkqbIhtsJ7NZxk8L4ihqgFb2jsdZzMbKlKN3ON2cAqyj Ua7lA9Rx2ObLQrdo/pJ6TkgA45RchR0PiXVJAJrE8Udwyybofced4QZiXUmxMRtRkXL7 AHbI4jckupAl8cxZhZuEEZXXol8STnPuG8GXbePuZ3IFxyK7WWPOyn597hvv+QdcMO3h xqCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=k5X9dCBbAfU6DjT+NDvr2dXxeO/cfwiJDXtpifKgXlA=; fh=01LXX0/E7r2X8N0dkUmDXKtwLjGB7IavRhxV+MLJbog=; b=N8eZ8oDI7pM/V1fJBhIpHgjvzG7AuhJDXriv+haRe5MqOpalRp3DlFocjYRjc4z4xM l7oiDzyj6qX1212POPSHEw6l3R03AVqcv2wT3CqXNUWBV0bYLyzWW0OzTTjjPDVYeCDi IFc4F/QTYBy0ZsjUDwdd9QvF3GIRE8Quc0lVgSwdFArl2NFxhcYbvXIv308ViFriFted a6IsHxP8IWMUzcka6mh2dZeu36I91Xtt+57oBQoHk3FOJPmsMForp9cKFNKcZRn+T65r gLgEeezYsRQQSw6Hl/s3MH4/i99dEyQvYutG5xUL6bcx1NSXKdPU5PM/VbxKhyEE7n2m adoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=AfNHOQJ2; 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=REJECT sp=REJECT 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 m16-20020a63fd50000000b00565660b78d3si1171696pgj.591.2023.08.11.10.36.24; Fri, 11 Aug 2023 10:36:42 -0700 (PDT) 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=AfNHOQJ2; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236681AbjHKP6p (ORCPT + 99 others); Fri, 11 Aug 2023 11:58:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236675AbjHKP6o (ORCPT ); Fri, 11 Aug 2023 11:58:44 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DA9730D4 for ; Fri, 11 Aug 2023 08:58:43 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-317b31203c7so1925250f8f.2 for ; Fri, 11 Aug 2023 08:58:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1691769522; x=1692374322; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=k5X9dCBbAfU6DjT+NDvr2dXxeO/cfwiJDXtpifKgXlA=; b=AfNHOQJ2nkB4iLHU0XVMtVVb1UTnxAlXjmudsfmcOaORZaxOvRzrr6koOLBpjL69QQ tt9xfEhLwbWEL3B7zOiiJ3zwChgyoycobsJf7svUsEVpCMgPOLnp3DPZtSoOnpVwxKDb 18FBd+zzEuVvYjyW1rujienvRQtSWWwKZMXGN6ZfK7/X3GRIsk4s6KKUq6Iiy26aWt6H gmoTwFWF9zbFCXa8wxuWHRN2D6xzLGJg8vmjzlFdVyvV9h2whRtMfhHnzPBSyY7yLkO4 6CnTY9+d+D8b4YjvYmH8zjFo2tLhlqIO41WsVPYxWAyBdtCH2il3OvT08DS2+ywhFiiG HYtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691769522; x=1692374322; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k5X9dCBbAfU6DjT+NDvr2dXxeO/cfwiJDXtpifKgXlA=; b=T502YaQVzrOWXsiRuAh0IJAa7bWB3jibeRcmfrjuD3/TzwRvfg8fIjIXBTsVE55xbk Ffak6PyXhpwSqd1KqDq9dhsJvIEyB885fhzt+fi6laz2ZwV9g6VnuSl5DXfQ7ygtoTi3 nSKRIzGrq49yIgh1kPfJuhQCuTOe7DphLkl8X/SIdN6vctvXmYyqvh1HyydrjjxZ+dYZ a0TieOn8VIGdtLo2umGTrTPRN5CWCKdJEtU/7WTgyNhW3IfC+vIiHU4uzA5n7qUFONuy dxsX6DtXi07c1C9OySkcZu6iF1qOjx76TUqILzMr2aKnRLVv1/TxWxvKgmkqK9GdozFK bHUA== X-Gm-Message-State: AOJu0YymESycpd20e5Q1l58y3kMhQAhXnmqED/CD8t7vci7vPspxblhY 16AqyNDQtFYo8qLzFfu8PgwZkg== X-Received: by 2002:adf:fc0f:0:b0:314:3a3d:5d1f with SMTP id i15-20020adffc0f000000b003143a3d5d1fmr1851910wrr.19.1691769521953; Fri, 11 Aug 2023 08:58:41 -0700 (PDT) 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 m12-20020a5d4a0c000000b00317e9c05d35sm5834308wrq.85.2023.08.11.08.58.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 08:58:41 -0700 (PDT) From: Matthieu Baerts Date: Fri, 11 Aug 2023 17:57:14 +0200 Subject: [PATCH net-next 01/14] mptcp: avoid unneeded mptcp_token_destroy() calls MIME-Version: 1.0 Message-Id: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-1-36183269ade8@tessares.net> References: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> In-Reply-To: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1720; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=gXoRie7DLKf3vWVejVmTZfC//Kg+jCDe1+Txjp6fEyI=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBk1lqv+r3KsHtF8v8Wo26pcmdkgVeFoZMKt2vnr HOE8E3VCBeJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZNZarwAKCRD2t4JPQmmg c5hhD/0c8KK8DF9+DihPAJVsBCw7OJK4Qsqj2v1GgkbmoYkVV/vFyweuzcYBNmZTwHt0Su6nykO yTlwWPLLzZhhIAXBOXbC3XB7d2jkyS3h2pqF/9NcTWo8weFJ8uSMbNlAe7PnjeMAIpzPkJrEK8H 4YkzZK9+ntc2MMMzT73WfsF5iC+FruQYPx/OhwC6yAEVeJ23v5qxEJJojrDZJN+x51fFdQdJNF/ QvsWBAWSLqAXLxy+4Ds9b8q8FMkIXKXIaws85ymRXZ/94L20W9rPdHHljK1Ek1hYlHbD8LJNcxO No80OBKqkrAXLp3LEsaADiPDGyDQSMeaWkRjFZlSj7dybAooRafbK8PZ1Da3GUJsR3Iv8cbj+9O cjhYtxdA6xrGd7MsTFO2pwlVGHp3NCJQyIyqoQFgpjflevMdPrfX/1kA0i/dioxVacgWg8/5uLO 5S0HrjyyGNyngounFXMI4f4Lsouhe0X+DgUcSLMUqyEb+Dpt3XyyIh+nZDOFc9Ivvi1pzkGYovL fLLChmmsbzNCGm4exod+n3UvNvo6upaYtM9NJqaT8A7u8XfsWA9bbICQ2IVtU1htskbe1U0L1Bn Qyhhfb59KB54aTJX647M05snl4oFlidlaSmSjVcMZKw2963aE61PrSJtRdVXw2g/wzH2L6b4HFU 8k5iDsBxKuQShNg== 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,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773955084168959019 X-GMAIL-MSGID: 1773955084168959019 From: Paolo Abeni The MPTCP protocol currently clears the msk token both at connect() and listen() time. That is needed to deal with failing connect() calls that can create a new token while leaving the sk in TCP_CLOSE,SS_UNCONNECTED status and thus allowing later connect() and/or listen() calls. Let's deal with such failures explicitly, cleaning the token in a timely manner and avoid the confusing early mptcp_token_destroy(). Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 48e649fe2360..abb310548c37 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3594,7 +3594,6 @@ static int mptcp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) if (IS_ERR(ssock)) return PTR_ERR(ssock); - mptcp_token_destroy(msk); inet_sk_state_store(sk, TCP_SYN_SENT); subflow = mptcp_subflow_ctx(ssock->sk); #ifdef CONFIG_TCP_MD5SIG @@ -3624,6 +3623,8 @@ static int mptcp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) * subflow_finish_connect() */ if (unlikely(err && err != -EINPROGRESS)) { + /* avoid leaving a dangling token in an unconnected socket */ + mptcp_token_destroy(msk); inet_sk_state_store(sk, inet_sk_state_load(ssock->sk)); return err; } @@ -3713,7 +3714,6 @@ static int mptcp_listen(struct socket *sock, int backlog) goto unlock; } - mptcp_token_destroy(msk); inet_sk_state_store(sk, TCP_LISTEN); sock_set_flag(sk, SOCK_RCU_FREE); From patchwork Fri Aug 11 15:57:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 134577 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1211764vqi; Fri, 11 Aug 2023 09:27:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEJe9kM83ZsuBY2nwGNdwmgaY4WxHZNUyLFDELe0ejbbsbD19bxUtK5ED51k/M5uQ5u6Lew X-Received: by 2002:a17:902:ab5a:b0:1bd:bfc0:4627 with SMTP id ij26-20020a170902ab5a00b001bdbfc04627mr1217853plb.40.1691771261926; Fri, 11 Aug 2023 09:27:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691771261; cv=none; d=google.com; s=arc-20160816; b=BRF2dCId/11g0xo4m3TbfKbGEeW5W6+y32PZcV+O33y3t1Qe0ylyC+h+m5HqjCoN+N H++XA+p56jwkbhOk+npkzRFRzTfDy+Fl7sF16UeGw5bc6GM6ZYwBAhrs/rhggev2Gb/7 hcD5uY0cPjj+lKHkDqdhnA5jacOCTb+Kilg+fG1hkagbAh7Lmr2sh7ZgNhrSk32SVuDm TY8HaJ84S1y+AXfDl3+p6VBas8PE6E/D6LqENADQHRZCUY+J2FxjkTQlt7c0wUX4ffmR Afi0IKL5lBfdE0F2JglmC7XKcq4AkpJPX9PMjQ3WRYoRRD5YwksDqLHlC4P1rYY2hhnB 4RuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=lhePiwzsSx/PL85mddTkFwpXPwkG7Z75k06o+iuXV0A=; fh=01LXX0/E7r2X8N0dkUmDXKtwLjGB7IavRhxV+MLJbog=; b=ehUyGxEq1APH4ZN7oWwzXbaG43X0jrBuSc43dMU99U8FuPu3rH1LCji3FoiRYufpdC 1e5CZXtwCZYsVKS4y5mLp6QrpHsqd9eDYuaE0z83VHjbI80rdVju+cIJlllPlx0v88/5 rTIQVl1XJGacZFM30wWuu8tjSNU6eparjWHxCpX6ZUx+wJOLD/ldPsSxouNEokoKjs8R UZB2OcWSAfsTJ84tzWuU7fneNT69LexHU8MNZ4D9VAevTZ3fCmBPuRCYkMj2Liph1CAz heTvq/Tw5lQr3GUETKmnGH4dOEzHv8TH6aYc4T9ofaBK/O9YJpeP/i1C0dmuO3eZyIut uAkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=v1ebNHHM; 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=REJECT sp=REJECT 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 z10-20020a170903018a00b001aff514a8f0si3686528plg.534.2023.08.11.09.27.21; Fri, 11 Aug 2023 09:27:41 -0700 (PDT) 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=v1ebNHHM; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236702AbjHKP6t (ORCPT + 99 others); Fri, 11 Aug 2023 11:58:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236680AbjHKP6p (ORCPT ); Fri, 11 Aug 2023 11:58:45 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAC5D30D8 for ; Fri, 11 Aug 2023 08:58:44 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-4fe0eb0ca75so3286148e87.2 for ; Fri, 11 Aug 2023 08:58:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1691769523; x=1692374323; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=lhePiwzsSx/PL85mddTkFwpXPwkG7Z75k06o+iuXV0A=; b=v1ebNHHM6M1mmtuZYCv9hRgIOkNvxHx2SBgalyfmwDZhrfEP9IFSEcEkc4TRnRuPDv Ao0uoh4HYY2as2H7y1J9ab6sbArcrdWg7SaIIeVQhpHhugrq2WkDi3Emdx/CbDhYrVBM D+lPAgyFcDqUpd2x8FeKuRbhvWnEgQaGpZCWhjB7Nwi+rIIhgoiueuPj5VE12UgA0dI0 h3oYYd9MkdE1qfpUX72Aat2uQTVWut57m3OIDEvheqy/KjoG3gPPP9gnWHvbvLTR5cDr N8aKLr3ik3cVQ/ZjSY56pHpzWz4ou7/3bqoVW9jSxs1angf6mLpdQeVnNoc+8EJP1btk NF2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691769523; x=1692374323; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lhePiwzsSx/PL85mddTkFwpXPwkG7Z75k06o+iuXV0A=; b=OiKl+okIEaPOggnOnrWuIxpq9huK6CTCCdndub2YwH1Z5B7CdpIm1FKoObpH8DmRJ1 RHcDU0y0m2RXnjj0eEnv/XxuAFgp7vNRb4HG9VnZdumYXyrx/AifzfwGzCcNuZeC/n5K i10rNdrWDKRWQkUXdeOz3r0jihKeDDiM82se3EIghPXnXhqtGPWDYIN2yLT7ya0A7yqB hzpU89aLo2Wroy+x5w/NNz7oVpboAtP4ryRT2+7h6DNvdXHa8EHSJe/VmmX+vSmz9ceu 9waB4dMg1bB+ji9d7jCu4Yc7I/h3Lw/nwa6gvllCqGiKe9OoZw4CMyRwfR+QzuuzeIFV OcAw== X-Gm-Message-State: AOJu0YxO0gqrbiZQK6AH33OnsOIqki9S+mRD1X5cVGKKY7n3D7/+p9ju Bi98ybnfhJ0xnt5Zp4wS++HEbLovWHa4ADZthXNCHA== X-Received: by 2002:a05:6512:308c:b0:4fe:8c1d:9e7b with SMTP id z12-20020a056512308c00b004fe8c1d9e7bmr2115985lfd.49.1691769522977; Fri, 11 Aug 2023 08:58:42 -0700 (PDT) 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 m12-20020a5d4a0c000000b00317e9c05d35sm5834308wrq.85.2023.08.11.08.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 08:58:42 -0700 (PDT) From: Matthieu Baerts Date: Fri, 11 Aug 2023 17:57:15 +0200 Subject: [PATCH net-next 02/14] mptcp: avoid additional __inet_stream_connect() call MIME-Version: 1.0 Message-Id: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-2-36183269ade8@tessares.net> References: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> In-Reply-To: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3783; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=9Qe781+27wzhv16vF50KO5HsGzkjYeuVU2/sb7jT8+c=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBk1lqv5fFsBgTBTnGPQG9RVKTvL3RVK7VoW1/dY tAt+/hU8biJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZNZarwAKCRD2t4JPQmmg c4sGEADj8+wJ8gLXhu4xLA3eshwVHpAUMPU6fl5G1adbkUaHa4ymSWx/xIIWUFc+BgqfFa4bUHA JZSHhjd5Ui/PTvxdKjznOkZlfpJJrXAke5riO8m2bkSLlAHIyh6YfaeXIZ4BqylD8FjjQi8fu/J Mi7HshwB5pwlR6mPcviJi8hiUV6ha9Txs/2nJ4l0uVpNw9i37VyzWW7N7S6MipOFkCiwmQrpnLo 0Hf69GX16W8QNlyvUxNcBcZr2KilIWTIYAYN/LvyP0TmzCKSAaQqKPqXBRwcDxus7tn3BxmRHig aA4FJPpHoM5XRCz5EtPtH5NNKOWWcUrsTlhiWlfKwcGqdVZwM5yTeD2U/LvEcyC43MMhUsTsBk2 KmM8E+oeTleZtGwTWAuD/dJjtY+KrW86S1iheFW9obk9GQIJNTK8SUzzRBhmF3hdpAZKQlMcNGc KZfbu0kd7uPFy6vaAtDtURGiU1YWRx0GT8SNcl4BxqzalwVQaS3oF0VdQkAE3yE7XC7u3kmDsBG XjrvyAU9j8Au9o0OtUEbvr8FST8dYjQdG8z/il7pD4pHB5FALIw5jnDpXLIFWRf91KIIZZQAQh6 7XwvLCdlTkwdU3yeM4FvlDciFXTqzbUHmjQMzSh+n7cLweyaMLk6p0fdSDg138LeQLLqjXfAewy fztkK3c9TEI9XkQ== 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,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773950742618696462 X-GMAIL-MSGID: 1773950742618696462 From: Paolo Abeni The mptcp protocol maintains an additional socket just to easily invoke a few stream operations on the first subflow. One of them is __inet_stream_connect(). We are going to remove the first subflow socket soon, so avoid the additional indirection via at connect time, calling directly into the sock-level connect() ops. The sk-level connect never return -EINPROGRESS, cleanup the error path accordingly. Additionally, the ssk status on error is always TCP_CLOSE. Avoid unneeded access to the subflow sk state. No functional change intended. Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 49 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index abb310548c37..b888d6339c80 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3589,22 +3589,24 @@ static int mptcp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) struct mptcp_sock *msk = mptcp_sk(sk); struct socket *ssock; int err = -EINVAL; + struct sock *ssk; ssock = __mptcp_nmpc_socket(msk); if (IS_ERR(ssock)) return PTR_ERR(ssock); inet_sk_state_store(sk, TCP_SYN_SENT); - subflow = mptcp_subflow_ctx(ssock->sk); + ssk = msk->first; + subflow = mptcp_subflow_ctx(ssk); #ifdef CONFIG_TCP_MD5SIG /* no MPTCP if MD5SIG is enabled on this socket or we may run out of * TCP option space. */ - if (rcu_access_pointer(tcp_sk(ssock->sk)->md5sig_info)) + if (rcu_access_pointer(tcp_sk(ssk)->md5sig_info)) mptcp_subflow_early_fallback(msk, subflow); #endif - if (subflow->request_mptcp && mptcp_token_new_connect(ssock->sk)) { - MPTCP_INC_STATS(sock_net(ssock->sk), MPTCP_MIB_TOKENFALLBACKINIT); + if (subflow->request_mptcp && mptcp_token_new_connect(ssk)) { + MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_TOKENFALLBACKINIT); mptcp_subflow_early_fallback(msk, subflow); } if (likely(!__mptcp_check_fallback(msk))) @@ -3613,27 +3615,42 @@ static int mptcp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) /* if reaching here via the fastopen/sendmsg path, the caller already * acquired the subflow socket lock, too. */ - if (msk->fastopening) - err = __inet_stream_connect(ssock, uaddr, addr_len, O_NONBLOCK, 1); - else - err = inet_stream_connect(ssock, uaddr, addr_len, O_NONBLOCK); - inet_sk(sk)->defer_connect = inet_sk(ssock->sk)->defer_connect; + if (!msk->fastopening) + lock_sock(ssk); + + /* the following mirrors closely a very small chunk of code from + * __inet_stream_connect() + */ + if (ssk->sk_state != TCP_CLOSE) + goto out; + + if (BPF_CGROUP_PRE_CONNECT_ENABLED(ssk)) { + err = ssk->sk_prot->pre_connect(ssk, uaddr, addr_len); + if (err) + goto out; + } + + err = ssk->sk_prot->connect(ssk, uaddr, addr_len); + if (err < 0) + goto out; + + inet_sk(sk)->defer_connect = inet_sk(ssk)->defer_connect; + +out: + if (!msk->fastopening) + release_sock(ssk); /* on successful connect, the msk state will be moved to established by * subflow_finish_connect() */ - if (unlikely(err && err != -EINPROGRESS)) { + if (unlikely(err)) { /* avoid leaving a dangling token in an unconnected socket */ mptcp_token_destroy(msk); - inet_sk_state_store(sk, inet_sk_state_load(ssock->sk)); + inet_sk_state_store(sk, TCP_CLOSE); return err; } - mptcp_copy_inaddrs(sk, ssock->sk); - - /* silence EINPROGRESS and let the caller inet_stream_connect - * handle the connection in progress - */ + mptcp_copy_inaddrs(sk, ssk); return 0; } From patchwork Fri Aug 11 15:57:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 134607 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1250245vqi; Fri, 11 Aug 2023 10:32:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH1ad2MwGagm1X+3lDCUj3KjBFTZ7gQVeIuIPXyyQFoRxPwnRkY1YuCz2JNYpq1x2BcwkPe X-Received: by 2002:a17:907:7716:b0:99c:5623:a2f1 with SMTP id kw22-20020a170907771600b0099c5623a2f1mr1973085ejc.48.1691775151418; Fri, 11 Aug 2023 10:32:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691775151; cv=none; d=google.com; s=arc-20160816; b=bbL7P4sBHhXphRKcxenlFWSckko5kIUExa9kQMue1DvFLqTCWYPrtg7ZEhu11u7qKC UvuYjMgY3AaiZOg4D78yst99wlqQx7XzkEOkcZqCHd6UlbQuqFbgq01ZpCsA6fr8pbtR 3Zfb47AqjZK1ouuhCxaJR/w4jvcxGr7Lqkdwnl86lM40nI6BJvZlg+pHAqr5Fmg2ioBD a9I9GbZhlTMvybyP3spwxdzWQSzBlAdYYutM2l+a026fkHVJqMh898nEKIq/Feowh5M6 rt5WvqqUD0nZQK/rJdj0FPHGKhiqv0P5Myf/7yO/dcqZMd1o9XY/b8iEnAA59pJgXowW fVkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=v41qzMf6LvZ79BWScnJgfS1EiY59Q4nhSyLXYX9clC8=; fh=01LXX0/E7r2X8N0dkUmDXKtwLjGB7IavRhxV+MLJbog=; b=w0AxYXHV9/I2W+Q5bYLAzb5y2PhBcKK9tVlpVKrDBYpkLNHYwEBkfMim3mhuulmTey xf8t6zzL99Nu2T7vzwlBmecZPbrJXFA7eN3oA8cWm2MpWoXUT2HxJpudObIHfHXxuKD/ ONTV+FxK6L3bbFCDj4QO5RS3XJXrH5XJahqitd381OAwQhTZ9g4qoBdN9V1QaHGByDY6 LKeCYR2fB+xjUyXGAlJlGSFVKUDkkvd013LrE8ZIvlPtCHELqq5NuWOgGe4iubt3puzl vK7+uaYwqTVYeSOj0GwA8gSPjgvSNunEIOqjgmWqMZMGUXU7ewoOAUT32/70CqHrSTNw k01w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=dCpP57fW; 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=REJECT sp=REJECT 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 jp12-20020a170906f74c00b00991dcfb1b07si3778208ejb.962.2023.08.11.10.32.07; Fri, 11 Aug 2023 10:32:31 -0700 (PDT) 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=dCpP57fW; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236709AbjHKP6v (ORCPT + 99 others); Fri, 11 Aug 2023 11:58:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236684AbjHKP6q (ORCPT ); Fri, 11 Aug 2023 11:58:46 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 543E830D4 for ; Fri, 11 Aug 2023 08:58:45 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3fe4a89e7efso18549115e9.3 for ; Fri, 11 Aug 2023 08:58:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1691769524; x=1692374324; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=v41qzMf6LvZ79BWScnJgfS1EiY59Q4nhSyLXYX9clC8=; b=dCpP57fWagMhSfkoq09ZTOyreAAn1Ol4VHCZxHRN1quTTKFwgC5E1TY/3szUZL+Nho bi4MwaKRbxx2jdBAnsIcMtJ/394azV8mlkBhG36GzSzQZ5lKHCYFHypiuKOD1yxm80ZZ hRvJVXtb9dGHvUk8u0sgnWydoFkJ4Y8Qn2NY5WDC4BPJitlQajjAYA9BaAffFNNTduFX dHRpKdIRCekz54EmvfTOlGwds3C06vC2AzPbvBEIwoc9VNypU2VpHoy4clF8101b3udq dOneavoGfDsaA9N8+0BoJSk6B4vRg+W5CKsNwoNmUWG5dCMcVX9ZAcroED7Jv6GVIs9S kZIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691769524; x=1692374324; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v41qzMf6LvZ79BWScnJgfS1EiY59Q4nhSyLXYX9clC8=; b=YxzYzUisNxECr7GSEvYReKxbVREK382OfiMtCjswTtIUmWAANWj9FI9NERzgTUqzQm TEWg3K4bK6NlhujgxYu5h69X6CVDXMf6p6SJdBk5IO5z2bGTaQSpoM+McUn12Tluavgq Z/5olM6UsbybG0tWpq1CJ75v+szK4OOu5LNEJr9NIRo51lqDUSnAqve6z7o++E58C43+ 8r8Ak0NvexqVTZuoi0V3HjbRYJxIWj1H3EHWH/3YDsDHffxs6CluWcpFuMEfsdVnL5fv 7+hV3f0r2vH6DdFZNsMLOclGYq1M+3IyZkmOOMTo8gp+GATc9PrvWG6Qqmejy72ePY3z sEBg== X-Gm-Message-State: AOJu0YxxeR5tnyR24lLTi4LKIrOc4xoMOA+LinXLdOfrTRHK5Vf2qfDX GQE3GuYYmoubZyP/DzBmmYLbsA== X-Received: by 2002:adf:efca:0:b0:314:34dd:aaec with SMTP id i10-20020adfefca000000b0031434ddaaecmr1889820wrp.8.1691769523941; Fri, 11 Aug 2023 08:58:43 -0700 (PDT) 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 m12-20020a5d4a0c000000b00317e9c05d35sm5834308wrq.85.2023.08.11.08.58.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 08:58:43 -0700 (PDT) From: Matthieu Baerts Date: Fri, 11 Aug 2023 17:57:16 +0200 Subject: [PATCH net-next 03/14] mptcp: avoid subflow socket usage in mptcp_get_port() MIME-Version: 1.0 Message-Id: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-3-36183269ade8@tessares.net> References: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> In-Reply-To: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1135; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=qK4HL7ezTejvaB3TjS+CX/NlLTCXy1zfWJooZqvAatM=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBk1lqvLUyKj/mYOz62URiB0KFWHJAuVmboKVIMR 4TcaDRhCOSJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZNZarwAKCRD2t4JPQmmg c8LuD/9b7fcRKlNJsRt+MISnQc+hRMDgQiu+4c5P3Dbqv/qbP8THtVxf4LdUWcBeTeV3dqcJir/ z0fAK/4dEvm08l8ew1OHXViLxS77ybbKIrN4azBbEnDCDnOiJc+7Zetxuwv2Mc2+rthfG8V9uBZ 7tvB8ET48AjFga00QxJd3oH1PE2Rj1r+N22oyH/bFxc2ECrCJZUo+ZUfh9FBhED7UXEIT3yyQbG C3EJCT6WkPKj0ROz7tPh5Zk2iODubNydmNdiKcwmdGrspd5UC3k9b7tkPXngeOZ6mdMDv0Wu5+v ne3eNtzm6rufhdIt1yhMVWUu6QCK9ilhuCo7PPE5KOcvxMm159bpU/il2t9mCWzlj8B9kWW9yKk vcoINOl/nPOZd2SmlVlO+qDhp1fXg5T20Wc8h1E7iGvkKkOLwvQid6Q5ay6KwnMtN0EfoB/bUXO nSYeL5urXLDgrToWfdlL/HXbvdLt9w/0OR4DXeFHRLu98KVQo3x6ngDnXTxJwOEeQYBmJznF+zE 3J4t29u7nqHNjUF06rmss4nPN8o1YHUvMm6vilrRJRM8tqG06B//ajcFqXEYe+G98IOz9Ah3wgl cj6uShv8wlaSvj94mjIdtldrdZcN1/64wQsmS6ByshKqXFkwVv1W8JDXU2NdrlT9cORnrxOiCi2 4R/CJi0KXEXOtvg== 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,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773954821139500286 X-GMAIL-MSGID: 1773954821139500286 From: Paolo Abeni We are going to remove the first subflow socket soon, so avoid accessing it in mptcp_get_port(). Instead, access directly the first subflow sock. Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index b888d6339c80..891f49722263 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3405,14 +3405,12 @@ static void mptcp_unhash(struct sock *sk) static int mptcp_get_port(struct sock *sk, unsigned short snum) { struct mptcp_sock *msk = mptcp_sk(sk); - struct socket *ssock; - ssock = msk->subflow; - pr_debug("msk=%p, subflow=%p", msk, ssock); - if (WARN_ON_ONCE(!ssock)) + pr_debug("msk=%p, ssk=%p", msk, msk->first); + if (WARN_ON_ONCE(!msk->first)) return -EINVAL; - return inet_csk_get_port(ssock->sk, snum); + return inet_csk_get_port(msk->first, snum); } void mptcp_finish_connect(struct sock *ssk) From patchwork Fri Aug 11 15:57:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 134630 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1262564vqi; Fri, 11 Aug 2023 10:58:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEk/DmKlqHmQol9Ot9lnPTdvRyjbpV5N8LhPH+CKBJI+4s7a0u+9P2UXUlNe3D0tJOdxWge X-Received: by 2002:a05:6a20:3ca8:b0:137:a3c9:aa99 with SMTP id b40-20020a056a203ca800b00137a3c9aa99mr2868431pzj.30.1691776702644; Fri, 11 Aug 2023 10:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691776702; cv=none; d=google.com; s=arc-20160816; b=KJJAArRcxUOBz3Ox1TndTVAHqAb0ak5sCh9puCG68yR/FC55BMTiTfzrdZVLYjJgjb RpFC7F0WuhwWRZV6N+WvsjZFQ33IyEN3Vu3Wwu+8Jr311gTu6X1XVaSWN9g5rKzwOl4h 7qGox3RYwXCNrnKveJzw39muzaIydTSEnGBg2CzHdNuEOEa7xFOfMl4soYhpQSO964VV tb5nAgmBWPwG8edzmB86Z+nx4QMlYQLeLPS2dk94EA9wV0s14PgKrgncjPMtXQ7vA/Oz HgImtDhOmbV0PHmX4xMwpc6Dt4e6LTc9s+eFYgWlEM3FJVAXs3+9fdeSXtgdaR5/yMZm aoeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=EwluUaIaFp8xw9bbqeJza0dSEd7d6Y+8KVbDaj+RAU4=; fh=01LXX0/E7r2X8N0dkUmDXKtwLjGB7IavRhxV+MLJbog=; b=tzTIDhQAoL6DDPWySDLjmyMqFrGkyobN4aBKFTc+oLqvE58YLGpa04sOvQBRWKx6w0 v7TtRyqoBTXVgzLcvm/ezPENZCyE0CQqNvqJ9FFHY7qeQ97iavInXSmXFaN978FXdONH CFKwoEU1Rl5nytOIP45ejzDszgJyn7Nh+8MW2Bt0MP0xQIRfbDpejbs4EYwvgax3RGny oL4cJ/KSHi/Wn5GIJ6/bod6+PPBOnK49wx8T3V6UDCmHVu/nlTyT6WHyJ+HdT4w1zvDU I5dSAc8Y1nOa/jmm8KXs44QKYnorwi1ze8atBYoKxiUXYYNIWs6WsuTNlVGVFPpJQdqO 9w7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=RPmoWFEU; 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=REJECT sp=REJECT 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 bz1-20020a056a02060100b00563e28e517fsi4002885pgb.195.2023.08.11.10.58.08; Fri, 11 Aug 2023 10:58:22 -0700 (PDT) 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=RPmoWFEU; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236703AbjHKP64 (ORCPT + 99 others); Fri, 11 Aug 2023 11:58:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236689AbjHKP6q (ORCPT ); Fri, 11 Aug 2023 11:58:46 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F95C30D2 for ; Fri, 11 Aug 2023 08:58:46 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-31759e6a4a1so1781905f8f.3 for ; Fri, 11 Aug 2023 08:58:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1691769525; x=1692374325; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=EwluUaIaFp8xw9bbqeJza0dSEd7d6Y+8KVbDaj+RAU4=; b=RPmoWFEUY34CsBWB1T3YgIpK7QheQyy4afzp1jWMob8P8SIQRh71QllzXtbBnu5ypi 8hFjDnYvAwUeOjangHtczaddwuBagCWIlcyDbCax8XLaMVpJp1lNqfcGtxwBpJXY0lK3 x/bHsUOPFYsvmYLaZv/jhe5on7mnv2jPxhfHlWoO+fxC2jYt0v2XeQeXY+kFM68ChsRJ dCVBBTvuHcHF1dj0TGHrwyqkhkZmqmy16SCK1qseyFHU0T8LXOkR/m9oClhuK93fAde3 bTA348TQfYgGgX+cKiXtf1EF6CgXK/Q6HNB7BCuJCHCEHpLjNZPduLRaWcPWN/Mslx+0 TKtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691769525; x=1692374325; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EwluUaIaFp8xw9bbqeJza0dSEd7d6Y+8KVbDaj+RAU4=; b=FaJA3EK0kNwr8Em22OdlkU5qSSV6LN3pj61yLWcVH9G+W3f2OKv7sGNODxnnOpDRXI PGGSbx+cVHA/OKhW/+SarV+6s8MUmDZW7TnrEqi/58fM+3AqyPa6UUCoH8pQUkwZxQAJ LgdTK75+z0IfSxHA/D7u+VaNEAAwkkvF+7A0Csv9qccVx7cpwGvupmnF7iUFsAMWj4VY +RQS3b4he0LkAjbkRonwIgeZ45L/EqvtIexO43tfWXDqqk7dYV6JGlmLYaBvyHDAI4Pv ONObr+2F1ynIT4NSLXYOIjPNJn9E91PrO4Vaoqs5z/97wgRAtQLy9LR5CcTX13fj74ye Ivcw== X-Gm-Message-State: AOJu0YwD87KSL2gm08HNjSrMrz5lJ5cb0LoRoy6Xv5qYs+v9aSBQcXdf 23RWS7UpyrONcDKaqTpJI1aEKQ== X-Received: by 2002:adf:f042:0:b0:317:15f5:a1ca with SMTP id t2-20020adff042000000b0031715f5a1camr1780613wro.10.1691769524854; Fri, 11 Aug 2023 08:58:44 -0700 (PDT) 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 m12-20020a5d4a0c000000b00317e9c05d35sm5834308wrq.85.2023.08.11.08.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 08:58:44 -0700 (PDT) From: Matthieu Baerts Date: Fri, 11 Aug 2023 17:57:17 +0200 Subject: [PATCH net-next 04/14] net: factor out inet{,6}_bind_sk helpers MIME-Version: 1.0 Message-Id: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-4-36183269ade8@tessares.net> References: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> In-Reply-To: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3806; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=BsYDUl/DUbLVHU4Xpb77aTgJyY+cTGBHLN6ctIYlp+g=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBk1lqvcGmbN1LPAIgSii681NHqkjqbG/PqT7qgh uX2O1Pdu8GJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZNZarwAKCRD2t4JPQmmg c9kDD/9Rkt0oclO8gRzT4WMkWSflZ5DKPreOTVjGK2jDzc+Ey2XwhTDLf34/LzizqyAiyyReo9I RA4Kqa4wLste8hiIZmf69CR8WpBwgjmK4k8S9Awwi4g1Iy/21RbOtqxwcf4HprWrOJhQ/iC363F TKTDGI8YHuSd9TJFB8c1YEz3aNvuD67F4n1KJ8x9V7jRqnSUCUKAFShc0KC5I5dqi86QAvV7sud uPL7+fyUb70hhV3GJMrojHPgQROlTC8fQYTLV4bs2Yf52728rCx/zMS2MbvNxWkCYB310cAnDj+ 2hqxDhyHP6Y0pvsCs4zpXEfq1q9RW52HlM5WBA74Nru9OaLhSQsI7YIiWu09GSIJMFzV0U825vv 09F5P85g/Bo0Lp5lwmKHp20P98IHU5VYzxbd5uaQB1JU9iHX/CDD9w6lWZKScdgfhVk9NMto7S2 zeP15nQrGFzajLSffRNsofkuRKu9DUhvMRSdxdkbTGBHR4Q0qjlvEF4VYgTs1LeZq6+tXwnPT1r Z+Fynw1LmFa+TBv+KsTKA5SUcjPZ5pP3KsBAvVK0H1k7zSQiGM8v4UhTHrcjUxLYkzeIjM22I4Z OxTcbrUNPVKhAJ48mQcQlyx1tL9hONyS1Aiqtcwhm2lkNjEJ0qRLWu+aXtu2sJamxLPglVCaMZV p8BNC20K7enjzJg== 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,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773956447937974983 X-GMAIL-MSGID: 1773956447937974983 From: Paolo Abeni The mptcp protocol maintains an additional socket just to easily invoke a few stream operations on the first subflow. One of them is bind(). Factor out the helpers operating directly on the struct sock, to allow get rid of the above dependency in the next patch without duplicating the existing code. No functional changes intended. Signed-off-by: Paolo Abeni Acked-by: Mat Martineau Signed-off-by: Matthieu Baerts --- include/net/inet_common.h | 1 + include/net/ipv6.h | 1 + net/ipv4/af_inet.c | 8 ++++++-- net/ipv6/af_inet6.c | 10 +++++++--- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/include/net/inet_common.h b/include/net/inet_common.h index b86b8e21de7f..8e97de700991 100644 --- a/include/net/inet_common.h +++ b/include/net/inet_common.h @@ -42,6 +42,7 @@ int inet_shutdown(struct socket *sock, int how); int inet_listen(struct socket *sock, int backlog); void inet_sock_destruct(struct sock *sk); int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len); +int inet_bind_sk(struct sock *sk, struct sockaddr *uaddr, int addr_len); /* Don't allocate port at this moment, defer to connect. */ #define BIND_FORCE_ADDRESS_NO_PORT (1 << 0) /* Grab and release socket lock. */ diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 2acc4c808d45..22643ffc2df8 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -1216,6 +1216,7 @@ void inet6_cleanup_sock(struct sock *sk); void inet6_sock_destruct(struct sock *sk); int inet6_release(struct socket *sock); int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len); +int inet6_bind_sk(struct sock *sk, struct sockaddr *uaddr, int addr_len); int inet6_getname(struct socket *sock, struct sockaddr *uaddr, int peer); int inet6_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 9b2ca2fcc5a1..2fd23437c1d2 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -431,9 +431,8 @@ int inet_release(struct socket *sock) } EXPORT_SYMBOL(inet_release); -int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) +int inet_bind_sk(struct sock *sk, struct sockaddr *uaddr, int addr_len) { - struct sock *sk = sock->sk; u32 flags = BIND_WITH_LOCK; int err; @@ -454,6 +453,11 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) return __inet_bind(sk, uaddr, addr_len, flags); } + +int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) +{ + return inet_bind_sk(sock->sk, uaddr, addr_len); +} EXPORT_SYMBOL(inet_bind); int __inet_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len, diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 9f9c4b838664..3ec0359d5c1f 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c @@ -435,10 +435,8 @@ static int __inet6_bind(struct sock *sk, struct sockaddr *uaddr, int addr_len, goto out; } -/* bind for INET6 API */ -int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) +int inet6_bind_sk(struct sock *sk, struct sockaddr *uaddr, int addr_len) { - struct sock *sk = sock->sk; u32 flags = BIND_WITH_LOCK; const struct proto *prot; int err = 0; @@ -462,6 +460,12 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) return __inet6_bind(sk, uaddr, addr_len, flags); } + +/* bind for INET6 API */ +int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) +{ + return inet6_bind_sk(sock->sk, uaddr, addr_len); +} EXPORT_SYMBOL(inet6_bind); int inet6_release(struct socket *sock) From patchwork Fri Aug 11 15:57:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 134671 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1333061vqi; Fri, 11 Aug 2023 13:17:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxENEfVSyc6UUbH1KDUfUjcrwltkBiLJnB4j5oZokiwVFxG0BVrESidIDagNssnOIH0OCl X-Received: by 2002:a05:6a00:1943:b0:67a:a4d1:e70 with SMTP id s3-20020a056a00194300b0067aa4d10e70mr2928525pfk.16.1691785032031; Fri, 11 Aug 2023 13:17:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691785032; cv=none; d=google.com; s=arc-20160816; b=r9pa9sVqSvbDkSDP9iOMbMAys5PyxnZjivvcGK4XqZSMxLTlvPyRcAOD9GuI5b7T4k PQ254UXJaAh1qzKcR4Js7KC+uI4PjY5o3V1ZVKVYgyrRvt2EiUS/nQ6eikEQkMoWxv6d exqHDEQ6eRKWxCw6pGoxvoyDpRl71ZbA8RFQLYJka0ysw7NCStr0UwQ+KHuayB0Dk/2r xBhwFUL4SbXTSZ1qYLsscIl/RHiD+873FBehGj03ggaa6UHSSKt+p51FHSv0aeKjKYbp 92vsV0F0jAntzQx82NT90o4A94uEmRx0BagqOkGp3bLtnT6P1fqvvsUtBVPnsDOMW7dU lyJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=VXo0sd7SwYNHKnxVFphwOPuJHuje+rAleUnK3N6bXns=; fh=01LXX0/E7r2X8N0dkUmDXKtwLjGB7IavRhxV+MLJbog=; b=NchckKpoKWrXFr5aqWUu2it8X6bzOG//9Fv2YgxlGNByyJA7JJNWdS/s0bAWqlLwOy LwFU4KFzP0vkLtolAUO3otXUXPQAAZZynUO4dR/cMManDvvC5AmNZb14LfahKHhVf6H4 iLHGzMG1vUZQMzEt+0t0ln3p/csuObJ2v+KTol/Z2sgE40Ae+Eh4IFony/AVkRDZsWm+ XZnLQSkRBxlWXFc1PalwOLgHc7aSFfbf6IS6bnG3cI0bh4xwhgv323EKvH8X0UVzktY5 vEbveF974ideIc81OzYBZJPsFSA0qN7foDtom/CrMFNUx9yArKpmlkbG5XYuYTS7q1ay wBQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=13y5vALU; 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=REJECT sp=REJECT 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 o6-20020a056a001bc600b0067ea74ba1fbsi3806142pfw.328.2023.08.11.13.16.53; Fri, 11 Aug 2023 13:17:12 -0700 (PDT) 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=13y5vALU; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236722AbjHKP66 (ORCPT + 99 others); Fri, 11 Aug 2023 11:58:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236693AbjHKP6s (ORCPT ); Fri, 11 Aug 2023 11:58:48 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66C062723 for ; Fri, 11 Aug 2023 08:58:47 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-31956020336so809881f8f.0 for ; Fri, 11 Aug 2023 08:58:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1691769526; x=1692374326; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=VXo0sd7SwYNHKnxVFphwOPuJHuje+rAleUnK3N6bXns=; b=13y5vALU9DW+JJ2uo9mfksvy1dk73siK5uzK8gc4SXHP1eziiEQAFRO1aTUrsZv0jW 6cakbID3ywLC+T/uZ0W+bymrKCy3C7WnFOOCVDNEMlTMc9m4fVIqgMGN4N38p2M3mtI3 SSO8Pdlnd3VH3/aZi5bjADFKUT3Q1HD8gZia2XkI5MVPr+qtBRnWyiGimYv7U6zTQeyW piuCFbEIP6A5yAvUzcm+r8DVdaQ+vvLRvJ6ayoZyKsTTmrqnjosjZ7tbJ9iZWZZ/TnTa NrY9Uz44enNrAfN++CU1qupQJDDrhLxlaB8gab1WaOlj7nVwStKdgpN43mrP/tK1PT6p UNjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691769526; x=1692374326; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VXo0sd7SwYNHKnxVFphwOPuJHuje+rAleUnK3N6bXns=; b=AszfeuNbxPnyVp/FVW1A9bo6rjseB62XAwhQ62Osgid1voBAlLj46xRzA5ZGPJlq+H h0MGsW1FpemvzqJX1AA2hZODxSsrrInTBdnUnQa1TX+8hkHaEjsvJTUNW89rMVdYN0Rd 71OJRYSQE1TFrtBMNuFJ3hQ6SwzXTbELA7f8fa3OpC+jR1FbcGqwk0PO7rtK+k0AxFzp jXXE9GzlkCMuR3rAV8JJGcuVKC775SjDCNyWYkfBRVwv8Nvi8KSDiTFIYW1yKELFzEDn 6dmDtwxOWi7NvmzmSurzAs0/fjfq8t6FHrSPonabGskxkY20BJmHbsgYlgG30+74kMK+ 7W8g== X-Gm-Message-State: AOJu0Yz92otpJpDUlrTCyed5IZXdnkRt4Xc7rySoHsSPLV61iVTCpAf9 10cmFOajcOovEFHiRYDBOFnBL4IGH9kjINyX53BPlg== X-Received: by 2002:adf:d0d2:0:b0:316:fc03:3c66 with SMTP id z18-20020adfd0d2000000b00316fc033c66mr1971213wrh.3.1691769525729; Fri, 11 Aug 2023 08:58:45 -0700 (PDT) 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 m12-20020a5d4a0c000000b00317e9c05d35sm5834308wrq.85.2023.08.11.08.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 08:58:45 -0700 (PDT) From: Matthieu Baerts Date: Fri, 11 Aug 2023 17:57:18 +0200 Subject: [PATCH net-next 05/14] mptcp: mptcp: avoid additional indirection in mptcp_bind() MIME-Version: 1.0 Message-Id: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-5-36183269ade8@tessares.net> References: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> In-Reply-To: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1547; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=cdwy4jZYJOHpcHNPu/Z9TpyfzeGedcmkSzxHG6aP0d4=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBk1lqvp6igb6LLgMw0L0m3fOD5/XhmzXvqIteac rzBRElskEaJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZNZarwAKCRD2t4JPQmmg c11KD/9UokU2haRftpKeotauDl76HX7tCqE3iw4xRk5XJvZkHuq1stH7gm4PN1Yb654o8nk0d4f vOd44O3is3+wImlJijpb/JC4XnDm7UIgPivo49Y/Ffa8oBeF8H3+mZE2jjhZkP46Ah0xNIFd5vK +0ho6WTK9/kxzznIugKjyHu9ILe0Kz40Nfwyu32EKdQrbjk7ho1/lMDxb0YcBADaOfx7KN1uU2j tn5+X2GH9SEk+zLdjmVB0lqeHERql3n4P/Xk6MJ8ajtc+A4PWWNZZ3gz/JJ9asaSWBD8yKzGcfg zN7Zev5BJmqRCb4QFh7RbkFBmFIqOQ5ROrkj/HkVlC5En4uA+g5g6LrbpC5adtjxiaoPKKdSuGN d8kHbKIVwn37lPm0TKU+8zMlqFKglgfCIunqehisK5DLANS5Ryk7XXzTQy36dI33h5pc5PluGbE h20VyHrAQ6wVRiFdkHwuR7rtijtfpxAr/TEn7A8ZnpOIVs6uM4Ia2Lv2P5ktwgO+O/v5mAoxAlj KBTmZ4Uorsbaj7FuTZF8xGHVfwcD9ft3oSlFiqN1ou5eJQkRXp3ZTel3Pq7oIQmFDHlegKTGPZL KXtkHRCYfIIUxz1pnWvZJvjrZ/xrEiU86VoSM2xkGvK2fYQuGPNKOfgXgAuaUxCbWJTTSyB7pR4 ltiVCyO+859qRgw== 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,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773965181797368114 X-GMAIL-MSGID: 1773965181797368114 From: Paolo Abeni We are going to remove the first subflow socket soon, so avoid the additional indirection via at bind() time. Instead call directly the recently introduced helpers on the first subflow sock. Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 891f49722263..5b4d6f0628a7 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3689,22 +3689,29 @@ static struct proto mptcp_prot = { static int mptcp_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) { struct mptcp_sock *msk = mptcp_sk(sock->sk); + struct sock *ssk, *sk = sock->sk; struct socket *ssock; - int err; + int err = -EINVAL; - lock_sock(sock->sk); + lock_sock(sk); ssock = __mptcp_nmpc_socket(msk); if (IS_ERR(ssock)) { err = PTR_ERR(ssock); goto unlock; } - err = READ_ONCE(ssock->ops)->bind(ssock, uaddr, addr_len); + ssk = msk->first; + if (sk->sk_family == AF_INET) + err = inet_bind_sk(ssk, uaddr, addr_len); +#if IS_ENABLED(CONFIG_MPTCP_IPV6) + else if (sk->sk_family == AF_INET6) + err = inet6_bind_sk(ssk, uaddr, addr_len); +#endif if (!err) - mptcp_copy_inaddrs(sock->sk, ssock->sk); + mptcp_copy_inaddrs(sk, ssk); unlock: - release_sock(sock->sk); + release_sock(sk); return err; } From patchwork Fri Aug 11 15:57:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 134582 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1213097vqi; Fri, 11 Aug 2023 09:29:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqGTzCuB7hOiYot7GzjFGph/1Hdgr7kQ11b8HbO2JuzKiz4fKZlCUNe6FDb3X80xP+ELZ5 X-Received: by 2002:a05:6512:3134:b0:4fe:5741:9eb9 with SMTP id p20-20020a056512313400b004fe57419eb9mr1699840lfd.49.1691771394834; Fri, 11 Aug 2023 09:29:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691771394; cv=none; d=google.com; s=arc-20160816; b=1Epbf8b9byhQomFQUMHsxRotl79S9xbR1gzV08cRm7zrISI+YoWnEWW6rBQx78Mjyl RBFlVD8C0E6KkUKcOzrh+4sI5v1e3WSZYEtAma9dU7YFd09pp4xR/aBpJkJSWrAPeJIn GOp6MEX74R/qqlXpsVjbc0JUtl1rsuWyADGi9NwAoDzlJ83bXiaQwKZCjZr7VIAZKTSr z9Z9LR8vHnwQfQF1L8UdKvRUGpsuWzl/WU/aG1XRmVE6bZIZ18WarUpoaOpyUwPLBMUf vvE37NG2wLXZeyclpVzF5FLdeBmoc3LnY8zrH10HgBXThfjwdM0FFGJpZdu49qNrXE6I oFqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=Y1qLyx2LWnWiVDIicSTKWPLIL8cOkrsv9pt//BNBZb0=; fh=01LXX0/E7r2X8N0dkUmDXKtwLjGB7IavRhxV+MLJbog=; b=R9MTpnElh+PzVXLYzffHdkSYoPj9wBdmYmpnYG6OvJXv2beBqsb+xKtQn24ZlArGt8 vfoc9mQJ0okl1XKzs9CH6VPNwrY/QsSxhMrzIbJvrnuaQiQ2A5NTRVhXAuURQxmx8eld hW7TunPR3ELnnv3wlumk9/KEkMOvCkWMUQ4nD8jeW69hvDcmJZge8kB4nxIzLi816mnN o3og1+VRVFiG32FqEiEUc20RjL456ho7w/prSaaQnqsyrr9SIoq3IOm17u/H9wudfQj6 l0kG+tCBQKXijLbNuXNWk8roSybnM9DKryhT2CjyRHFGLxiJQwSbuowcc7A5jvPxDbEV /7IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=5CwpXuyc; 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=REJECT sp=REJECT 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 r15-20020aa7c14f000000b005232e129627si3636516edp.670.2023.08.11.09.29.22; Fri, 11 Aug 2023 09:29:54 -0700 (PDT) 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=5CwpXuyc; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236747AbjHKP7A (ORCPT + 99 others); Fri, 11 Aug 2023 11:59:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236695AbjHKP6s (ORCPT ); Fri, 11 Aug 2023 11:58:48 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E99330CB for ; Fri, 11 Aug 2023 08:58:48 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-317715ec496so1937834f8f.3 for ; Fri, 11 Aug 2023 08:58:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1691769526; x=1692374326; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Y1qLyx2LWnWiVDIicSTKWPLIL8cOkrsv9pt//BNBZb0=; b=5CwpXuyc3e6V3L5gpSouGk49Q1W6jcHqBw2n3JRh5rxeWROc6RP0WMlI3du/myOPmQ puaHwGDQzngqlZqsTSl1AJYZUARvyusyNSZDnqqD1G+WkC9kGhL8KS23G/vKMnSFqtwF F7MlilSG9CMyFf736o5zzpNvtmnNjorFEFiCknqz0CAvpOrI22/K2lxvHZ1CR6j+I2+t yBytN7X3CaMJrgOdnRU2O2C22RMQItsSHTeRNPSD0lvTGaiImWpKjiAnX20Hp52EsKSY 3DaEGNExNcg6Z7Vlnqz+wkuSz9nMG/BL4BntoOh1gFyKMzX2YJIMAH4O1xD/GWyWse9y j+Qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691769526; x=1692374326; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y1qLyx2LWnWiVDIicSTKWPLIL8cOkrsv9pt//BNBZb0=; b=RVCgdpIvOpKBmn7tjsxeoxSEx5mP55zaLWNSdD3ZGj4BROgMa6JojZotER1Bkt1RMn UuFH4iLHW8Ma2x+NtfqmyGs6MKXWs/1TdVftOFCrD/O6vq9hazT4XtKACcBzJhfYArVZ zh450ZOhy/URiUp12yLtY/bF8L2EciSzUVOK3Z+OkXOjOrcH1stYZElMCYM/+h+g43Al d+u5MkMF0ZLL3y6jg3LAF61mniSXaBqk2KXCLSU5qFeXXsQEZBJBQvBG39J4i9TCwgz7 vUO1Eg4ZqG7l8PR+JdOeQdKl1u5o69y8dImOW7Of4cavd1+o+/bfSaiA1D0rrRS5ux3T GQmw== X-Gm-Message-State: AOJu0YyoHCO3pzbZh/zAJJj4lj0P5m7vjRT345q2KF/WAhjGKzMX8qID tweGebPodUucxlQ9ZYrkgdxM5imSxx7x1FLcm4U7DQ== X-Received: by 2002:a5d:4ecf:0:b0:317:5f04:bc00 with SMTP id s15-20020a5d4ecf000000b003175f04bc00mr1863528wrv.27.1691769526605; Fri, 11 Aug 2023 08:58:46 -0700 (PDT) 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 m12-20020a5d4a0c000000b00317e9c05d35sm5834308wrq.85.2023.08.11.08.58.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 08:58:46 -0700 (PDT) From: Matthieu Baerts Date: Fri, 11 Aug 2023 17:57:19 +0200 Subject: [PATCH net-next 06/14] net: factor out __inet_listen_sk() helper MIME-Version: 1.0 Message-Id: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-6-36183269ade8@tessares.net> References: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> In-Reply-To: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2806; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=bTkRYVwJ7Bz5xqxHF7Zx1jU11iINDUJMHCOsJN7EE2Q=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBk1lqvWJ+40gT5DCRm0wzA6GWW71En1AJiVIL0q cyGXtBLMdWJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZNZarwAKCRD2t4JPQmmg c5E8EACO1BlTw3jWXRxMGk/AGNAJ7LKBgy2u6pKDc2BZIqqPhyn6pLcNgjgTXPkhX5zmfRAUkjf 2H2t2dQ7K2uYYZaCEbHDQgyD8CXdVZbJGXgt/oOY59A6QeBNd0ZMsp5PcFv0hhnGgHp5On4nume 7zQt1bR3lJBlXN2t6pFywGTU8LuMn+bakwUL8yv3rK0OfPRfhmjpkB2koU0MsvifsZt8a2JY1Fy vH6A6mQ8NVO6NOpcQhIFJHYODBvCOz9e7z5l7l7woFiZ7Yp7GTI5qY7CKvWk7pdexEC9M7Fph9M 2akdXXS50JCWa77DG5ox2ae+Ud/hASytOKywNgXRZm5vS/3IJxsOpDpFxRAq/9C0pf1hHmDPsrC Ip7l70RMDt9bXvYsKCESV7EZpL3Uv/CvIRH06FUjngzMLZ+/kWZVRDJtWUgUpVK6+pxMSg9dD8Z DVc+Id57OLi/QXArLKIVja84CNuwy5AK3IdL9im85QqqDNVXT3C4td4aaeS6KP7mUWxvTeCfRzR 5Mdv1YvILBTAqgV0kFvcisFNzZZ8QRHrxWx2FOm1X9Y8tJ0cLYROhjJprdMtz7lMWa1aytvSGo8 R0XhXB9M/Y31n9yFOzHHpCHNits6YehkcrYWjz9Q2Nuyem1eaYlP+9NfxNNS6rnw4XzLJbFNsEl uEXsD8ZExbvWA9Q== 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,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773950881957875180 X-GMAIL-MSGID: 1773950881957875180 From: Paolo Abeni The mptcp protocol maintains an additional socket just to easily invoke a few stream operations on the first subflow. One of them is inet_listen(). Factor out an helper operating directly on the (locked) struct sock, to allow get rid of the above dependency in the next patch without duplicating the existing code. No functional changes intended. Signed-off-by: Paolo Abeni Acked-by: Mat Martineau Signed-off-by: Matthieu Baerts --- include/net/inet_common.h | 1 + net/ipv4/af_inet.c | 38 ++++++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/include/net/inet_common.h b/include/net/inet_common.h index 8e97de700991..f50a644d87a9 100644 --- a/include/net/inet_common.h +++ b/include/net/inet_common.h @@ -40,6 +40,7 @@ int inet_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, int flags); int inet_shutdown(struct socket *sock, int how); int inet_listen(struct socket *sock, int backlog); +int __inet_listen_sk(struct sock *sk, int backlog); void inet_sock_destruct(struct sock *sk); int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len); int inet_bind_sk(struct sock *sk, struct sockaddr *uaddr, int addr_len); diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 2fd23437c1d2..c59da65f19d2 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -187,24 +187,13 @@ static int inet_autobind(struct sock *sk) return 0; } -/* - * Move a socket into listening state. - */ -int inet_listen(struct socket *sock, int backlog) +int __inet_listen_sk(struct sock *sk, int backlog) { - struct sock *sk = sock->sk; - unsigned char old_state; + unsigned char old_state = sk->sk_state; int err, tcp_fastopen; - lock_sock(sk); - - err = -EINVAL; - if (sock->state != SS_UNCONNECTED || sock->type != SOCK_STREAM) - goto out; - - old_state = sk->sk_state; if (!((1 << old_state) & (TCPF_CLOSE | TCPF_LISTEN))) - goto out; + return -EINVAL; WRITE_ONCE(sk->sk_max_ack_backlog, backlog); /* Really, if the socket is already in listen state @@ -227,10 +216,27 @@ int inet_listen(struct socket *sock, int backlog) err = inet_csk_listen_start(sk); if (err) - goto out; + return err; + tcp_call_bpf(sk, BPF_SOCK_OPS_TCP_LISTEN_CB, 0, NULL); } - err = 0; + return 0; +} + +/* + * Move a socket into listening state. + */ +int inet_listen(struct socket *sock, int backlog) +{ + struct sock *sk = sock->sk; + int err = -EINVAL; + + lock_sock(sk); + + if (sock->state != SS_UNCONNECTED || sock->type != SOCK_STREAM) + goto out; + + err = __inet_listen_sk(sk, backlog); out: release_sock(sk); From patchwork Fri Aug 11 15:57:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 134601 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1229184vqi; Fri, 11 Aug 2023 09:58:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhyuTjItEVGVBb43+jdv+DjYk3+2LyFzzzgvXU/Wz0KCxtE1Eg6AqSloeIRxkE9OBMhLvA X-Received: by 2002:a17:906:3013:b0:992:91ce:4508 with SMTP id 19-20020a170906301300b0099291ce4508mr2338533ejz.53.1691773110861; Fri, 11 Aug 2023 09:58:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691773110; cv=none; d=google.com; s=arc-20160816; b=QlqGOgklMZe8X7rI3+N9IbqGIhzKLGkAhaxxBaOw/AIwxFCnm9aqrPkG2f3q0Pio87 clZ9YmFiEG7KH70R7C59rdEOr+biXtn3WDAcvlB1han+ZV/ZWUExosadIwvf3aV39ufE ayhncShEXX1dR2HOV3BFc6lcqzvDztqrAahSNPnLcMaLhcMDXHsptw2+lR1GfZKh1vq9 lv8zYBgQfvDKBVLmbxWyWG26z3r1ZGHfe/ruonHq0vub7K6xOFvjuvdMFdH+Lu+Rswnz Eu1zHWAU454GIeZiYLnrq/ZkvOyoa+lpiGuZfZMotgU7NufrGL7o3RmH5t/2sdz10cgr t/9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=EyRx/lqS+isYchr9XgPLMFHBFRIijA0curLoMvnrLXI=; fh=01LXX0/E7r2X8N0dkUmDXKtwLjGB7IavRhxV+MLJbog=; b=R1hxcvTJntAmhrbKcHSZvQ3OxijN8U6nLSVYV6HOmawRbUdyigAmfcuhhTVdseEKJJ L6yVQtkakdyXNdKEEnV8pekKGWxJwlyZ6x3nELSXYuUpXBaLN2APhhP5JM3fNAVdhqPt 9w6kohPI3nvvNSoS0pfejdLL8d+Js5ePRNCQo8pCHKQOOsIUJIFlauvxVaiYc2M6w6lb JNlEDX+HzuyG2Uw2Fm+w2FMK12RFkFyEIs6LaSJ9IMtJbyCoTkXHuJ0QhMvcOLOBeKiE ZJNgJxtrbD46HXM5rkRa2s/KJtBWJhyOofMB9AmaiyGGc4L/UloNBFTZ4Chtj5Jv++0l fJUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=A4x7JHBF; 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=REJECT sp=REJECT 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 pv14-20020a170907208e00b00992bbdebdbesi3183885ejb.785.2023.08.11.09.58.06; Fri, 11 Aug 2023 09:58:30 -0700 (PDT) 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=A4x7JHBF; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236757AbjHKP7C (ORCPT + 99 others); Fri, 11 Aug 2023 11:59:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236704AbjHKP6t (ORCPT ); Fri, 11 Aug 2023 11:58:49 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0765530D4 for ; Fri, 11 Aug 2023 08:58:49 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-31963263938so355681f8f.2 for ; Fri, 11 Aug 2023 08:58:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1691769527; x=1692374327; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=EyRx/lqS+isYchr9XgPLMFHBFRIijA0curLoMvnrLXI=; b=A4x7JHBFtN/v8rQSnnmwXaQxQTM977zx8b5onDqAtC+l9kHCtn/C8+sQOS8LRmmfgR d1DCu1MVk4eeOTT9Q4gsBGPdbSEOvESuLPp0Q2NQJN/7Eg/EkPG87mrn4lFVIrN2q1qk vFxh+WcOIlgOVs2nkW24Y9a1Qg4/y6nr5isopIgjw74w5mQabIO1LHWXoDVqgAOraLlU lgbJos7nlJM4hpQXti3OzEvwtX+X+sE5V4gHyn5/wEB65e2jFrucBCuyVVZja7IVSEE2 oS0QSjgnoeOTfoL0+J23cW5hS+q0Q2WJmKFNMaYM42XWJ1UKxNDyU6UcaspQx/xWGQYp HmLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691769527; x=1692374327; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EyRx/lqS+isYchr9XgPLMFHBFRIijA0curLoMvnrLXI=; b=ZxrvYHxe5x0Ke8UQo8ECxrQOtUrfV8oQZC75s3jiZB7FEt5orhNiFa4LEqiOzbPeqC zO4tNABVuHkVi4rAluNGGZrdFebAj+Kmbrr1wpJCq0QqY3AooRzKkDLwWR1+qrNRuvJO vCqXmjUUJljWpH14wNbnrmHz3T3gKDSD49x5J0cjtkSWUncwDTUSedgxVp8TrX2ANI+A EhLQrNQNVnCMjbFRrwq1mfyE+RoiPwbw2QqtJJZTj9Bv/MEe/3b8iHibYJ11vDGi3P36 C2lYLYR6KAyjdYPG9/oZ4T0qrzdHj5r9verywfcAnirsFRbABQdO2b5IFXDyaHV/6Afc Qmcw== X-Gm-Message-State: AOJu0YwdJ3SpEQtpcwXXEH6uq1GR5RZhA9ATZLcnk89vO7eZ3xgvS4Nr tVTiJAsazyX4u6g65No+pRqx2Q== X-Received: by 2002:adf:fcce:0:b0:316:fc63:dfed with SMTP id f14-20020adffcce000000b00316fc63dfedmr1705179wrs.39.1691769527592; Fri, 11 Aug 2023 08:58:47 -0700 (PDT) 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 m12-20020a5d4a0c000000b00317e9c05d35sm5834308wrq.85.2023.08.11.08.58.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 08:58:47 -0700 (PDT) From: Matthieu Baerts Date: Fri, 11 Aug 2023 17:57:20 +0200 Subject: [PATCH net-next 07/14] mptcp: avoid additional indirection in mptcp_listen() MIME-Version: 1.0 Message-Id: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-7-36183269ade8@tessares.net> References: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> In-Reply-To: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1668; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=uGv0GZryGFtqDT83EYsbNMTqvKrHGPnUvPWP7zmvWRc=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBk1lqvJSlkomXuEhk3T8qOlOZZYYOSwumgYgTcj lJMdiQ9JlmJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZNZarwAKCRD2t4JPQmmg c0SQD/9RvknM07vU2B7bycJBkHsghFJbpbcj/egc4zS2Q4FbOtFZ+n4uytsZjFaFu0fEXHdmwM4 fF75/DI2RsOcGg8d4Nu0RGM8yRu8gPBRZQIC+H45/7ld2tN6qZsSBd8ZAnxhlX2z4N0KuKaV5J7 u5EdlH5ubNE3tvGauOZzlaSDhugejcC9fSmjDz6sOxirfdGIrJKrftVKU3JekZJQMGW65B8kZYG gcM5+lUWNoNT/91bH7ti6qe4rcP8fxMTzX9OTflHVmM+DqWuZ/iO41mCrnVu6RgZBqhrnRiLveX CqP3x2VJBgzSHAfXaz9caEESzKNm+GKtJcXlfbMaPtqpYmB69rI+jU+eGrOe6fIozUw/3HN85pT Rrvp9jjK6CDlb1CRXIRgV3S7Pn7pwSnYayeRN0m2Eu7izBY4VCzI1GH3Rice8+oljgIp4tmxfYO EJ74fsybfqn7ARd7WSs0jIqJ/zNA74edhHrm5FUSMKGG1F9rUQimn3BN6DZpm9YMd46vwDXr43S bM/QR1Q1QxZB4rgdGoJbR460fXqhD36Yq8ldZH5P9edz8ze5ZgfcGxBxGei//TEUwKvZx2O6Q8Q QJiGDSkqYnJxlMvJMNJxkOizkDt7+zGPbtl4LAyqwzNVUt2IjMTBdbew5hj6ZhrenvBcqFf2tqd Q601hSoSt8x2g5Q== 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,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773952681650811616 X-GMAIL-MSGID: 1773952681650811616 From: Paolo Abeni We are going to remove the first subflow socket soon, so avoid the additional indirection via at listen() time. Instead call directly the recently introduced helper on the first subflow sock. No functional changes intended. Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 5b4d6f0628a7..d8b75fbc4f24 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3720,6 +3720,7 @@ static int mptcp_listen(struct socket *sock, int backlog) struct mptcp_sock *msk = mptcp_sk(sock->sk); struct sock *sk = sock->sk; struct socket *ssock; + struct sock *ssk; int err; pr_debug("msk=%p", msk); @@ -3736,15 +3737,19 @@ static int mptcp_listen(struct socket *sock, int backlog) goto unlock; } + ssk = msk->first; inet_sk_state_store(sk, TCP_LISTEN); sock_set_flag(sk, SOCK_RCU_FREE); - err = READ_ONCE(ssock->ops)->listen(ssock, backlog); - inet_sk_state_store(sk, inet_sk_state_load(ssock->sk)); + lock_sock(ssk); + err = __inet_listen_sk(ssk, backlog); + release_sock(ssk); + inet_sk_state_store(sk, inet_sk_state_load(ssk)); + if (!err) { sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); - mptcp_copy_inaddrs(sk, ssock->sk); - mptcp_event_pm_listener(ssock->sk, MPTCP_EVENT_LISTENER_CREATED); + mptcp_copy_inaddrs(sk, ssk); + mptcp_event_pm_listener(ssk, MPTCP_EVENT_LISTENER_CREATED); } unlock: From patchwork Fri Aug 11 15:57:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 134629 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1262258vqi; Fri, 11 Aug 2023 10:57:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGydFwrcJcoZEYGw+83LEF4QJW3dpJkPo4YHSrpX28WAvPZ9kfJ73xTrJvcjxtGzQ+g6eks X-Received: by 2002:a17:902:ea0c:b0:1b2:1b22:196 with SMTP id s12-20020a170902ea0c00b001b21b220196mr3046971plg.48.1691776664229; Fri, 11 Aug 2023 10:57:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691776664; cv=none; d=google.com; s=arc-20160816; b=riZN37VJrnObDfHOs5xOfXZIvr3gev5XXasNNAQpJiNSpG2WQFi65qtWXSrrvIAfWV eUh5705TMf73LDO1plYqiNtPZxTRtLTu9vQjT1gsLlXzzPI6nMUaVpn8GbjrfF/tOys/ /P64cOu/IpmYkGiBLMXjFkrYPf7pqWzRlgngCfrcpN0RGW6lF2rKVGzvL5HQ4Ewx+VtD UMzT/atqdr5cx5P6jKQmbSz4OMtnc86mZSFt/2XmvYADQEm483hw15MNfMziW+E6i/0q PFP5FDQxR5ijpiJC/bh6XrnXSf1DYST5NCoYaYaRtLkrC5ij53CxunEN55L+17kF3A42 taVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=0e3CJJrqZ7ewmH2P5w0S/0zIFsn4QxREbiOM6aZrWvM=; fh=01LXX0/E7r2X8N0dkUmDXKtwLjGB7IavRhxV+MLJbog=; b=WZBf4Vo2jdhAwykC0ymmqJjP5r/t7grlo4yZnio+sq2vTjCCBDPhOHRGxLwyLS+wHG 5iz9hQyk5XdNEfYE97OTr6v8H8Q9u9qWIsNKLuTPmy23U+IBFgVmb76o/r3ZBeUtLnYC Xh5ulDw22IveY/NVK8kYpJjkkTXdUMFy6QTJTxAR4XH7pitKjWy0fNdU5VFLEHsK4QFN luGhORNheb3TKZOlBIfNMxTbLNBITEHwDFPjYoiDy97x/3sjTnOpJld0Om4cgqI3I1TU NGIz+S/kjE9I4FD2lEVR4G/BwNVVxIH6cDorWOFt+h8FtAR4ZcgMmsJ9v0tyNgpys2hd 3jPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=lX+Ys8CL; 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=REJECT sp=REJECT 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 d11-20020a170902654b00b001bb8a57d518si3513470pln.379.2023.08.11.10.57.30; Fri, 11 Aug 2023 10:57:44 -0700 (PDT) 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=lX+Ys8CL; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236764AbjHKP7E (ORCPT + 99 others); Fri, 11 Aug 2023 11:59:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236712AbjHKP6z (ORCPT ); Fri, 11 Aug 2023 11:58:55 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38F9230DA for ; Fri, 11 Aug 2023 08:58:50 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-307d20548adso1921832f8f.0 for ; Fri, 11 Aug 2023 08:58:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1691769529; x=1692374329; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=0e3CJJrqZ7ewmH2P5w0S/0zIFsn4QxREbiOM6aZrWvM=; b=lX+Ys8CLIATfx0LJtFzeLQ0ERTTrxPkesrFPMmBBNHN86jFrD5P1lfm+ZuIU+kAt7e BKBApd8RB4H0cU1jcFTrQziVbtFXdP1duoGwh18rf/io955LcWi7us/52WSQe7pFxdrN EJwVzpvtfkWkZnUNNLZTu/xoWO5mMB33a6uemnlGsaUvGomWxdXoxtP0zmFEhhokvjCV j/sqlOHXHII4646BvzRoTJ5hcYJbNMEgjwc+ULaarg5W/hYVGjbZHwIv/en9my3r/+zp yt5LVvVLIh5SJ7x/IeBaD3TVW7tdwEaGCfOtSkZAIktPoya9afYeSPdirqU9498B2Sl3 IoDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691769529; x=1692374329; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0e3CJJrqZ7ewmH2P5w0S/0zIFsn4QxREbiOM6aZrWvM=; b=ANlfU06FY5PqYcwE+g9dtwMsVkjOomqtz9aVkKOaT2mp49CaPAyNbzKcmUN/yEJlSs A/n6FitHADjbeR86ww005YkEpiNq48wpoLAmsLDNoG45cMY34K/ec/m8G11XSGhb2Z/b ljCL/++t5i/O92Zg/orrmW4uuetb0QyP46rK8FstPjxzC7T6FM8Y+B7vaO4ztG87fcFn ZkPGFCy6mwZ3InXZLaOFVDs7WaUFTTNuTGrFzUkwIUJlpXAK0HlllP4YQkm0q8lPUJLX rt6b3eckAMJ2jfWtwztdS9nj4CNaEYBP5EemOuvwqlrg9M3xeJnBpI9BzLyhO17oABkf Q0xA== X-Gm-Message-State: AOJu0YwcE7zaeuIhNWyT2HVv9u0KFcelNvwqgf7iRpHuFPNkPoeOinNm ME6RwOeNK0nPuZyHADXxW/om4Q== X-Received: by 2002:a5d:438a:0:b0:30f:c5b1:23ef with SMTP id i10-20020a5d438a000000b0030fc5b123efmr1642236wrq.41.1691769528840; Fri, 11 Aug 2023 08:58:48 -0700 (PDT) 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 m12-20020a5d4a0c000000b00317e9c05d35sm5834308wrq.85.2023.08.11.08.58.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 08:58:48 -0700 (PDT) From: Matthieu Baerts Date: Fri, 11 Aug 2023 17:57:21 +0200 Subject: [PATCH net-next 08/14] mptcp: avoid additional indirection in mptcp_poll() MIME-Version: 1.0 Message-Id: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-8-36183269ade8@tessares.net> References: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> In-Reply-To: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1163; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=J9VNeffJDPfkoJa+eIaJ2TO+2VxqSncVcduqI3h44xQ=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBk1lqvfhQYxdq5nUH4ZAoej7J8+p2L5Lmk3Y0Jp 4uaCRiefWOJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZNZarwAKCRD2t4JPQmmg c8j2D/4z5s9NgjC9q7QH5Jp/JvDdZkfDO89mpDeftND2ALbI0xuUPpP/N2wmHEm9wtubG3ZWDPP 1YHwLOswxY4RhycdjJc8NMo3j/IqTpCtz/hTNXmOdReLcv1BiuIERObu7456c46NuhYZbG2fepu j1sOGlUnf6LxHPb4MLyWv5PtU90T+gL+MQFyQr4j+uumiM719nFQm+yB7j7ULl08oD/x1ZjRdy1 BD8Sci4RpOCJJYZ5JK3/Ms6H1NOPsULBbPGoaVJks9OsFpEMwky9aPPlpDsQOQAfKVlkLp1mMZz UH4zdwDsJIhMC1USzsgCLBM7TZIu3lckmH6QikfyD1nJ/6R7G4jE2u3zJC6uqLWx8EJo74mfqUu hakjOElfGBTXTXCBLIDoBFJTDBEFspHXFtzxztgMGB7mDZIUJ2RcUwn4K8r1t7zBK2GhLfxQrNL mUHr3pJ/m/h4UuJvc9cyK4DHp6gN7PF/bRO+Kg0ZCTEp2zdoi8UEi24lqRRVZfJhVd2QR+1ueuK JZhzQl2UjPNt+UW6kN0DcNIgcIaBi+1T4l1O1zyx8jGXfyHkfC1GQ0DZe8C42hOD9d5//IZqhV+ T9uAVSAVqZXlJ1unylAdRkJ1lgXkkuRnOri0iROXZx/wK//VK6iWZodcb2jhuj2NaYq/xZr2oAq Q0T1caiGXyTPi4g== 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,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773956407332679709 X-GMAIL-MSGID: 1773956407332679709 From: Paolo Abeni We are going to remove the first subflow socket soon, so avoid the additional indirection at poll() time. Instead access directly the first subflow sock. No functional changes intended. Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index d8b75fbc4f24..e89d1bf44f77 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3844,12 +3844,12 @@ static __poll_t mptcp_poll(struct file *file, struct socket *sock, state = inet_sk_state_load(sk); pr_debug("msk=%p state=%d flags=%lx", msk, state, msk->flags); if (state == TCP_LISTEN) { - struct socket *ssock = READ_ONCE(msk->subflow); + struct sock *ssk = READ_ONCE(msk->first); - if (WARN_ON_ONCE(!ssock || !ssock->sk)) + if (WARN_ON_ONCE(!ssk)) return 0; - return inet_csk_listen_poll(ssock->sk); + return inet_csk_listen_poll(ssk); } shutdown = READ_ONCE(sk->sk_shutdown); From patchwork Fri Aug 11 15:57:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 134591 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1222425vqi; Fri, 11 Aug 2023 09:45:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEK4NjLWPg66xT2QTMf2oNeDPuWnURjxOFKCFfW+HTUcnAYRCFRC+EnITjsg3Zjqd2Qqkcc X-Received: by 2002:a05:6a00:198c:b0:67e:bf65:ae61 with SMTP id d12-20020a056a00198c00b0067ebf65ae61mr2557819pfl.28.1691772347408; Fri, 11 Aug 2023 09:45:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691772347; cv=none; d=google.com; s=arc-20160816; b=G2HtHxZu+pyVza8YhL3sjQHpHj2dbTi6N5JFVsP3XuNzImaxwfWlH9ACBkECfvYYvv s5C6rm64GVCF8rKWmm6uHrPzW6GOqCFqYCoBKYvhHFRsJzXYzwtCXoDX4rPgapLqJbDw S4PM5yvSbTAOQ+fk1lExl4S3PQF7xqhjugULJ2Rtspgn/qFdHH9bYyD+sMVAhKNGQ7+y t1hIAo43HPLxXbHKdDK4Ny8OaCZphnHOs3UocHIe8yp9OrwzhsflSRcedee6P6dTSy7Z 1fwLTaAUnYl1gSy7Hsw3vpL1/HtPak46IpKlvVigSQrX62O9lJJSkWVXZUJCubW0Ao++ w3AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=8p7hz56BvINY3bYnl+8763aXFv1bqlZKj1UXcfxTM+A=; fh=01LXX0/E7r2X8N0dkUmDXKtwLjGB7IavRhxV+MLJbog=; b=AYlKDwz12znDSnXoz04xyHIz4ooy92uC8Fsxsz7aLAGIJwa0oPxlCVg4A1czkGDfn5 u6RlZ6BC/vTl87iqAsOh2xliwiSUcxwsD1k+vTvfLyxapQvcVE6GBnhL/FOgspbVp82H mGi7lwjOcKEiZsPf1IOZzdrECsqQsItHyAhJLjphH9mkRtL9yTTxHJs2hfURxt5oF/U9 YmEf3xeMnoTPLF3KoeEk6kaJ89liWs1hjXi7/YCNlOYpWRSbiOX5dbTvHy0EWagmJEqP MNPe9qyQLoio4IiMIlbQsSpYpXNgeFAhDncMjCkEV2vsv+MewhrIjdOAdSyZa+qXKizh dvFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=a1cUMQYv; 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=REJECT sp=REJECT 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 bz1-20020a056a02060100b00563e28e517fsi3928163pgb.195.2023.08.11.09.45.30; Fri, 11 Aug 2023 09:45:47 -0700 (PDT) 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=a1cUMQYv; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236780AbjHKP7I (ORCPT + 99 others); Fri, 11 Aug 2023 11:59:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236716AbjHKP6z (ORCPT ); Fri, 11 Aug 2023 11:58:55 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C5BF30DD for ; Fri, 11 Aug 2023 08:58:51 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3fbea14706eso18726295e9.2 for ; Fri, 11 Aug 2023 08:58:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1691769530; x=1692374330; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=8p7hz56BvINY3bYnl+8763aXFv1bqlZKj1UXcfxTM+A=; b=a1cUMQYvxGodmKZuN0U3paq8749qJLSolfZfU9LZW7mhsN12u/vcKYlNfVEvpeKua/ RSmJgd1SNHQdt4lIQsjrfenFY/IX2BrdTWGD9BQ80j3g4WZXiX6YQj6gNAsjrvPGxjes Ufmxo0b5XJenWZ4KJy/ajW8xU1VBSu9ujiwUAnGHkMiQw1VKWzyrxvlPjAVgRhPZpQwB 7aI+LtZOe2SUU61zO8ayLhK9z8ypD6Dw92oKbTg3/Tz9zf0rPFFTAT3sSuyEhIrJ5yyj E9sVzAsk3NTtBt5FEUTwRnB+1Hv5aujTj6AcCwU2IQrpWI3xPO/BYBbDQhzvpFMouPB7 PtcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691769530; x=1692374330; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8p7hz56BvINY3bYnl+8763aXFv1bqlZKj1UXcfxTM+A=; b=NAeN6RzjHPBCqYFOXuFsbkImONrsBvyw4ZA86iqoZYVUTuK0l+QB92K+I57GheI+A/ ZrZYMGibFWLkrakI4Pqy+B1tq9HrfVMoLnxeLZt+Jj2EjKwzLQR8iJH5NHFHD64gD67h u3m3bnUMW5kJg3jEuOCNByf1pucoKzcw4eoShP5ZUfUItbhGHbfNhn2zKRrCoLE8KEJW +sVYpZ++4LZDlYvm6aX5bszFbj/ibAYEuJpYYF4CdTDTihIP8/zsHhOLEIuXS4t71pey IbckARitN1F0kHa9HLU8C2o9uFvPP4nomZ0qUSPFdc35+CAlVXQBcP4Imc7o6OMKYsDf /oJg== X-Gm-Message-State: AOJu0YyVKCJcSowEqRKVLkI46kbrdvswASmqrXkIOCW5HadJghT632QW vG00JTUtaCu/G3nCkvKZb3gATg== X-Received: by 2002:adf:db02:0:b0:317:6262:87af with SMTP id s2-20020adfdb02000000b00317626287afmr1780157wri.16.1691769530265; Fri, 11 Aug 2023 08:58:50 -0700 (PDT) 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 m12-20020a5d4a0c000000b00317e9c05d35sm5834308wrq.85.2023.08.11.08.58.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 08:58:49 -0700 (PDT) From: Matthieu Baerts Date: Fri, 11 Aug 2023 17:57:22 +0200 Subject: [PATCH net-next 09/14] mptcp: avoid unneeded indirection in mptcp_stream_accept() MIME-Version: 1.0 Message-Id: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-9-36183269ade8@tessares.net> References: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> In-Reply-To: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3045; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=ezLN5rJDn0TKO1JLa8QX3XwohNG5LslqBliGtaEoxsw=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBk1lqv/lFxB/q1xOo6Csx0Xdq2xu9hotDvV06g3 sPqycFbHI6JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZNZarwAKCRD2t4JPQmmg c282D/0YBufkFft2xSGrrVTQKpXzWqy831F4wJMr0YYiSFFjo6t89EoMlCfqAA6Hi7PhgT8zjre lZ7XLHyFEoqT0kcRbZkRecPf6ufbznmbi0DSXRLLtW1T5yZCx+MSgGL+nddqIr+j7d5p8JLYWIC Uj9v5uObKodFM3Zc9KlK/aqJ0Wlti5is16ableDYRk+6u7QzLJVt6UUOgiAgDs3mNA/VCHoysOU 78L2m/REztuWfSsDwmNcl4dEsNn6nLfxo6uUJALQOR6NEVtrrhy8zBiWjBWGGS4swP7++luhdhN mUpnMYiCzxyx4rACw7tho5c5ruF+IrFkDBgwrm5B6s9FrvsC+ZqX//AB2dIbKVOXJSdjBOqwrVO JDLQBk06QM8GZiZVzI5+UZCfgsZwI3TTlRZJk1LrrxYCnSpLtvBOp6srC1V33iqUFaaqmESfHgn PgPRj4tqPwo/n53/etr+/FGO3B3HvatVudlgHJffISYDreLC44waaztHUMOFs4JraTim70bq5UE 4qCXED30ysbD0zbBVYxnMFYFmmkH2Ig2niuukH761p5M86YFa9lrS8Ae0CwsSosY35YYfw3H9+1 wH2Z9UUn5XiW//D8W7VJVz0Y9ACfBHxuBioJy5pqdJluWqf5E5Lr1rvE09vbUjkSd1pmOgzOEOI pJJ2zxuw4QcPZhQ== 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,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773951881101141386 X-GMAIL-MSGID: 1773951881101141386 From: Paolo Abeni We are going to remove the first subflow socket soon, so avoid the additional indirection at accept() time. Instead access directly the first subflow sock, and update mptcp_accept() to operate on it. This allows dropping a duplicated check in mptcp_accept(). No functional changes intended. Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index e89d1bf44f77..e5ebd170d316 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3174,25 +3174,17 @@ void mptcp_rcv_space_init(struct mptcp_sock *msk, const struct sock *ssk) WRITE_ONCE(msk->wnd_end, msk->snd_nxt + tcp_sk(ssk)->snd_wnd); } -static struct sock *mptcp_accept(struct sock *sk, int flags, int *err, +static struct sock *mptcp_accept(struct sock *ssk, int flags, int *err, bool kern) { - struct mptcp_sock *msk = mptcp_sk(sk); - struct socket *listener; struct sock *newsk; - listener = READ_ONCE(msk->subflow); - if (WARN_ON_ONCE(!listener)) { - *err = -EINVAL; - return NULL; - } - - pr_debug("msk=%p, listener=%p", msk, mptcp_subflow_ctx(listener->sk)); - newsk = inet_csk_accept(listener->sk, flags, err, kern); + pr_debug("ssk=%p, listener=%p", ssk, mptcp_subflow_ctx(ssk)); + newsk = inet_csk_accept(ssk, flags, err, kern); if (!newsk) return NULL; - pr_debug("msk=%p, subflow is mptcp=%d", msk, sk_is_mptcp(newsk)); + pr_debug("newsk=%p, subflow is mptcp=%d", newsk, sk_is_mptcp(newsk)); if (sk_is_mptcp(newsk)) { struct mptcp_subflow_context *subflow; struct sock *new_mptcp_sock; @@ -3209,9 +3201,9 @@ static struct sock *mptcp_accept(struct sock *sk, int flags, int *err, } newsk = new_mptcp_sock; - MPTCP_INC_STATS(sock_net(sk), MPTCP_MIB_MPCAPABLEPASSIVEACK); + MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_MPCAPABLEPASSIVEACK); } else { - MPTCP_INC_STATS(sock_net(sk), + MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_MPCAPABLEPASSIVEFALLBACK); } @@ -3761,8 +3753,7 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock, int flags, bool kern) { struct mptcp_sock *msk = mptcp_sk(sock->sk); - struct socket *ssock; - struct sock *newsk; + struct sock *ssk, *newsk; int err; pr_debug("msk=%p", msk); @@ -3770,11 +3761,11 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock, /* Buggy applications can call accept on socket states other then LISTEN * but no need to allocate the first subflow just to error out. */ - ssock = READ_ONCE(msk->subflow); - if (!ssock) + ssk = READ_ONCE(msk->first); + if (!ssk) return -EINVAL; - newsk = mptcp_accept(sock->sk, flags, &err, kern); + newsk = mptcp_accept(ssk, flags, &err, kern); if (!newsk) return err; From patchwork Fri Aug 11 15:57:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 134574 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1208603vqi; Fri, 11 Aug 2023 09:22:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFAdfw+keS+SWogld4E9WoyYgkR69M6nP8+LdmPbO/ONICn9zoYOqXxlCgNiClLA9XLyRUs X-Received: by 2002:aa7:d584:0:b0:523:ad6e:7d00 with SMTP id r4-20020aa7d584000000b00523ad6e7d00mr1802575edq.6.1691770962566; Fri, 11 Aug 2023 09:22:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691770962; cv=none; d=google.com; s=arc-20160816; b=bPJmZG1M0o+bX8SdnvLyQaNMVOsG3HQXs/9xh+YuIgZzCSXceabWxc4e4QBUVv78KL Co1zOcL056kuYGwLDBVroN7JO+O7dVkPrxThGn+cjWJXUunqUs812BIlpt/Gvx3iyh26 4mmZpLAaiNOmpGXHj7S1JwqzW9Mrbh/WoAzLLknn1Gl1SwmwfG8iutsNls8Hd4GQP5lq rlImdWx+DHnBy4c+j4cD/M9WVMdkbp6bv98ojGeX1n8BK2p0M2hG+7WzX3jU1KgZAqaH HgvgDW/ih59ApK4xLBksoESr9oYYMxEAoHiOxv2bIOdf1f1YlWhabFE7jhW4FkOB1co/ X9uQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=JwrGlqlP8zy3xXA0Lb/3kVoPgUx6S4wahN68TVcAYEQ=; fh=01LXX0/E7r2X8N0dkUmDXKtwLjGB7IavRhxV+MLJbog=; b=OEWqQLCGYCO1WrUB3hXmPCGoeqmEvBfRHEvrq+kJkG6O50yZ8O0KmCnwdTZHEtRn57 dPX2/jfgR0zaR49loRNn56DWmjELkLMt/EIsPl0nZDE2cRgmfRF9CIFXq1eRJ2fC0Gh3 7xtAmBO2nUaVU9uxVU1WBHUKm9V1l7hTfiHx6CVysMC2u7yleU16CWw6ROwE/doQk7Rd pJ36g5guFiHwjjMsocrfGjvkbmYmDrMsYMvbR9oqG77cjo0T8qaNMrHd6+4KqOK1tmWD v2hZXXmYR8TG07+c22/oqGCmzRm3CNJ52ol5uvYWX8vG3aGLtAzlo+q2xYq08EL9YYjZ /1Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=TkGxEa8d; 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=REJECT sp=REJECT 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 w7-20020aa7d287000000b00523d8bee81dsi537093edq.611.2023.08.11.09.22.17; Fri, 11 Aug 2023 09:22:42 -0700 (PDT) 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=TkGxEa8d; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236729AbjHKP7G (ORCPT + 99 others); Fri, 11 Aug 2023 11:59:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236717AbjHKP6z (ORCPT ); Fri, 11 Aug 2023 11:58:55 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96B0330E2 for ; Fri, 11 Aug 2023 08:58:52 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-317b31203c7so1925431f8f.2 for ; Fri, 11 Aug 2023 08:58:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1691769531; x=1692374331; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=JwrGlqlP8zy3xXA0Lb/3kVoPgUx6S4wahN68TVcAYEQ=; b=TkGxEa8dAStkiM49LVmgJ3jR4c3XDLmu00M5xmgIHyo6D7mpxSimlm3wTJ3CS7gxNu 61d6qt610XAioK9CRnwlPzJqGvTE8yWUs3SYRoqOjUYWPRhGMcgfHUD/J1C/UchyGLvF FPAPd3SVA6hrxFS3EYxo638MzgVoOFAv9mXW/vC81ZZqXdlrUqr9fv/4qzXOTIcP2yrP 2CMiPNNv/YR8xoyYET+pLGPCHvZNxbHGgoDorqTPL7I54Kk1OLkw/lj0mJ8D5HNTy25j N6J8M0M/cikW5nR0talBWo0QPmO3LrKnuru+oe+fLpner+KT9IYfIEItbvkAQriDq6cY Xzfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691769531; x=1692374331; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JwrGlqlP8zy3xXA0Lb/3kVoPgUx6S4wahN68TVcAYEQ=; b=lZ4pHcLLs1RnkqcbRRikJFqidsrZx+FywUaOZPhd1rVurLDkSG7WER5PLVasO7rrg+ JtGj7vN8Uk3CHtgPshVkqZOMVkrR66YrAZxksZG4wm7nKd7kLGM2oAI8a5fXjsX6anSN /RDElhHxm+wUTS1dcHl540QZ4BWfvb4DPGcDVH72O4nmKW8f/slOBor0hduqg1KbB7Km yBbcGPFGLuWafq0qNV4OhopR0U0sSBGDCqvXPF2hsdkS5Rm/JPc6l29lOzUZnxUvVIzv x5EMeTRLj9IPdfe7ca2GMpwJaB6S/KtDCZmgRjmLZBvxrDK7G9W1y6uGfnpCz1oCXakx Q9ag== X-Gm-Message-State: AOJu0Yxz7qpJvMS/ofI+uoJancWu05RQP+/yJ7sZgnEsXks8T0DijrIJ EnQFxOfBBlZunqhcpbH64m+Svw== X-Received: by 2002:a5d:40ce:0:b0:317:4d79:1e45 with SMTP id b14-20020a5d40ce000000b003174d791e45mr1756196wrq.15.1691769531158; Fri, 11 Aug 2023 08:58:51 -0700 (PDT) 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 m12-20020a5d4a0c000000b00317e9c05d35sm5834308wrq.85.2023.08.11.08.58.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 08:58:50 -0700 (PDT) From: Matthieu Baerts Date: Fri, 11 Aug 2023 17:57:23 +0200 Subject: [PATCH net-next 10/14] mptcp: avoid additional indirection in sockopt MIME-Version: 1.0 Message-Id: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-10-36183269ade8@tessares.net> References: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> In-Reply-To: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3734; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=K7Cpw3bUrIQ1S7TwFyAgFflx+80UQhfgWAmuSbjF5r0=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBk1lqvQ4Qy9NxZorSk6UHkZ3Aip/F03UNbG6MtU BNDH6LXkDaJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZNZarwAKCRD2t4JPQmmg c11OD/90ZhRggDinf+VJ9ze2snCh8sxAHT3osOY0tSEOW5XL9QSsQfrygLx9LGDNMYMJ/evOU/v vxxmWM9J2RYCR66Ihi0Qqxtsulf/v2bMi9TtbGdvneTxyIfOlEtVAmmPmlZdBLw529/RiTI3wj0 wYQxytcKOMq2sVxBkL8VUXgXbvvwhgnzXX3ooTTiaAu4Rm/bqCXWxLecOnXfSN2vDc4+LrCBJz8 jPq4akOusmYqvBT0mc7zPw46AMyU3DYhLUmtCvcxQfyoykgPSe6F8RUxA8G/esE6Lldp5jlzGTa 084tnztrobEugEOhkChqxji7jUyUnJvx1G7Tx2KVbpKNiCACmX0XX2RcCMgexevqL2HN2o8DPAS /HiLpGk/91JQxkqOMwxvrrF6n6nCp6XJ+Scrrp6Uu9KS3W3jWu9qBAF3jspNrl6lkex3bvqfiLV CicghVwEs2ggnF7dhTENjjDJ23AsUcdiYN7dNT95i2qYkUfpWAfDMq69+hUeA+9c2zqv2+/idq8 Ynoxbz/5cKHVGueKv/XJSnqaVLCcc288UgYOElMnzcreyAijt8TFDzxPtJQO5KN+Ug9CfP6q76o gGZqDDwDC8B1dsf/cjnz4seJSSI/GjZ/Ws4DR92gkWDUBtU40O+KkjWC8WEkirYuNg0wMbN9MFZ DQsB9DrXeyUk87A== 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,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773950428912315916 X-GMAIL-MSGID: 1773950428912315916 From: Paolo Abeni The mptcp sockopt infrastructure unneedly uses the first subflow socket struct in a few spots. We are going to remove such field soon, so use directly the first subflow sock instead. No functional changes intended. Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts --- net/mptcp/sockopt.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index a3f1fe810cc9..6661852f8d97 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -293,6 +293,7 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, { struct sock *sk = (struct sock *)msk; struct socket *ssock; + struct sock *ssk; int ret; switch (optname) { @@ -307,16 +308,17 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, return PTR_ERR(ssock); } - ret = sock_setsockopt(ssock, SOL_SOCKET, optname, optval, optlen); + ssk = msk->first; + ret = sk_setsockopt(ssk, SOL_SOCKET, optname, optval, optlen); if (ret == 0) { if (optname == SO_REUSEPORT) - sk->sk_reuseport = ssock->sk->sk_reuseport; + sk->sk_reuseport = ssk->sk_reuseport; else if (optname == SO_REUSEADDR) - sk->sk_reuse = ssock->sk->sk_reuse; + sk->sk_reuse = ssk->sk_reuse; else if (optname == SO_BINDTODEVICE) - sk->sk_bound_dev_if = ssock->sk->sk_bound_dev_if; + sk->sk_bound_dev_if = ssk->sk_bound_dev_if; else if (optname == SO_BINDTOIFINDEX) - sk->sk_bound_dev_if = ssock->sk->sk_bound_dev_if; + sk->sk_bound_dev_if = ssk->sk_bound_dev_if; } release_sock(sk); return ret; @@ -391,6 +393,7 @@ static int mptcp_setsockopt_v6(struct mptcp_sock *msk, int optname, struct sock *sk = (struct sock *)msk; int ret = -EOPNOTSUPP; struct socket *ssock; + struct sock *ssk; switch (optname) { case IPV6_V6ONLY: @@ -403,7 +406,8 @@ static int mptcp_setsockopt_v6(struct mptcp_sock *msk, int optname, return PTR_ERR(ssock); } - ret = tcp_setsockopt(ssock->sk, SOL_IPV6, optname, optval, optlen); + ssk = msk->first; + ret = tcp_setsockopt(ssk, SOL_IPV6, optname, optval, optlen); if (ret != 0) { release_sock(sk); return ret; @@ -413,13 +417,13 @@ static int mptcp_setsockopt_v6(struct mptcp_sock *msk, int optname, switch (optname) { case IPV6_V6ONLY: - sk->sk_ipv6only = ssock->sk->sk_ipv6only; + sk->sk_ipv6only = ssk->sk_ipv6only; break; case IPV6_TRANSPARENT: - inet_sk(sk)->transparent = inet_sk(ssock->sk)->transparent; + inet_sk(sk)->transparent = inet_sk(ssk)->transparent; break; case IPV6_FREEBIND: - inet_sk(sk)->freebind = inet_sk(ssock->sk)->freebind; + inet_sk(sk)->freebind = inet_sk(ssk)->freebind; break; } @@ -700,7 +704,7 @@ static int mptcp_setsockopt_sol_ip_set_transparent(struct mptcp_sock *msk, int o return PTR_ERR(ssock); } - issk = inet_sk(ssock->sk); + issk = inet_sk(msk->first); switch (optname) { case IP_FREEBIND: @@ -865,8 +869,8 @@ static int mptcp_getsockopt_first_sf_only(struct mptcp_sock *msk, int level, int { struct sock *sk = (struct sock *)msk; struct socket *ssock; - int ret; struct sock *ssk; + int ret; lock_sock(sk); ssk = msk->first; @@ -881,7 +885,7 @@ static int mptcp_getsockopt_first_sf_only(struct mptcp_sock *msk, int level, int goto out; } - ret = tcp_getsockopt(ssock->sk, level, optname, optval, optlen); + ret = tcp_getsockopt(ssk, level, optname, optval, optlen); out: release_sock(sk); From patchwork Fri Aug 11 15:57:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 134628 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1261146vqi; Fri, 11 Aug 2023 10:55:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzaJUiEsEjorOYAKjrE6Jn1/NhholYf/gJq9/xE5ROn6dUvyT0o76uMeUxpqc7XMzQ71+D X-Received: by 2002:a05:6a00:1907:b0:668:753a:b150 with SMTP id y7-20020a056a00190700b00668753ab150mr2710670pfi.21.1691776526218; Fri, 11 Aug 2023 10:55:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691776526; cv=none; d=google.com; s=arc-20160816; b=m6ysXrHLz+rAzveFWRRkOrtnqBGckxdl6jdhGCZO0hy+rDGWKiJTByDPe8i5biftQk vhcIcGMDGJujaBoalh43Si6En13brp2uFLrMr5d7NYoYM3xNarFOYn8cMLTm7sBoMY2Q DQcoLxzSNEuPqmiwEnLLR+1CvLKovhsS+Y6Dd8Fc7O7oiHylE+QaoCo6UAhc9lnq/mVl SYb9P0rvqsQlzrKHAeaZqFt7dvtdS/BY3GTSUedVF3Q5v9mG3SKUcB0YHhL0fTmnk6VV dOTebKtKnekxc1MywyeXqqnIz8XDfbc/aezCJHnLvy5TX/H+IS9kmGz3CG5kmPiC36fN zNgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=st2NKZ9E1hXrfDL5Ot0q/FaTfuFvnM6rU0/aNjt+RGc=; fh=01LXX0/E7r2X8N0dkUmDXKtwLjGB7IavRhxV+MLJbog=; b=mTYs5ARkqI4lAX5ZPwiIIDT5UEyQ/sx7ucDS0SQQ75mtgeJi+mooRrZglm3bvNpP72 ZXRGzEbDUfvEhqFvYs7vazbcDAv9onKKtySWi0P0Cx/hGml8+KzWoxU91f1mMVYhbJqv vqZNXmCJVGPnRZYu7Fhli180VVysJHPu6ckON74J0vttnPHvZ2t6GBwgl1bz7jiCA7T5 Ujsym+gYvUMlxLIRqwO/ZNPCmGEz19YcZe+mnzmXmBvjyWzd8vAHfLIRHK5ZWCckS/nZ sCCTgCFd4bhwFXr7iLCI5109Nwkghv6ww6lak5su2zkSRLrfy1QoJFlfCmA/wCjz2cz+ glZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=TGFIIasq; 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=REJECT sp=REJECT 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 q5-20020a056a00150500b006826c5b86dasi3871373pfu.364.2023.08.11.10.55.13; Fri, 11 Aug 2023 10:55:26 -0700 (PDT) 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=TGFIIasq; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236786AbjHKP7L (ORCPT + 99 others); Fri, 11 Aug 2023 11:59:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236721AbjHKP66 (ORCPT ); Fri, 11 Aug 2023 11:58:58 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 986D530E9 for ; Fri, 11 Aug 2023 08:58:53 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-317f1c480eeso1904058f8f.2 for ; Fri, 11 Aug 2023 08:58:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1691769532; x=1692374332; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=st2NKZ9E1hXrfDL5Ot0q/FaTfuFvnM6rU0/aNjt+RGc=; b=TGFIIasqCurxVc8BEOtpb7f0OIiHFeMet4baqs+yRG+W1i1oVpnRM7RH/oRF2dGxHu C3yaSG936y/XFN8cFrb3PMr9yODT9g8P7U3CJvMLHGL72yTu++BvRLnXj8GK9c7yO4qq B90jn6CTED9DabWy5o4ivqlOkl+g/Wx9ue+bKmzH700b9rs9Fj5L51k/NsSviadPG9uo 5Srlly7ULuVfkVqVLWSMgTKirFez42x5hJmEga1Wfi8xh29VbL+TXjSR3kIfTeMlETqO pOP7LD/6pkfaQFEyYmILGr4/Trla2LyutlHlST2Rxpc4G/wGX8MS6hGcXOQSoP15krxv nHaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691769532; x=1692374332; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=st2NKZ9E1hXrfDL5Ot0q/FaTfuFvnM6rU0/aNjt+RGc=; b=ZuJxcDhA5gS6eH67UFhB0roVIRQ4BIbjKBpfFTPQi1CEgok0af/oT8jvByczMc4S0p TlrxTj1snrBk59r4senK4SqSRUSAP/1WkTZE7iBk0UEwIR7zk3f2QJmX5GCtmJw5Hgm+ MlH3aWWVJk7AsD1wCacW8+GrSw8PNh/pRIp0XWjyuDo7okQq+i4MgNbTWUv79u4eCS2x 1aEfiV4XvyxSAay+nvJooAoUNtZHNUlM92+pD/wj7o+s9y5CBsTTcrmvbXpA/QbsJxX3 /he8yBjkY/q7b7UpS9AC09YTK8kSOGxfv0fvbdLl9bcT+C9LZQpWkI7TVEND6HNaTmR9 gpNA== X-Gm-Message-State: AOJu0YwywXSBOzhcrHBxvJXT9+zx1CBRHVWTrQ4lA3W/8idhWMuRIeaU ZNDG/bOkUqc3ubpMsIbnjV37gQ== X-Received: by 2002:adf:fa8c:0:b0:317:7081:9a6a with SMTP id h12-20020adffa8c000000b0031770819a6amr1667780wrr.24.1691769532173; Fri, 11 Aug 2023 08:58:52 -0700 (PDT) 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 m12-20020a5d4a0c000000b00317e9c05d35sm5834308wrq.85.2023.08.11.08.58.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 08:58:51 -0700 (PDT) From: Matthieu Baerts Date: Fri, 11 Aug 2023 17:57:24 +0200 Subject: [PATCH net-next 11/14] mptcp: avoid ssock usage in mptcp_pm_nl_create_listen_socket() MIME-Version: 1.0 Message-Id: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-11-36183269ade8@tessares.net> References: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> In-Reply-To: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2211; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=ryKEnhcU8jzGTw+8/ZGieSQgwwgsCHLHT0d+ugOOpQc=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBk1lqvmajEXvtvTqt8lHzWQds82lCmd/Y2V7HCi Z01gYHwgqaJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZNZarwAKCRD2t4JPQmmg cwrJD/40dDF0EYxvn5MXmn3Z/EHHQzIE6RcDCAsJGNaSvTC/z0X5Qd57QL50ZkUasy7eWY/XL04 dVxdTQXld587lj44Hpu4qUxptiGHQcjviVPK8jhcH9QBJME4PL9apiurN28mna90GcUCuZfgTWU hn1pw0e2lY0nEY91BMsvdrbgPXYQljrn+kn2O6nIkNq0WWsfphkTWNMfeBCwFeVzto6Kecrf5bI LVPSdRtuy+fBfG2qAa+HUyf5wvyo4Lpu3PBlWvJJuj3gL7Qjpp/xfXWMRhsTRpe1iHl6CmhhguS Nkag1RM90+SzkkKWzMKEZEJkWAgM+5hMY2Kzzodm4V6raj7tof+dxZdii0Zike1tiV0FTQK0WLo o8xPMddT995MaoIDY3QCxbiViJDQpRRUPH6+NeMWq+AheVQJauH2eLA2DotoBZUCVjbWTWKfHfO /jm3l4X8Xam9FNNKeFMQ/lr+ZyydVpZ1bx5gye6iBVHRH06E0o+J9stqqlmqIV8hQo8J880Fhr2 eWvuLyMImbi0rKsspWbaphIL/iTrMjzaK+n4WkfcXtzcaQtn/9ROyHYtErQZh3A8wfdbMjJX1UX JkngATdTVyt+Kiy0BAHiirZrk1HjjgQkw+v5U+UJXvMBcrwFXQCIz8t/ECB9soCoeBK6MThJH5D Pr81hahvz6kdXcA== 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,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773956262585704824 X-GMAIL-MSGID: 1773956262585704824 From: Paolo Abeni This is one of the few remaining spots actually manipulating the first subflow socket. We can leverage the recently introduced inet helpers to get rid of ssock there. No functional changes intended. Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts --- net/mptcp/pm_netlink.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 5692daf57a4d..ae36155ff128 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -1005,8 +1006,8 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk, bool is_ipv6 = sk->sk_family == AF_INET6; int addrlen = sizeof(struct sockaddr_in); struct sockaddr_storage addr; + struct sock *newsk, *ssk; struct socket *ssock; - struct sock *newsk; int backlog = 1024; int err; @@ -1042,18 +1043,23 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk, if (entry->addr.family == AF_INET6) addrlen = sizeof(struct sockaddr_in6); #endif - err = kernel_bind(ssock, (struct sockaddr *)&addr, addrlen); + ssk = mptcp_sk(newsk)->first; + if (ssk->sk_family == AF_INET) + err = inet_bind_sk(ssk, (struct sockaddr *)&addr, addrlen); +#if IS_ENABLED(CONFIG_MPTCP_IPV6) + else if (ssk->sk_family == AF_INET6) + err = inet6_bind_sk(ssk, (struct sockaddr *)&addr, addrlen); +#endif if (err) return err; inet_sk_state_store(newsk, TCP_LISTEN); - err = kernel_listen(ssock, backlog); - if (err) - return err; - - mptcp_event_pm_listener(ssock->sk, MPTCP_EVENT_LISTENER_CREATED); - - return 0; + lock_sock(ssk); + err = __inet_listen_sk(ssk, backlog); + if (!err) + mptcp_event_pm_listener(ssk, MPTCP_EVENT_LISTENER_CREATED); + release_sock(ssk); + return err; } int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc) From patchwork Fri Aug 11 15:57:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 134599 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1224253vqi; Fri, 11 Aug 2023 09:49:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGyXBQ1OuQ155rgG1ZV1GgSETHhpmR083ZqxNCl6MtIe0zEkh5TBxzmJImcTHjzQbVJK9wf X-Received: by 2002:aa7:8883:0:b0:67e:18c6:d2c6 with SMTP id z3-20020aa78883000000b0067e18c6d2c6mr3128113pfe.5.1691772560399; Fri, 11 Aug 2023 09:49:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691772560; cv=none; d=google.com; s=arc-20160816; b=p1WwIpWzXBLUMlTxGUfBWc6Hgbs00sBeLqhqOkt65kt5A9xyZ0eag7fPpWRgG59EZ7 TRk+Tu7TYUxPFh9dFMQWKKY006YM9OTOgobHAa7bc/bZsEZYsdYAl5vouv76224zYa3c XLxHl3BwzaLHLLJl8Mu9SHz1h4lHj4rvMs1j2luaJDBdICYZrnU7MIC1SCxRUPij1fgd RdT54h8OaoxDWQICvNvOxyROUoukLbH7PfIqZNi6g6M3QIQu0dySvBZMVc06Zn8972F7 pM1EifYcyll1b5b7iNwEYm04RYElD+Q1SYoH0nspY1rIbzn9/MJyaY2DboIZBk2cNDiG TzPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=LSGODcFr9OATSyqQxuKOktFKCDDLoEhYtD7jcorRxls=; fh=01LXX0/E7r2X8N0dkUmDXKtwLjGB7IavRhxV+MLJbog=; b=ol0ggqWnZwVSgVVeRC8KPd9w/ogncaXU/ml8mEjPoU9zmlTZzsS5uLYnnI/aAEsCgQ D4ZC5X1h2ToAJScawr9neu+ju+DcYQggQjOCZturKb/mVL1fj2LB6WBPM/T55upnn8SS S+jtQHlkLgZEDn6Tyxs44T0B9zXYIqx0inKq9qjqkT5kEpRKZx//SHIU7sZ5L32GSqv7 7Slap1vUT3uUmnHWXPSqq6dhMAWSu7o7IMmq8dtyEUPW8wFqWmqhOMV+jr3SbyVobFVi 33nBfJeuSKRQVGFV1amDg+qBhsKvEtRsrfr513PJCBoa8aflCUifAWu2j92/69BxBNXg d7Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=Ns1lteFx; 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=REJECT sp=REJECT 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 z41-20020a056a001da900b00687071384a7si3625280pfw.152.2023.08.11.09.49.05; Fri, 11 Aug 2023 09:49:20 -0700 (PDT) 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=Ns1lteFx; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236794AbjHKP7O (ORCPT + 99 others); Fri, 11 Aug 2023 11:59:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236734AbjHKP67 (ORCPT ); Fri, 11 Aug 2023 11:58:59 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C81D230EE for ; Fri, 11 Aug 2023 08:58:54 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-317b31203c7so1925466f8f.2 for ; Fri, 11 Aug 2023 08:58:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1691769533; x=1692374333; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=LSGODcFr9OATSyqQxuKOktFKCDDLoEhYtD7jcorRxls=; b=Ns1lteFxpGDVHRr38JDPYc+60Nzl7xP/gf0ZKPsOMwq34jdrCKfZ/cwPk/wmPUz4sS 4B0ebU8RTUNR/NLt23mZ+jTb2pmqeRacpKRP1Bbver0Yy0LlTNvzg/13mW3x9NB5Wkq6 maFLwHCC9lVe6FM7zhXGEi4pxAuOOSmZri/uYjdvRjK2/0Aor+r0q4muwwnVHvqlhuRJ fCPYJtvJhrgsHNxhRA4r0ywV7MrSTxZTiV5vWC0kR1dP4RvW2VQmc3owz7jn42NyeCr8 ESM/YU2HagKdfe6mjsOx8oPYUL/LMLexoi0mib6FD+g3nWBb+fojKsCSSS16Gr3xYToU 8qMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691769533; x=1692374333; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LSGODcFr9OATSyqQxuKOktFKCDDLoEhYtD7jcorRxls=; b=ENy5EnCxuBJEOUEyeKyLUVtXeMKWrrOOu7D5OBLDBQNQeeYg0Cv322CMcQfqOMy5Hg iFUxzFPgryfzXiCqAzV44oe8gdVaoelJpaOHnWrc5TyJabpXrGDUoGa+K0KKVTQlWzSc 2UHK8Ko/AfsqwaH0tpTslKeN9EtBUvxr/TMIXSoiuuHWrbaoFtX9opbDj2piuAorFbHr A5IwhvtEXT9Ikvz70RXRZOjqhU70yT3c3ZyMfLshGDYqpJEONQMfVBCLnsGnOkdo4gLt NzBcy/wDbnGeLjBoLU8E3Z4qtgTEXLtp5cC6Pf6ZxaSle3hzLL0eJgPGt5bGtf9v9spV Mjlg== X-Gm-Message-State: AOJu0YxhdA59oJfayWeKLHn/3IcSSMAbvRgfRgG8N78P70G8fUCjQ5eR pPAjuAs6sHC3+lIGzGRV+9nb8g== X-Received: by 2002:a5d:5742:0:b0:319:57c0:19f7 with SMTP id q2-20020a5d5742000000b0031957c019f7mr1881075wrw.7.1691769533171; Fri, 11 Aug 2023 08:58:53 -0700 (PDT) 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 m12-20020a5d4a0c000000b00317e9c05d35sm5834308wrq.85.2023.08.11.08.58.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 08:58:52 -0700 (PDT) From: Matthieu Baerts Date: Fri, 11 Aug 2023 17:57:25 +0200 Subject: [PATCH net-next 12/14] mptcp: change the mpc check helper to return a sk MIME-Version: 1.0 Message-Id: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-12-36183269ade8@tessares.net> References: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> In-Reply-To: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=10012; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=5FIAPyMt3vXexcaCp5hS8RO0kYDOfcIUe8e+GVkbMIM=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBk1lqvEIUdoYbsI/k9HD+UAvGip1BHaH0nZMrnK M38NGK6mkaJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZNZarwAKCRD2t4JPQmmg cxNXEACaIW71/uXxptgFXdcZuPe5B6cj2DPTZ7da9NeA1HhobPG9XGyFbJRt6lYh7CP+DoUxDrU kIB3bMZjZM/g3ljiPvnyGbNBOAg96iZKCvdh4XxkqvHKoIK5IApq/MD4FPK6G0Z2Jpmdv2rI4PB hzB14paKlxVV5aqiSiaQNhEoT5L8w1tg/6ZADRLfMkdv2az3ZnFDPrXZ1+AjlBTB6pVtvQXXhsF /JZQ0O0kzQZRBNVIKhF1jW6Qmp/oXP3w+TvfM9RFIYbJbdILcpt1cwV6KGdKnTWMni9h/6OOg1F eAg1hXQXZJ/wCU6B/Yoq+56E4qz+mL1ZXlxJuX8O0HiHNjakXvwlqp9CuHb4b1i71rTkhgQT44R /26+Ha9fXQV7qph/+O3Vcc+bpHJzsPd7GFzqkj2Cw0K1JHoCq7j+gNGtjO59T//MXJMig3dYmKH QPnnVV4Q0mhN/CYsfkCeQTzW51NrnkgeybU4gB91QfxhPQoF0jkUqszrU9rQ57Fno8z4CuVVGYs hh6YCjB3xnqIp/BzJoV7fe1Hl0JQugFHClZ/IizWAd5R6D60KVQCSkq/SXS2Y6dfT1XiGnHatH+ WDuEAQHv/bzgsanN6X9rUTXksrKtTYms66SKvK70PKM0gyVlu8MTPOiS+6k3gwEIW1Qs5h4KCnZ woES6Jm4M95XQ8g== 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,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773952104342024510 X-GMAIL-MSGID: 1773952104342024510 From: Paolo Abeni After the previous patch the __mptcp_nmpc_socket helper is used only to ensure that the MPTCP socket is a suitable status - that is, the mptcp capable handshake is not started yet. Change the return value to the relevant subflow sock, to finally remove the last references to first subflow socket in the MPTCP stack. As a bonus, we can get rid of a few local variables in different functions. No functional change intended. Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts --- net/mptcp/pm_netlink.c | 8 +++----- net/mptcp/protocol.c | 40 +++++++++++++++------------------------- net/mptcp/protocol.h | 2 +- net/mptcp/sockopt.c | 43 +++++++++++++++++++------------------------ 4 files changed, 38 insertions(+), 55 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index ae36155ff128..c75d9d88a053 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1007,7 +1007,6 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk, int addrlen = sizeof(struct sockaddr_in); struct sockaddr_storage addr; struct sock *newsk, *ssk; - struct socket *ssock; int backlog = 1024; int err; @@ -1033,17 +1032,16 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk, &mptcp_keys[is_ipv6]); lock_sock(newsk); - ssock = __mptcp_nmpc_socket(mptcp_sk(newsk)); + ssk = __mptcp_nmpc_sk(mptcp_sk(newsk)); release_sock(newsk); - if (IS_ERR(ssock)) - return PTR_ERR(ssock); + if (IS_ERR(ssk)) + return PTR_ERR(ssk); mptcp_info2sockaddr(&entry->addr, &addr, entry->addr.family); #if IS_ENABLED(CONFIG_MPTCP_IPV6) if (entry->addr.family == AF_INET6) addrlen = sizeof(struct sockaddr_in6); #endif - ssk = mptcp_sk(newsk)->first; if (ssk->sk_family == AF_INET) err = inet_bind_sk(ssk, (struct sockaddr *)&addr, addrlen); #if IS_ENABLED(CONFIG_MPTCP_IPV6) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index e5ebd170d316..fafa83ee4a72 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -109,7 +109,7 @@ static int __mptcp_socket_create(struct mptcp_sock *msk) /* If the MPC handshake is not started, returns the first subflow, * eventually allocating it. */ -struct socket *__mptcp_nmpc_socket(struct mptcp_sock *msk) +struct sock *__mptcp_nmpc_sk(struct mptcp_sock *msk) { struct sock *sk = (struct sock *)msk; int ret; @@ -117,10 +117,7 @@ struct socket *__mptcp_nmpc_socket(struct mptcp_sock *msk) if (!((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))) return ERR_PTR(-EINVAL); - if (!msk->subflow) { - if (msk->first) - return ERR_PTR(-EINVAL); - + if (!msk->first) { ret = __mptcp_socket_create(msk); if (ret) return ERR_PTR(ret); @@ -128,7 +125,7 @@ struct socket *__mptcp_nmpc_socket(struct mptcp_sock *msk) mptcp_sockopt_sync(msk, msk->first); } - return msk->subflow; + return msk->first; } static void mptcp_drop(struct sock *sk, struct sk_buff *skb) @@ -1643,7 +1640,6 @@ static int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, { unsigned int saved_flags = msg->msg_flags; struct mptcp_sock *msk = mptcp_sk(sk); - struct socket *ssock; struct sock *ssk; int ret; @@ -1654,9 +1650,9 @@ static int mptcp_sendmsg_fastopen(struct sock *sk, struct msghdr *msg, * fastopen attempt, no need to check for additional subflow status. */ if (msg->msg_flags & MSG_FASTOPEN) { - ssock = __mptcp_nmpc_socket(msk); - if (IS_ERR(ssock)) - return PTR_ERR(ssock); + ssk = __mptcp_nmpc_sk(msk); + if (IS_ERR(ssk)) + return PTR_ERR(ssk); } if (!msk->first) return -EINVAL; @@ -3577,16 +3573,14 @@ static int mptcp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len) { struct mptcp_subflow_context *subflow; struct mptcp_sock *msk = mptcp_sk(sk); - struct socket *ssock; int err = -EINVAL; struct sock *ssk; - ssock = __mptcp_nmpc_socket(msk); - if (IS_ERR(ssock)) - return PTR_ERR(ssock); + ssk = __mptcp_nmpc_sk(msk); + if (IS_ERR(ssk)) + return PTR_ERR(ssk); inet_sk_state_store(sk, TCP_SYN_SENT); - ssk = msk->first; subflow = mptcp_subflow_ctx(ssk); #ifdef CONFIG_TCP_MD5SIG /* no MPTCP if MD5SIG is enabled on this socket or we may run out of @@ -3682,17 +3676,15 @@ static int mptcp_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) { struct mptcp_sock *msk = mptcp_sk(sock->sk); struct sock *ssk, *sk = sock->sk; - struct socket *ssock; int err = -EINVAL; lock_sock(sk); - ssock = __mptcp_nmpc_socket(msk); - if (IS_ERR(ssock)) { - err = PTR_ERR(ssock); + ssk = __mptcp_nmpc_sk(msk); + if (IS_ERR(ssk)) { + err = PTR_ERR(ssk); goto unlock; } - ssk = msk->first; if (sk->sk_family == AF_INET) err = inet_bind_sk(ssk, uaddr, addr_len); #if IS_ENABLED(CONFIG_MPTCP_IPV6) @@ -3711,7 +3703,6 @@ static int mptcp_listen(struct socket *sock, int backlog) { struct mptcp_sock *msk = mptcp_sk(sock->sk); struct sock *sk = sock->sk; - struct socket *ssock; struct sock *ssk; int err; @@ -3723,13 +3714,12 @@ static int mptcp_listen(struct socket *sock, int backlog) if (sock->state != SS_UNCONNECTED || sock->type != SOCK_STREAM) goto unlock; - ssock = __mptcp_nmpc_socket(msk); - if (IS_ERR(ssock)) { - err = PTR_ERR(ssock); + ssk = __mptcp_nmpc_sk(msk); + if (IS_ERR(ssk)) { + err = PTR_ERR(ssk); goto unlock; } - ssk = msk->first; inet_sk_state_store(sk, TCP_LISTEN); sock_set_flag(sk, SOCK_RCU_FREE); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 79fc5cdb67bc..dccc96dc2d6b 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -640,7 +640,7 @@ void __mptcp_subflow_send_ack(struct sock *ssk); void mptcp_subflow_reset(struct sock *ssk); void mptcp_subflow_queue_clean(struct sock *sk, struct sock *ssk); void mptcp_sock_graft(struct sock *sk, struct socket *parent); -struct socket *__mptcp_nmpc_socket(struct mptcp_sock *msk); +struct sock *__mptcp_nmpc_sk(struct mptcp_sock *msk); bool __mptcp_close(struct sock *sk, long timeout); void mptcp_cancel_work(struct sock *sk); void __mptcp_unaccepted_force_close(struct sock *sk); diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index 6661852f8d97..21bc46acbe38 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -292,7 +292,6 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, sockptr_t optval, unsigned int optlen) { struct sock *sk = (struct sock *)msk; - struct socket *ssock; struct sock *ssk; int ret; @@ -302,13 +301,12 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, case SO_BINDTODEVICE: case SO_BINDTOIFINDEX: lock_sock(sk); - ssock = __mptcp_nmpc_socket(msk); - if (IS_ERR(ssock)) { + ssk = __mptcp_nmpc_sk(msk); + if (IS_ERR(ssk)) { release_sock(sk); - return PTR_ERR(ssock); + return PTR_ERR(ssk); } - ssk = msk->first; ret = sk_setsockopt(ssk, SOL_SOCKET, optname, optval, optlen); if (ret == 0) { if (optname == SO_REUSEPORT) @@ -392,7 +390,6 @@ static int mptcp_setsockopt_v6(struct mptcp_sock *msk, int optname, { struct sock *sk = (struct sock *)msk; int ret = -EOPNOTSUPP; - struct socket *ssock; struct sock *ssk; switch (optname) { @@ -400,13 +397,12 @@ static int mptcp_setsockopt_v6(struct mptcp_sock *msk, int optname, case IPV6_TRANSPARENT: case IPV6_FREEBIND: lock_sock(sk); - ssock = __mptcp_nmpc_socket(msk); - if (IS_ERR(ssock)) { + ssk = __mptcp_nmpc_sk(msk); + if (IS_ERR(ssk)) { release_sock(sk); - return PTR_ERR(ssock); + return PTR_ERR(ssk); } - ssk = msk->first; ret = tcp_setsockopt(ssk, SOL_IPV6, optname, optval, optlen); if (ret != 0) { release_sock(sk); @@ -689,7 +685,7 @@ static int mptcp_setsockopt_sol_ip_set_transparent(struct mptcp_sock *msk, int o { struct sock *sk = (struct sock *)msk; struct inet_sock *issk; - struct socket *ssock; + struct sock *ssk; int err; err = ip_setsockopt(sk, SOL_IP, optname, optval, optlen); @@ -698,13 +694,13 @@ static int mptcp_setsockopt_sol_ip_set_transparent(struct mptcp_sock *msk, int o lock_sock(sk); - ssock = __mptcp_nmpc_socket(msk); - if (IS_ERR(ssock)) { + ssk = __mptcp_nmpc_sk(msk); + if (IS_ERR(ssk)) { release_sock(sk); - return PTR_ERR(ssock); + return PTR_ERR(ssk); } - issk = inet_sk(msk->first); + issk = inet_sk(ssk); switch (optname) { case IP_FREEBIND: @@ -767,18 +763,18 @@ static int mptcp_setsockopt_first_sf_only(struct mptcp_sock *msk, int level, int sockptr_t optval, unsigned int optlen) { struct sock *sk = (struct sock *)msk; - struct socket *sock; + struct sock *ssk; int ret; /* Limit to first subflow, before the connection establishment */ lock_sock(sk); - sock = __mptcp_nmpc_socket(msk); - if (IS_ERR(sock)) { - ret = PTR_ERR(sock); + ssk = __mptcp_nmpc_sk(msk); + if (IS_ERR(ssk)) { + ret = PTR_ERR(ssk); goto unlock; } - ret = tcp_setsockopt(sock->sk, level, optname, optval, optlen); + ret = tcp_setsockopt(ssk, level, optname, optval, optlen); unlock: release_sock(sk); @@ -868,7 +864,6 @@ static int mptcp_getsockopt_first_sf_only(struct mptcp_sock *msk, int level, int char __user *optval, int __user *optlen) { struct sock *sk = (struct sock *)msk; - struct socket *ssock; struct sock *ssk; int ret; @@ -879,9 +874,9 @@ static int mptcp_getsockopt_first_sf_only(struct mptcp_sock *msk, int level, int goto out; } - ssock = __mptcp_nmpc_socket(msk); - if (IS_ERR(ssock)) { - ret = PTR_ERR(ssock); + ssk = __mptcp_nmpc_sk(msk); + if (IS_ERR(ssk)) { + ret = PTR_ERR(ssk); goto out; } From patchwork Fri Aug 11 15:57:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 134617 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1254100vqi; Fri, 11 Aug 2023 10:40:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgeTaRtCmtOIZTkCO6yvx3Zyb96hQ6nRbyDUlcPw1KOapNpR8k0E3jRn+fk0GyCXH5uTca X-Received: by 2002:a05:6a00:1397:b0:680:98c:c593 with SMTP id t23-20020a056a00139700b00680098cc593mr3709546pfg.7.1691775619657; Fri, 11 Aug 2023 10:40:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691775619; cv=none; d=google.com; s=arc-20160816; b=gX796q/y06oVXFH6OYESWue9v2STfHWjK9L10s+mIasyJYNg9V/jrwZULNUdvN/6Ry +8y3bkkqXkUVLNybPGtmVRmv8EFE5SDtqe2b9s4YhTU74EvdND6YhzohAgZowZaM0n0v qBmpF1FJVR/Cu5TMPvrMsMQZqEhUoeQG0UdvLeGObBaSr9iB/rZAqej7zBuRcAQL6Pj1 06RZfr1r8u83OTIelpat1lfOzmyXtMHMZ/LQ7aGZp9kXHTQubRTLTfUvuujdCMqk2rcJ G6TyyRPzJ6SH4gFjTWW81pqIKbmvnwatRDl3cl/o3L3EBkkDGmxcx+29mxn80xIf9A0m Ap6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=cLaLRYF1JduC+QzJ6GmQvAFgWnOUNDuN5FR0KZ2xx0A=; fh=01LXX0/E7r2X8N0dkUmDXKtwLjGB7IavRhxV+MLJbog=; b=ElUeF7DtHZLBzTHkWbPS4GmpYwjMe9OVrXEicjRzxyWJtyVetWwNp22lfmmc+T5KfB sAN+cJK7vpYCEUEUKKOjJbgiKEoEHaWCOXC44SOYO4OAlx4tCetz7EJzT5m2UhKB4Xha NgKbT9Kz6CxSy5UUhRWJshc8EAmzV370lZlZChrdOzyB2mgMlThBxR6XMCelNyLGuC43 G7VvdKF50Jpo06Hs+ezgZoJ83mniYVPX1hlvJlkjDdzkDRNoXI59A9WRV8onxRopR01b VT5YS7XyJm2UDTfeEEgs23q7Ghz2gvWTeWm6XPq0o4Gu2Hc/W0jf6MhkSbsEoH7FSaQB +6Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=noy0cHvA; 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=REJECT sp=REJECT 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 e3-20020a6558c3000000b0054fdfd26dffsi3724142pgu.337.2023.08.11.10.40.05; Fri, 11 Aug 2023 10:40:19 -0700 (PDT) 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=noy0cHvA; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234384AbjHKP7S (ORCPT + 99 others); Fri, 11 Aug 2023 11:59:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236745AbjHKP7A (ORCPT ); Fri, 11 Aug 2023 11:59:00 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50B1830D5 for ; Fri, 11 Aug 2023 08:58:56 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-317c3ac7339so1847658f8f.0 for ; Fri, 11 Aug 2023 08:58:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1691769535; x=1692374335; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=cLaLRYF1JduC+QzJ6GmQvAFgWnOUNDuN5FR0KZ2xx0A=; b=noy0cHvA5nSTmWrJUz91yjHuTF/IaG5qP+BedmmnjvAivrJ7RDhS85BDCiPUg3NRFE XeVT+4W66rrFujkgK3Lyqjh77PF2/8XxVznsW/tvioTNi/g3DlaFBsxEHcyN/9awDzLc p1dfFs3XqBkbW6ETfcwakXFGLYb1nMthGv2b3/MiKQ3AYhG1PNbYfdNAkU3zmtO2z+uk +tMNEn9LJiAgyKyTJiWyB775hg29tXJ9Y1oN8OQTL2CeXRqF6po4G0Yar2tLTXb60o2H fWWd7inV6p7Tngvoc/hLcSWbeFGE0zgKeW9lT9gEuN2QC6SvRK/l7b7/YjjoXELTcY+W G0wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691769535; x=1692374335; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cLaLRYF1JduC+QzJ6GmQvAFgWnOUNDuN5FR0KZ2xx0A=; b=UHGP4r9YmG/5klnsq+6zcuEodRI9jqcujWcViQrxxXs52bygvP+cygUN/yrrXZMAoy anxfqU1Sy7vg+hNs0sibGkOfiX8m3ZqqbbExvdPLaMXT1A43TMhtTAxV16sCL27KCM5k l7i9ErcL/UIGhDp9XcS0PIQ0aHBXzFAX0IuqAMvgLcPjOgLSD90HYZv2BDNWUIs6e70g hs42CuAT3kXY2M9CyMHAIDXm/b5KIC3Dl/mUKAqpdQOJeVCbWN5z+hyvy60Ib/8m0gJq ufifc44tlfcmw90Oi6j5U/MIZIPJdi6M/KUGF/57AZ/lM15SEwJsJfo872h/EorEVmb2 svZg== X-Gm-Message-State: AOJu0YwkpdDZtxUMJzySKfjldke+IyDKeP7aj6LVRQ4Lgy9/V9htM7Ry dJxTtUgOgp11MYh/wLJaJ4M2pw== X-Received: by 2002:a05:6000:1086:b0:317:594a:dbde with SMTP id y6-20020a056000108600b00317594adbdemr1777929wrw.20.1691769534752; Fri, 11 Aug 2023 08:58:54 -0700 (PDT) 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 m12-20020a5d4a0c000000b00317e9c05d35sm5834308wrq.85.2023.08.11.08.58.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 08:58:54 -0700 (PDT) From: Matthieu Baerts Date: Fri, 11 Aug 2023 17:57:26 +0200 Subject: [PATCH net-next 13/14] mptcp: get rid of msk->subflow MIME-Version: 1.0 Message-Id: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-13-36183269ade8@tessares.net> References: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> In-Reply-To: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Matthieu Baerts X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=5387; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=JOoJwlBZFYBUmiOmWbe7z+i/oWAb6YdcTuPbi7SJfsk=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBk1lqv+QeEPuMBcjYRKmzxcRYgSkRQXDk9iGBun vM2a5KezHSJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZNZarwAKCRD2t4JPQmmg cyamD/wLack7Ml/PVH4WCAUD77D7IUrXDx2QwvmPDDPIrBy8extCVuY65SVGbf4MLGWc5VLR4Fh /+pyJCyslnWNGjIhYp5fzJMNKBO0XVCTaaa8g+TV1umSei3ZcF92+m08Jf1PgANT7J/70WzSQKM iJj0NboA+2HnINHXUrb460QdHWDd0VGtp8Qp2ttCHOq8mKBg4LrhLPQW7D/DU1eSTfll+2u1atP KwV5wWXWbSuKGJxOAiGKMJmBQ0EHjNOHxCYf5/AKJesmv5i2L75pOqRhvYGWB0uaQqj3OZh6BFF 34Q1AxWzJzcBLQRljg1MYlb6isWqZrRefJZ2prthzJKk+OQ9ujOfGSp3li06eJBQyVgrvL+x2qc 5dzwRrHSGl1z16xFqiUzfW8oR8CZ7n5aBrU4l+a35VSVmP060bBiBp/0R+dkzJndam3XT4eEBsF A2Pcmog4QLppbn4fwvFmgESMqtauV0CEYzYcML3xvVz0m3Aa8IIdZzFrDkXvY5N5m/C2xxBnwBX SXPwgxC4dzyrJH4J1bGTCzAWtY6YtH10XLApj0TwuWwKqEt5h31iPq0V+N0vSl734jfVZ3wAT5X xMUhV5OMqjBDl2D7YjyMHXWUNA5zPgkMsOo1IyJ0wVRCq2GP2kEt0xBwyDwBYmvZzIGZjUsCjtW mBvQOALx7hmZd0Q== 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_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773949178857971628 X-GMAIL-MSGID: 1773955312446628252 From: Paolo Abeni Such field is now unused just as a flag to control the first subflow deletion at close() time. Introduce a new bit flag for that and finally drop the mentioned field. As an intended side effect, now the first subflow sock is not freed before close() even for passive sockets. The msk has no open/active subflows if the first one is closed and the subflow list is singular, update accordingly the state check in mptcp_stream_accept(). Among other benefits, the subflow removal, reduces the amount of memory used on the client side for each mptcp connection, allows passive sockets to go through successful accept()/disconnect()/connect() and makes return error code consistent for failing both passive and active sockets. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/290 Signed-off-by: Paolo Abeni Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 25 ++++++------------------- net/mptcp/protocol.h | 13 ++++++------- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index fafa83ee4a72..e715771ded7c 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -92,7 +92,6 @@ static int __mptcp_socket_create(struct mptcp_sock *msk) msk->scaling_ratio = tcp_sk(ssock->sk)->scaling_ratio; WRITE_ONCE(msk->first, ssock->sk); - WRITE_ONCE(msk->subflow, ssock); subflow = mptcp_subflow_ctx(ssock->sk); list_add(&subflow->node, &msk->conn_list); sock_hold(ssock->sk); @@ -102,6 +101,7 @@ static int __mptcp_socket_create(struct mptcp_sock *msk) /* This is the first subflow, always with id 0 */ subflow->local_id_valid = 1; mptcp_sock_graft(msk->first, sk->sk_socket); + iput(SOCK_INODE(ssock)); return 0; } @@ -2238,14 +2238,6 @@ static struct sock *mptcp_subflow_get_retrans(struct mptcp_sock *msk) return min_stale_count > 1 ? backup : NULL; } -static void mptcp_dispose_initial_subflow(struct mptcp_sock *msk) -{ - if (msk->subflow) { - iput(SOCK_INODE(msk->subflow)); - WRITE_ONCE(msk->subflow, NULL); - } -} - bool __mptcp_retransmit_pending_data(struct sock *sk) { struct mptcp_data_frag *cur, *rtx_head; @@ -2324,7 +2316,7 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk, goto out_release; } - dispose_it = !msk->subflow || ssk != msk->subflow->sk; + dispose_it = msk->free_first || ssk != msk->first; if (dispose_it) list_del(&subflow->node); @@ -2345,7 +2337,6 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk, * disconnect should never fail */ WARN_ON_ONCE(tcp_disconnect(ssk, 0)); - msk->subflow->state = SS_UNCONNECTED; mptcp_subflow_ctx_reset(subflow); release_sock(ssk); @@ -3106,7 +3097,6 @@ struct sock *mptcp_sk_clone_init(const struct sock *sk, msk = mptcp_sk(nsk); msk->local_key = subflow_req->local_key; msk->token = subflow_req->token; - WRITE_ONCE(msk->subflow, NULL); msk->in_accept_queue = 1; WRITE_ONCE(msk->fully_established, false); if (mp_opt->suboptions & OPTION_MPTCP_CSUMREQD) @@ -3240,10 +3230,8 @@ static void mptcp_destroy(struct sock *sk) { struct mptcp_sock *msk = mptcp_sk(sk); - /* clears msk->subflow, allowing the following to close - * even the initial subflow - */ - mptcp_dispose_initial_subflow(msk); + /* allow the following to close even the initial subflow */ + msk->free_first = 1; mptcp_destroy_common(msk, 0); sk_sockets_allocated_dec(sk); } @@ -3782,11 +3770,10 @@ static int mptcp_stream_accept(struct socket *sock, struct socket *newsock, /* Do late cleanup for the first subflow as necessary. Also * deal with bad peers not doing a complete shutdown. */ - if (msk->first && - unlikely(inet_sk_state_load(msk->first) == TCP_CLOSE)) { + if (unlikely(inet_sk_state_load(msk->first) == TCP_CLOSE)) { __mptcp_close_ssk(newsk, msk->first, mptcp_subflow_ctx(msk->first), 0); - if (unlikely(list_empty(&msk->conn_list))) + if (unlikely(list_is_singular(&msk->conn_list))) inet_sk_state_store(newsk, TCP_CLOSE); } } diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index dccc96dc2d6b..38c7ea013361 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -299,7 +299,8 @@ struct mptcp_sock { cork:1, nodelay:1, fastopening:1, - in_accept_queue:1; + in_accept_queue:1, + free_first:1; struct work_struct work; struct sk_buff *ooo_last_skb; struct rb_root out_of_order_queue; @@ -308,12 +309,10 @@ struct mptcp_sock { struct list_head rtx_queue; struct mptcp_data_frag *first_pending; struct list_head join_list; - struct socket *subflow; /* outgoing connect/listener/!mp_capable - * The mptcp ops can safely dereference, using suitable - * ONCE annotation, the subflow outside the socket - * lock as such sock is freed after close(). - */ - struct sock *first; + struct sock *first; /* The mptcp ops can safely dereference, using suitable + * ONCE annotation, the subflow outside the socket + * lock as such sock is freed after close(). + */ struct mptcp_pm_data pm; struct { u32 space; /* bytes copied in last measurement window */ From patchwork Fri Aug 11 15:57:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 134584 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1214175vqi; Fri, 11 Aug 2023 09:31:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxtGFHDSLR9uV2HKNWd5cGAk7+KmFb8EPpCBEUB+GjLgCoOvFMTt405Dr1uVp/HVG2B292 X-Received: by 2002:a17:907:7858:b0:99a:7ff1:9b5a with SMTP id lb24-20020a170907785800b0099a7ff19b5amr2227452ejc.4.1691771488577; Fri, 11 Aug 2023 09:31:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691771488; cv=none; d=google.com; s=arc-20160816; b=pbBo7pQkFo/PyVSrcqFyZHgfai40iZfeLmJp3OznAQnwCIPpYdqs2wkGJFWKlTNNl0 F4zLcsqnGbfoVvK8NXca4Ymmhuemj/+3d7xZed9eds0xBFoAh8OA5DQUz0qkdvt9hu+l /QeRIZJrIg2afxdCH4hz/eZgIwhVQfWL33xWUYinIG6E0DumI9tz43IpvRLXRpdM0YRv PCufhDiHczQ10CybM9/y7+75O2iTDjFY06QWnKi7rQ6JE7k7OqIa+yxjZVkW2XveTi8G 7a2REfwqk+C8arkjXFjD+AYi+pp8hINGgKBd+Ed8NcweH+2gkMP7vU9hZPxSIZShQxYc JBWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=t+XgaLGpUVP+G9qnOB0ZNXJDWKPyu+7aNgrOOBV4CXs=; fh=42M7BrMwBStMUi3jpqhw+75pMDBk/q49CsOT5xjniSw=; b=uxsmCS1cTuVRZbzmJWmy7YMTUisdlaszKznLV94JeNB+GNxeejMC1bOtsOuCjRnkQ0 nDNKJtLU+K9jjxaOFm9FawR3BHYNzcxGkUTMKv8cvu7HTUXa7nn853p2fzr807ogxnMY WmvtC43x2JT6H3FujVjTJ5ZIqLKRvhUVqd8e7A1vkvUt8lnBvcI43Yyv2jX0lMRsXtsh UezxK7ECfNxAiw81QzJN5HeFGgB2OCFKdHmBOJA/36i1Epvh9KvTyU7c6vQGuzbMVqP9 6squXIkudsW7XMxbveKzqXBlJCg9NSVBCQO/1CtS2LLQYIyQ5CG+im5hcM6QdIN3hiJA k4rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=Wge3t0yM; 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=REJECT sp=REJECT 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 cd24-20020a170906b35800b0099cdab19fd5si3502741ejb.1034.2023.08.11.09.30.43; Fri, 11 Aug 2023 09:31:28 -0700 (PDT) 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=Wge3t0yM; 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=REJECT sp=REJECT dis=NONE) header.from=tessares.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236745AbjHKP7U (ORCPT + 99 others); Fri, 11 Aug 2023 11:59:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236751AbjHKP7A (ORCPT ); Fri, 11 Aug 2023 11:59:00 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A55830E5 for ; Fri, 11 Aug 2023 08:58:57 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3090d3e9c92so1898081f8f.2 for ; Fri, 11 Aug 2023 08:58:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1691769536; x=1692374336; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=t+XgaLGpUVP+G9qnOB0ZNXJDWKPyu+7aNgrOOBV4CXs=; b=Wge3t0yMVuay4tm8zdBQ9VyeL6OLJAnYtN8V9iwiqU8TvRM5ND9ERv/8i2Y0FArvFQ tyG+3O1nerD6rcqBCbg2Yxi/GEjlgN0VeHNCzZWoK8KmI2UeXphNC4ct39rAWNHhOq6n g3MxOHl1F/R3iVZaFvULiNeXrTd5HPlV4+zO97TksYClBrDGyBmm4kRFzTQccpHZLLyG jXFYRE99H23TempgCoan3vs01e8+KRWka4tBP479RADB9zjrIIFJ64LnP/2iwPPymaWX OkJg6VAAsx3QO7crW4QlH020KhacJUh6CmeEv8xlivqVhmJYQ7RUE1o45BE134rD1wev Scgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691769536; x=1692374336; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=t+XgaLGpUVP+G9qnOB0ZNXJDWKPyu+7aNgrOOBV4CXs=; b=Xk2ncjNSLBbJG4x+w/eAoEnJ32BrbqsaNeeOkVI5fGe2KPX8V3miUV9rp1zN8qZVPu 2+iLzNNg8t3KrFaqn72/6SW0Im4tvbcKlNSBOqPa9diivfyp+xUlip6qB/Sf9yxVlIHM 9vJ3R5SJFZLtmyNnooL/Mj1bcZ4SXG2ZuW2kvU+RtaXUY8tkjskSDyoqAFwpQZydUudh C/ph1xQPRwICZFxuWcu0oMc+Xs3w9yJO/PvLFC6gMuo9Wk18FKsHiHwY226S3Dt8dsC3 2rCs9hgWbC6xsW7vdxoykiPF+kDr+KVAJxZT4dwkTiYBq065NXJXtuwmRX/0dvWineA1 vdOg== X-Gm-Message-State: AOJu0YxcaypUJd/uQVqTNKVQmJB+3DUlYfJZ8ZBD8DfwAMCA7N/35HA2 oNU0XxBycwYl3F34trdeo9sXjA== X-Received: by 2002:adf:dccd:0:b0:317:5a9b:fcec with SMTP id x13-20020adfdccd000000b003175a9bfcecmr1553679wrm.14.1691769536025; Fri, 11 Aug 2023 08:58:56 -0700 (PDT) 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 m12-20020a5d4a0c000000b00317e9c05d35sm5834308wrq.85.2023.08.11.08.58.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Aug 2023 08:58:55 -0700 (PDT) From: Matthieu Baerts Date: Fri, 11 Aug 2023 17:57:27 +0200 Subject: [PATCH net-next 14/14] mptcp: Remove unnecessary test for __mptcp_init_sock() MIME-Version: 1.0 Message-Id: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-14-36183269ade8@tessares.net> References: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> In-Reply-To: <20230811-upstream-net-next-20230811-mptcp-get-rid-of-msk-subflow-v1-0-36183269ade8@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , David Ahern Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Matthieu Baerts , Kuniyuki Iwashima X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1657; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=9eUzQsTH9C4lw0Wrk8AIKRJ6c0bqe3QPvYFbn9S2V3Q=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBk1lqwU7yF3k2xiGkkBmwynf1c4Z1lknA9Khwon buB7uDg15eJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZNZasAAKCRD2t4JPQmmg c53oD/9Cm0tzdEzZtSh2bD4u/FrbdFha+H7oI7jW05zlpsFeQAA3EQLy5H58wxt8lTY6tbB3ENZ MHZa6zrGYtWnVl3BEO8/JPEa1wSXa2BT+Ke/fk2NRWhHV8w/7w426oiEurwvMZgpU2U/l6rlpFi 3vRvAO8KgA1CDraah31q+rj0LD40A//lSUC5rcG/XtrqIduqvyo/Mb0+sqQ66guhuzAPYRGj1Qk 3A0OAwr9kMd6ie34lrH4wle2YQnZku78y5+KjTPgKR3/m+tdn4AtwdqvsGHZsxjwRf9GwgUeXsU jkwWJSEN5bHVOChix6B/qGM8ziHaGa+Icc23/wR1ZMBRfhzD6i5NuljgtALxngwomGPkaMHZUCy 7pgM497BTMGffB7C7NPkHSuYmykvz+xAlJgcTLgLL83dweYf6NoFvRgie/vjHwBc4m+MooOJhZy jdGsO7K8gEB94e6a34UTYdtZAtiyUABk/qr2KYHzdU4zdOT05/7V14EJZRXdR8ZT8CakcEBP7XG fJdRjfUt7lnMcpGT5hKYMGqP8ZSmkTY4SN+j7kE0/8jNzYkifmuiSgp773MGvtbrDf0ONREBNBL Hr6lp1QGjLPxsdtKiHaEbI4NW5pl3ZmwlvQ5wKs80e9cM2+PJFX6+1Dn20Xdx8e3wrDIPF8dXbk eqm6CsASm8so4Og== 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,URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773950980478196324 X-GMAIL-MSGID: 1773950980478196324 From: Kuniyuki Iwashima __mptcp_init_sock() always returns 0 because mptcp_init_sock() used to return the value directly. But after commit 18b683bff89d ("mptcp: queue data for mptcp level retransmission"), __mptcp_init_sock() need not return value anymore. Let's remove the unnecessary test for __mptcp_init_sock() and make it return void. Signed-off-by: Kuniyuki Iwashima Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts --- net/mptcp/protocol.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index e715771ded7c..6ea0a1da8068 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2649,7 +2649,7 @@ static void mptcp_worker(struct work_struct *work) sock_put(sk); } -static int __mptcp_init_sock(struct sock *sk) +static void __mptcp_init_sock(struct sock *sk) { struct mptcp_sock *msk = mptcp_sk(sk); @@ -2676,8 +2676,6 @@ static int __mptcp_init_sock(struct sock *sk) /* re-use the csk retrans timer for MPTCP-level retrans */ timer_setup(&msk->sk.icsk_retransmit_timer, mptcp_retransmit_timer, 0); timer_setup(&sk->sk_timer, mptcp_timeout_timer, 0); - - return 0; } static void mptcp_ca_reset(struct sock *sk) @@ -2695,11 +2693,8 @@ static void mptcp_ca_reset(struct sock *sk) static int mptcp_init_sock(struct sock *sk) { struct net *net = sock_net(sk); - int ret; - ret = __mptcp_init_sock(sk); - if (ret) - return ret; + __mptcp_init_sock(sk); if (!mptcp_is_enabled(net)) return -ENOPROTOOPT;