From patchwork Thu Jun 8 13:20:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 104978 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3046:b0:115:7a1d:dabb with SMTP id p6csp326555rwl; Thu, 8 Jun 2023 06:24:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7sCYi/ilAJLMSf57C6Hsxgmkf+y4no1XOYgsgFA7Wei2gy3fs+j58W69LP6Vuj/hqReurN X-Received: by 2002:a17:902:b68d:b0:1ab:8f4:af2b with SMTP id c13-20020a170902b68d00b001ab08f4af2bmr3615416pls.38.1686230642842; Thu, 08 Jun 2023 06:24:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686230642; cv=none; d=google.com; s=arc-20160816; b=ApA1ZpJVrXKyLk8qj0IU+oqjjDcWM3EszEuUUDiaPMNA3VFnEmvj6zCqjGgj33jd3B 5zB/RGJRzOwtrCgT36NGP8ryOd8owQUA8YigrMn6CVyrcsOvBfPLQG928X5462J3A/cL OdK5NPNALlAGEFs97ZHElNPWfwh5GXmLl4DwgQ2NtvXfjmzjzIYhkxnjvLrhgApQyOhC SxjuOtX73lq4O8R7sRE93y8hQEQO2kcKTId0mI7W/QxLFREYpf6tiV+4ImhDOiuQWq4c zVwB5MdpBqmPTQXCjt48Ehqnto34XxgQByX/Js+4brRPU3Lf08cXS+SBGfMwbXK2avX2 Qc6g== 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=KhaoeTZksIn80amAPN23tQL1E6Mg1h/yTJF6X95xsdA=; b=uEOmcYuy7KVVo5yqrCXWDWS+aBU+p+Wc4OmPXZvsKk+ELLv4Oueu/1weKUtCGHF2JP sFG67nJRePoi+tw7vfMkKV1ipHJoq52GiG6vikzNn43Pf7IMfkYCNdkZolfIaSDPMVle NBkISXE2C1yps6Tp5ZM5qH3EIgDwkTJBZ6APMPg6PiSgW/pIb3jDj/Lv3jvYhL/3UZuo 3QD4rE88lWHkyKPTkeJ8gMDFWf+bS3rPbpQzTuf2cykYS13GhIgreNw/daOg38YvYP2Y WL1pUfjk4rIfzdpRnHyCgaJbi3qvu7biRF5ihb0G7j3c+7up674wbRYMBENdFdebwIt3 5xVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=z84ZpGUZ; 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 c8-20020a170902d48800b001b23ee377f4si1112270plg.271.2023.06.08.06.23.47; Thu, 08 Jun 2023 06:24:02 -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=z84ZpGUZ; 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 S235905AbjFHNVR (ORCPT + 99 others); Thu, 8 Jun 2023 09:21:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234893AbjFHNVO (ORCPT ); Thu, 8 Jun 2023 09:21:14 -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 E5C7726B2 for ; Thu, 8 Jun 2023 06:21:12 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3f6d7abe934so3960095e9.2 for ; Thu, 08 Jun 2023 06:21:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1686230471; x=1688822471; 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=KhaoeTZksIn80amAPN23tQL1E6Mg1h/yTJF6X95xsdA=; b=z84ZpGUZD+SoR2l0mm/WX8KCJV1wk0b43QiO/RkCyFd50gka6DenhY2SkjvX95BTJ9 /WyuVZmLaiSm34TCH17AS4AdNWMWEhIgVpnTw3ltoTeI+DHO39BvqbLMuY8EMAKmaaky paobvax5r5jrirXch9eXe4rxOg6x1K7d1m7YWmfOyOIKgdIP/+oA0TJwE6jWovzkkdX7 pVa5BdoLcV3ix17y79ttEusCbrZeIeKth4TcZWw9Ym0SYizKWoSceJjhG2R8KGTBdBV9 ac6EU6WW0/Vz1BSFZCj07vHK+qp4iiV8epk++pot0fCMcPU1X/gc2fzHlbOJV7vXBnQg UD0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686230471; x=1688822471; 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=KhaoeTZksIn80amAPN23tQL1E6Mg1h/yTJF6X95xsdA=; b=O1EKSpfn8AR0sNFJsPgI795amtFgnfKf8AO+wvI1mmQ82qziNPTpmDhvwkKGbZP3vA bV75TqjcG8ku3ZAybyvR/rKgmWDvKUHzmis35YNEqYO0eGGPMK6+3E0zJMPe3Dy0Amvm 6+m9KeDFRdB318Flmu4kiolICvY1mGW3lYy2ujFL2ktIaS7vhohVEhhhTH+1Iz+56Yug csEcuImhNKt87yvgvc+nWSzgArplbR7ZA/cDJ11zvHbWa3KLc4hrz5YkKpi0uMkboQed Xqq6AMa2zlSH85ZSfPGfr66ywtAMA3W2YYP3CrKeghRPrJh5EU+Ocw3dvlhrm7zL010e 86eg== X-Gm-Message-State: AC+VfDzThc8Qb8gXb66kLTdZwaWsHuoJZWFKS3XAChxPN3gbByRUUi3R SmhLhS3g+zRSqMYUutw/a4bQymvqTFdQ8oYru4JbHQ== X-Received: by 2002:a05:600c:2148:b0:3f6:e13:b268 with SMTP id v8-20020a05600c214800b003f60e13b268mr1466363wml.22.1686230471465; Thu, 08 Jun 2023 06:21:11 -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 16-20020a05600c021000b003f7f1b3aff1sm5001100wmi.26.2023.06.08.06.21.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 06:21:10 -0700 (PDT) From: Matthieu Baerts Date: Thu, 08 Jun 2023 15:20:49 +0200 Subject: [PATCH net-next 1/4] mptcp: export local_address MIME-Version: 1.0 Message-Id: <20230608-upstream-net-next-20230608-mptcp-unify-pm-interfaces-v1-1-b301717c9ff5@tessares.net> References: <20230608-upstream-net-next-20230608-mptcp-unify-pm-interfaces-v1-0-b301717c9ff5@tessares.net> In-Reply-To: <20230608-upstream-net-next-20230608-mptcp-unify-pm-interfaces-v1-0-b301717c9ff5@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Geliang Tang , Matthieu Baerts X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3955; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=l/jGQDI6Wt0DGeE+EQbUTZRRGJNBQ8M0TmciTMimsH0=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkgdXF2dATrt1k6R8plFmN8YuqD23J2mPMTIU61 TUKbXRcPKiJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZIHVxQAKCRD2t4JPQmmg czfBEACo7eQ0NVkbvNrezSrhGOLT4aK9BfzKo+4EB8n96i3gUZ2j++5wVPgkILBk5SIjysunUSL T/E+lXs0BNDicXhww6kGFQjltK66kKcCNaV5/h8z6dZof62rYRLjSKZOggD8ct3y/3JLSUvahNt KGbYtgVqt8q7S9R1MWkBivbFQufl9irsI6KV68uK6evPOl6wlaL4R42p7BcM2OxqFrYI/cB/ib8 GTH3gp8vtwKdNOlknU+KzOlAkjR7amGO7FSHdki683JNae/ZK/v3vwC6ZCAtlp3WIYtM2No8fFS pDpiB3olHMgqzTDOvOkNdJa/DTodXX5wy8kf7jjBePHSqoGWZMniApm0heE/Ise9CREbK8ucaGC kQYgIbc7DcavGlIoStQjNP30IxJ7LTAWozqD8Mc5twi5YkEduXO+96F8py4y2dTjgTmPvx3J7Xj 9VeDjiZlN59VBT8yHDDu8Wjb8zB05lO76hsL6pXCls/4eR88mggOhjY2u8/esfJjzQGqa+dLzis WPqRIQyBXql7TlL60VCPfCNjUp6npDVEu4V9IN2ANcD3H+3bNJF8+6VJWtnqhm/tWFNZzEYZofS Ecy1kkIXEEMcsvwvSb8acPhZk8rTamJuXuC3Kl0wft/QoWuDOJNa6ToQlbxaq2/Cr7lToV06Li1 lJNm86sxNBNu+6g== 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,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768140982449249947?= X-GMAIL-MSGID: =?utf-8?q?1768140982449249947?= From: Geliang Tang Rename local_address() with "mptcp_" prefix and export it in protocol.h. This function will be re-used in the common PM code (pm.c) in the following commit. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts Reviewed-by: Larysa Zaremba --- net/mptcp/pm_netlink.c | 17 ++++++++--------- net/mptcp/protocol.h | 1 + 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index bc343dab5e3f..c55ed3dda0d8 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -86,8 +86,7 @@ bool mptcp_addresses_equal(const struct mptcp_addr_info *a, return a->port == b->port; } -static void local_address(const struct sock_common *skc, - struct mptcp_addr_info *addr) +void mptcp_local_address(const struct sock_common *skc, struct mptcp_addr_info *addr) { addr->family = skc->skc_family; addr->port = htons(skc->skc_num); @@ -122,7 +121,7 @@ static bool lookup_subflow_by_saddr(const struct list_head *list, list_for_each_entry(subflow, list, node) { skc = (struct sock_common *)mptcp_subflow_tcp_sock(subflow); - local_address(skc, &cur); + mptcp_local_address(skc, &cur); if (mptcp_addresses_equal(&cur, saddr, saddr->port)) return true; } @@ -263,7 +262,7 @@ bool mptcp_pm_sport_in_anno_list(struct mptcp_sock *msk, const struct sock *sk) struct mptcp_addr_info saddr; bool ret = false; - local_address((struct sock_common *)sk, &saddr); + mptcp_local_address((struct sock_common *)sk, &saddr); spin_lock_bh(&msk->pm.lock); list_for_each_entry(entry, &msk->pm.anno_list, list) { @@ -541,7 +540,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) struct mptcp_addr_info mpc_addr; bool backup = false; - local_address((struct sock_common *)msk->first, &mpc_addr); + mptcp_local_address((struct sock_common *)msk->first, &mpc_addr); rcu_read_lock(); entry = __lookup_addr(pernet, &mpc_addr, false); if (entry) { @@ -752,7 +751,7 @@ int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk, struct sock *ssk = mptcp_subflow_tcp_sock(subflow); struct mptcp_addr_info local, remote; - local_address((struct sock_common *)ssk, &local); + mptcp_local_address((struct sock_common *)ssk, &local); if (!mptcp_addresses_equal(&local, addr, addr->port)) continue; @@ -1070,8 +1069,8 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc) /* The 0 ID mapping is defined by the first subflow, copied into the msk * addr */ - local_address((struct sock_common *)msk, &msk_local); - local_address((struct sock_common *)skc, &skc_local); + mptcp_local_address((struct sock_common *)msk, &msk_local); + mptcp_local_address((struct sock_common *)skc, &skc_local); if (mptcp_addresses_equal(&msk_local, &skc_local, false)) return 0; @@ -1491,7 +1490,7 @@ static int mptcp_nl_remove_id_zero_address(struct net *net, if (list_empty(&msk->conn_list) || mptcp_pm_is_userspace(msk)) goto next; - local_address((struct sock_common *)msk, &msk_local); + mptcp_local_address((struct sock_common *)msk, &msk_local); if (!mptcp_addresses_equal(&msk_local, addr, addr->port)) goto next; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index c5255258bfb3..6e6cffc04ced 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -638,6 +638,7 @@ void mptcp_set_owner_r(struct sk_buff *skb, struct sock *sk); bool mptcp_addresses_equal(const struct mptcp_addr_info *a, const struct mptcp_addr_info *b, bool use_port); +void mptcp_local_address(const struct sock_common *skc, struct mptcp_addr_info *addr); /* called with sk socket lock held */ int __mptcp_subflow_connect(struct sock *sk, const struct mptcp_addr_info *loc, From patchwork Thu Jun 8 13:20:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 104979 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3046:b0:115:7a1d:dabb with SMTP id p6csp326663rwl; Thu, 8 Jun 2023 06:24:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ75GEXMhb0i17WspHG7m+geFKz6yVBGZBtjzNywKyHU+de27yjjHy0UHu9w5tXE+YLzNCwo X-Received: by 2002:a05:6a20:158d:b0:117:71bf:a58a with SMTP id h13-20020a056a20158d00b0011771bfa58amr3855653pzj.17.1686230653586; Thu, 08 Jun 2023 06:24:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686230653; cv=none; d=google.com; s=arc-20160816; b=sYJf6ThuwWAxmF5w8M8O/zZWFcIfxJ9FaWzcWIEFlzO+7yPr+ILkdxY/dMAHqMn5Ct ejSeo7yNmnpr7LCv7tPUego//KGON7b/UC5Tui8+KtcmJe1NIOrtQWuv1ghIu+I7oDZE I1KyxYNmRGDoqox5U2dWXb2zmRKSOs9W6ta1M55kpmGRH5PbaC3lyRBOVrj6u/OYzWnn t4HDQF4P+w8L7gl+4rh+m5TTyVFoMOdIp/3TEbWHFUYa7OMzms538Ra9m6qY9WMXfL94 KgxS+06GgLgwQAz62wY2cajTwfi1pQ5ISD3zmandL5tp2xQX9lDTxS+3CKYUeytu/Ymm y5AA== 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=7gFKa9O69PK+PsR17eSXRUsf4u+mlPVa86DBx+jj43Q=; b=l//YlaYersFtRMean56Klj+JtcWHVIRRKKkdqiwVF1eQkImCJcnnS7CJJQw0GRbjzd LQpcGJRNiDHyopAlCRU/P1ugBtltwItBv1G2l7x1YFlfrMXyc+K27NJC6VpESHSHmhOY Mqn1CmMxK4YaLSZmRTPkeyKVXbJ0KXVEJI+ziK2Irzxla1HB7YAxaTL1posjQ5vNG18A O/2USyrWPP3cOEootXZX1xkZPICTBxrKHHtlb8mwi/0ruqiUe5jVQucEypkQup7dmNIi ztTO4K/XNHyVaHOWxV6Kav1Jmmf2SlgtqrL9rnJTk9DP+aaHE3Q2eN0TOvDACnXl+l7n 1CBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=E4kfzjF6; 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 c22-20020a621c16000000b0065ffb3568eesi827566pfc.208.2023.06.08.06.23.57; Thu, 08 Jun 2023 06:24:13 -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=E4kfzjF6; 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 S236474AbjFHNVW (ORCPT + 99 others); Thu, 8 Jun 2023 09:21:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236043AbjFHNVR (ORCPT ); Thu, 8 Jun 2023 09:21:17 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27F3F2121 for ; Thu, 8 Jun 2023 06:21:14 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3f732d37d7cso5276835e9.2 for ; Thu, 08 Jun 2023 06:21:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1686230472; x=1688822472; 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=7gFKa9O69PK+PsR17eSXRUsf4u+mlPVa86DBx+jj43Q=; b=E4kfzjF6nZ0wF9rrV3h9waQUQbC8N5mNdnn0mcMbM9TUZROyPEHiCRi76MCUAG4PbN sQIO50wLECEwLs9Wsh8PKXc7zvdYY6yLyd2vg8oeX0QJawQHYkZYerI4OG+sdc/uxQje KHpjbjFGOYKBD+qXAIXZGLYrM1rKbCdxP25iSLmBRzAsosajIalZhcjaayjG1twYXAuD CZETdSOCevHUe3sa4Ef9mbOPRiWaiMgbOuHxyiNg1w5DTzWRsaEH5Tx1pH7tCWgo+DvQ HxoZBFuH8u8ZTvz01ckLgVM006o5aDAthiwYbpZgRiiGh22L/rH2k4DJmwKRD1Y8ernG WO5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686230472; x=1688822472; 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=7gFKa9O69PK+PsR17eSXRUsf4u+mlPVa86DBx+jj43Q=; b=Z2q0ziMqFS2pjY9ckqfs/mAqyxN8DIh3cwSPPfyNZkk0Y2trJxxicF7xQ7D4wnTdet IgHklXib/fuJMXYr2hZNXnlxheUW+SEs5zxOlw3GI4kmJFYKcMu2VsCAs0QRRCA7X7Pv ugq8kFvnjVKWCOq19QN5QYDlg7+Bw8nNnuwkdNzI7gg7OV79VJgjdVESEmBQO2fR2cdj 27gzjrOxodDD8oK8V2Xi+1OxlTogwGDIN6dYN5L8qwdEVEtAvkN4XXT9GtF1YZ4ywVpJ g0xQ0NL6EVxP1EWmWjIXNSSYM0qerc01PiRvmNvXYp1YtZA11/vNAdeVHc1ADj7M/rLK WK/w== X-Gm-Message-State: AC+VfDyQCo/93trGQ2YjZn9u2ImIpEH7zGwwJOYysf9yvAI18/VtYtOM 7rt3BDrzKnvxU+T0Gq1R9fYnjw== X-Received: by 2002:a7b:c84c:0:b0:3f6:128:36a5 with SMTP id c12-20020a7bc84c000000b003f6012836a5mr1381810wml.10.1686230472470; Thu, 08 Jun 2023 06:21:12 -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 16-20020a05600c021000b003f7f1b3aff1sm5001100wmi.26.2023.06.08.06.21.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 06:21:12 -0700 (PDT) From: Matthieu Baerts Date: Thu, 08 Jun 2023 15:20:50 +0200 Subject: [PATCH net-next 2/4] mptcp: unify pm get_local_id interfaces MIME-Version: 1.0 Message-Id: <20230608-upstream-net-next-20230608-mptcp-unify-pm-interfaces-v1-2-b301717c9ff5@tessares.net> References: <20230608-upstream-net-next-20230608-mptcp-unify-pm-interfaces-v1-0-b301717c9ff5@tessares.net> In-Reply-To: <20230608-upstream-net-next-20230608-mptcp-unify-pm-interfaces-v1-0-b301717c9ff5@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Geliang Tang , Matthieu Baerts X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4622; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=tn1Eikl6cGHxV4McPMlmq9kj3EGuMT4TIu0o5dG+VYc=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkgdXFFY+V5/S/ntKomdIzFWXBuGXZ1FTeoQ+Zf 40xdMwPeT+JAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZIHVxQAKCRD2t4JPQmmg c43TD/4+6+HGmxLfwEtatupGtboJRGks2iO20DsIlcDpFqXOHDlTEM4gR2ArlgKdVOFJmfdS+YE Q+xyN+VNYoNeAnHF6OXNStzwihTKHEBEE+hMXo/OD1RmIhCrrhSAIoeomLSr765OfvH6q+/8DAg kJJv3jJUjhDTTpfhL5meqYp3T/E0gSycklY4EM0dvEzUa2STYrri9BE14zJVYLTsKb7DicnvXwZ m6R0QxoT/eR9stCmqH2gi8Q//7lSZuRRPWTDh+zAKDvz0SsJyyfkhrZQw7puJJnPb7nlUcvHtfR vT04u2vYC+18dkGrVJJxiTq4gkkkXk4xd65QAWJxegRuoEU50Y/ZXg9++Fl4eUorIrRipBPou9i M0vqbDBaC74oUP5Te6gWwMzlaEU/ZROkHlHa1NqDFIgL+0jwujr4jFI3Hhq9iRGWMI8Xa1CGQLA OauclSl8BTUIn8hY6IsiLzLrXgHsRujKPTnCcQh6CHmc5I76G9D1Q8TeGG1mtYYKMLgJXqL8XOJ dHoSkDg0Q+j2Oya1TO/rNjOMqnDtw5rRmL0UjxYEiseixoolbUZIOovxIWz47BQY9w9PidV114G l7cBS58jIqrqb7e2TqyOpnLiTxzzSZdndnuGfcRscF+E5Hy/u0enLjUAYk+GHCNNN9u0zqSTXb3 6T9BwH+atG1C46Q== 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,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768140994065141367?= X-GMAIL-MSGID: =?utf-8?q?1768140994065141367?= From: Geliang Tang This patch unifies the three PM get_local_id() interfaces: mptcp_pm_nl_get_local_id() in mptcp/pm_netlink.c for the in-kernel PM and mptcp_userspace_pm_get_local_id() in mptcp/pm_userspace.c for the userspace PM. They'll be switched in the common PM infterface mptcp_pm_get_local_id() in mptcp/pm.c based on whether mptcp_pm_is_userspace() or not. Also put together the declarations of these three functions in protocol.h. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts Reviewed-by: Larysa Zaremba --- net/mptcp/pm.c | 18 +++++++++++++++++- net/mptcp/pm_netlink.c | 22 +++------------------- net/mptcp/protocol.h | 2 +- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 7d03b5fd8200..5a027a46196c 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -400,7 +400,23 @@ bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining, int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc) { - return mptcp_pm_nl_get_local_id(msk, skc); + struct mptcp_addr_info skc_local; + struct mptcp_addr_info msk_local; + + if (WARN_ON_ONCE(!msk)) + return -1; + + /* The 0 ID mapping is defined by the first subflow, copied into the msk + * addr + */ + mptcp_local_address((struct sock_common *)msk, &msk_local); + mptcp_local_address((struct sock_common *)skc, &skc_local); + if (mptcp_addresses_equal(&msk_local, &skc_local, false)) + return 0; + + if (mptcp_pm_is_userspace(msk)) + return mptcp_userspace_pm_get_local_id(msk, &skc_local); + return mptcp_pm_nl_get_local_id(msk, &skc_local); } void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index c55ed3dda0d8..315ad669eb3c 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1055,33 +1055,17 @@ static int mptcp_pm_nl_create_listen_socket(struct sock *sk, return 0; } -int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc) +int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc) { struct mptcp_pm_addr_entry *entry; - struct mptcp_addr_info skc_local; - struct mptcp_addr_info msk_local; struct pm_nl_pernet *pernet; int ret = -1; - if (WARN_ON_ONCE(!msk)) - return -1; - - /* The 0 ID mapping is defined by the first subflow, copied into the msk - * addr - */ - mptcp_local_address((struct sock_common *)msk, &msk_local); - mptcp_local_address((struct sock_common *)skc, &skc_local); - if (mptcp_addresses_equal(&msk_local, &skc_local, false)) - return 0; - - if (mptcp_pm_is_userspace(msk)) - return mptcp_userspace_pm_get_local_id(msk, &skc_local); - pernet = pm_nl_get_pernet_from_msk(msk); rcu_read_lock(); list_for_each_entry_rcu(entry, &pernet->local_addr_list, list) { - if (mptcp_addresses_equal(&entry->addr, &skc_local, entry->addr.port)) { + if (mptcp_addresses_equal(&entry->addr, skc, entry->addr.port)) { ret = entry->addr.id; break; } @@ -1095,7 +1079,7 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc) if (!entry) return -ENOMEM; - entry->addr = skc_local; + entry->addr = *skc; entry->addr.id = 0; entry->addr.port = 0; entry->ifindex = 0; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 6e6cffc04ced..8a2e01d10582 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -916,13 +916,13 @@ bool mptcp_pm_add_addr_signal(struct mptcp_sock *msk, const struct sk_buff *skb, bool mptcp_pm_rm_addr_signal(struct mptcp_sock *msk, unsigned int remaining, struct mptcp_rm_list *rm_list); int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc); +int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc); int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc); void __init mptcp_pm_nl_init(void); void mptcp_pm_nl_work(struct mptcp_sock *msk); void mptcp_pm_nl_rm_subflow_received(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list); -int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct sock_common *skc); unsigned int mptcp_pm_get_add_addr_signal_max(const struct mptcp_sock *msk); unsigned int mptcp_pm_get_add_addr_accept_max(const struct mptcp_sock *msk); unsigned int mptcp_pm_get_subflows_max(const struct mptcp_sock *msk); From patchwork Thu Jun 8 13:20:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 104981 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp283856vqr; Thu, 8 Jun 2023 06:39:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7T9gUmeRX/b3yiao/u36M7rVAO14o/Yrsdvc0NY9kbuISb8oYn+NC7AP7P0VAqz4hJjFKS X-Received: by 2002:a05:6a20:7f93:b0:118:62d9:b0a6 with SMTP id d19-20020a056a207f9300b0011862d9b0a6mr3984457pzj.4.1686231545412; Thu, 08 Jun 2023 06:39:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686231545; cv=none; d=google.com; s=arc-20160816; b=lc68dBJtb+2MYnU4fjzTEaSz0bxNbwSgg68m4+avgDWwYUcg7DnsR0CUpUIo2k+Lc1 OTPM3G0sdahuZSnPyuPpuyYnlMIlUccW9VOM1WLLKxa9/3OKttZaW7Hnh4O1g/sSNtej o8Qyv8uVs657anZKmnfEebj9m41Q0zzJ2ZJlFRyvxnY1LXfk4xWQkvHMVO2loEpExRtZ lWysiwSGDMGU7uPnuF4pkEGUoiFp8zNgbnMulapbTuyDYgl1XYNfENhm/FFZnHnX7iEo kPLYZZ2GoibUIfwYJHlDNsVLA3pHhq1L05/GjocQyDXsFAQXgkGWy05vQv1cuK5LhaSu uNew== 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=NSwaV8frgP+BsYdMJSEI28hJ+VH7kpitse/TkoXMDpU=; b=fyhZ6Xl3ZOuGhtILbm5xEyRU7plZ6YSl/2uAFdSd8mfXydTDkWEs8ntclY6CIa2Y2a GbRLL9bULwx9WfoF1HuxohUtpgWHfoWZNC0vfwe5jQzJwDL3pI6rI61YIkRAhYngWUCc Xd1Wcpyz2ntwE2my99EX+tC0jUtF3aT/QxAjxwhH21IZDu34KHJKeR7sIm6sQrylYXvl Goq6oBTXnuM8X4+J4SeHPpsvDftHVvE2bIYXRZR/Uj9J1efLSrvByankwfYSzkIRPtwR spU2jAnVFHAumcH0b+gDm8o4IY0wu7sCz5nT4NxjagS3PerbhhrExw+Z/ZVLRIyfbRic RQYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=rilF142T; 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 r30-20020a638f5e000000b0053ef5472639si960418pgn.489.2023.06.08.06.38.53; Thu, 08 Jun 2023 06:39:05 -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=rilF142T; 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 S236696AbjFHNV3 (ORCPT + 99 others); Thu, 8 Jun 2023 09:21:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236110AbjFHNVS (ORCPT ); Thu, 8 Jun 2023 09:21:18 -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 394C026BA for ; Thu, 8 Jun 2023 06:21:15 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3f730c1253fso3934085e9.1 for ; Thu, 08 Jun 2023 06:21:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1686230473; x=1688822473; 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=NSwaV8frgP+BsYdMJSEI28hJ+VH7kpitse/TkoXMDpU=; b=rilF142TtI9Re4yJ+CLPrruyPWByld4nvPKVBApP6xKp7kfR/KIPO7c/SrdtN47Q2t mC5TJOAvOuCUI8WGcjXz9Tm88ijvKDPIbP+3JC/hb/Zy87bgCL3c44YDbMA8WNFW9Kzo fE71XZWZ8NBkgj1pFJGWeSfTbDSSEnOIg5QaYpq4ZK+vK/AQ3ZcCSsm5aMcC2PbQUXUW 0KhA8ueN+rZ+pPOuOo5ym32tsBWQGQjOhBzrC5Uk7i0NWeaudcsFVC5UBH8X22aa5VSA 6liaOy2NBmOsNouz/JU8m6rLnBcVroho8ZxBWJ2m5NElSDZZpjVZRbkIhfko52Wg4u/8 OPiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686230473; x=1688822473; 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=NSwaV8frgP+BsYdMJSEI28hJ+VH7kpitse/TkoXMDpU=; b=UtVyugUHyO6QmAnSoGDApnoUP7gHzIFiUUC3nr9m//HGbtqfY0Bv8cI377/FwlUEBy wEynLUXiYHBQtayLP1HVD1qHKpTCRgO11+eHtrGJBz5fx2OyfiwGIeUo/W3GNRqETZgg YTZBJGm9X/EptW8IsKYpcETkDANFnuFJ9RAWGN2DWc568UeWJHeyjT8yHfijqDhp9TWB cvBp3wGcuf/PQ0vMIEzQmGHwIGm5Ni5oc7iZilC/iRisGeHhcouI2jOJcVO0DchMJEgB AB68x9T7b1unT3RnaFxrojYGaRe5UKX9Ksr40FsfLhOIa6wfAWSo3KHgVo0gl5D+NAru skaw== X-Gm-Message-State: AC+VfDzWtQdRItXgephiZ+/+xMP3d6tpZ+MlEeSVS2s767v6p2iRG1XV RxQVkfkt3fuxJVriOtyxzh2ctg== X-Received: by 2002:a1c:7c0d:0:b0:3f6:f152:1183 with SMTP id x13-20020a1c7c0d000000b003f6f1521183mr1441901wmc.37.1686230473699; Thu, 08 Jun 2023 06:21:13 -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 16-20020a05600c021000b003f7f1b3aff1sm5001100wmi.26.2023.06.08.06.21.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 06:21:13 -0700 (PDT) From: Matthieu Baerts Date: Thu, 08 Jun 2023 15:20:51 +0200 Subject: [PATCH net-next 3/4] mptcp: unify pm get_flags_and_ifindex_by_id MIME-Version: 1.0 Message-Id: <20230608-upstream-net-next-20230608-mptcp-unify-pm-interfaces-v1-3-b301717c9ff5@tessares.net> References: <20230608-upstream-net-next-20230608-mptcp-unify-pm-interfaces-v1-0-b301717c9ff5@tessares.net> In-Reply-To: <20230608-upstream-net-next-20230608-mptcp-unify-pm-interfaces-v1-0-b301717c9ff5@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Geliang Tang , Matthieu Baerts X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4069; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=5nDr9M7v5Mf80NDixMM7FPrdaFJMIldEDth/6RZgYhg=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkgdXFgoTtiSJCP9CGOJ/S5Y8wlsdZcfEsuGk0z vqPlL1i0HOJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZIHVxQAKCRD2t4JPQmmg c+sWD/91DLbuH2odrwHtoGbvYHh6JKcUMBF4JZuuj8Kqa91+9NrVaGqdy0inki2k9/vpH46Rvqu O0kABJTas7MMPwIYvxVQoY2VBdwNnKh65ADv4UCzElb/jIph6yr0EEQrAOZ8FhnhiQyfP1pLglP lsGwBvPrIUJkLMsWt8aaYBHb3Sg+dXN4OehZGULDnl2KbE633yMRr8+hn9hsHf0S0Y5sjIfJLGF pokZUAhDySwtRC284Oq/ea5AXYmrmzT7Js0I+dIFk3nTbw7JwMP3aZ8UPeC2dbZL/+WxSbyFQXF aXkEUkorTeesliyUHgx13TaEO45kUWECEhxQndDiIN/eXE5OBxn0CeyRXt82OAcwQs/INUQksON PbGW1Hnbxnzj6bvVNG+jHKVBs70D/r4watCKjJYRVqeoC++ndJ4HrDJuPdP1HFnbuW3HKUpTYw5 tKYQarydPhmD2btUaqUQB/aXPyegTC0RGAklanVIB8NLbKuRdcfKYJm1bhV8dKGYaI6F/WvNxnK yH765OZy6x667VWlcWdOrWufpAl9aJKSmjIQOxP6PaJNvZYpTnjlZRhQ+Uta5odYgyIYE8xyQ+p HHHOdad02GNDw4Fy5hraX1YRnBat/kScnEw9dXLkrT2BZaBLCYxw1WvyjnnFmJHtgOugXCCoUjL kXa3DTfQ6B062Lw== 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,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768141928956937259?= X-GMAIL-MSGID: =?utf-8?q?1768141928956937259?= From: Geliang Tang This patch unifies the three PM get_flags_and_ifindex_by_id() interfaces: mptcp_pm_nl_get_flags_and_ifindex_by_id() in mptcp/pm_netlink.c for the in-kernel PM and mptcp_userspace_pm_get_flags_and_ifindex_by_id() in mptcp/pm_userspace.c for the userspace PM. They'll be switched in the common PM infterface mptcp_pm_get_flags_and_ifindex_by_id() in mptcp/pm.c based on whether mptcp_pm_is_userspace() or not. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts Reviewed-by: Larysa Zaremba --- net/mptcp/pm.c | 14 ++++++++++++++ net/mptcp/pm_netlink.c | 27 ++++++++------------------- net/mptcp/pm_userspace.c | 3 --- net/mptcp/protocol.h | 2 ++ 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 5a027a46196c..2d04598dde05 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -419,6 +419,20 @@ int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc) return mptcp_pm_nl_get_local_id(msk, &skc_local); } +int mptcp_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id, + u8 *flags, int *ifindex) +{ + *flags = 0; + *ifindex = 0; + + if (!id) + return 0; + + if (mptcp_pm_is_userspace(msk)) + return mptcp_userspace_pm_get_flags_and_ifindex_by_id(msk, id, flags, ifindex); + return mptcp_pm_nl_get_flags_and_ifindex_by_id(msk, id, flags, ifindex); +} + void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk) { struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 315ad669eb3c..e8b32d369f11 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1356,31 +1356,20 @@ static int mptcp_nl_cmd_add_addr(struct sk_buff *skb, struct genl_info *info) return ret; } -int mptcp_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id, - u8 *flags, int *ifindex) +int mptcp_pm_nl_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id, + u8 *flags, int *ifindex) { struct mptcp_pm_addr_entry *entry; struct sock *sk = (struct sock *)msk; struct net *net = sock_net(sk); - *flags = 0; - *ifindex = 0; - - if (id) { - if (mptcp_pm_is_userspace(msk)) - return mptcp_userspace_pm_get_flags_and_ifindex_by_id(msk, - id, - flags, - ifindex); - - rcu_read_lock(); - entry = __lookup_addr_by_id(pm_nl_get_pernet(net), id); - if (entry) { - *flags = entry->flags; - *ifindex = entry->ifindex; - } - rcu_read_unlock(); + rcu_read_lock(); + entry = __lookup_addr_by_id(pm_nl_get_pernet(net), id); + if (entry) { + *flags = entry->flags; + *ifindex = entry->ifindex; } + rcu_read_unlock(); return 0; } diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 27a275805c06..e1df3a4a4f23 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -85,9 +85,6 @@ int mptcp_userspace_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, { struct mptcp_pm_addr_entry *entry, *match = NULL; - *flags = 0; - *ifindex = 0; - spin_lock_bh(&msk->pm.lock); list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) { if (id == entry->addr.id) { diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 8a2e01d10582..607cbd2ccb98 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -822,6 +822,8 @@ mptcp_lookup_anno_list_by_saddr(const struct mptcp_sock *msk, int mptcp_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id, u8 *flags, int *ifindex); +int mptcp_pm_nl_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id, + u8 *flags, int *ifindex); int mptcp_userspace_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id, u8 *flags, int *ifindex); From patchwork Thu Jun 8 13:20:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 104980 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3046:b0:115:7a1d:dabb with SMTP id p6csp326812rwl; Thu, 8 Jun 2023 06:24:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ41Xf5nnK+/cdWnL+FS/NOQttNX0qISEf1fqeG4d933ylfiiFPRwnwZOhA96IIoX5TOteco X-Received: by 2002:a05:6a21:3889:b0:114:7637:344f with SMTP id yj9-20020a056a21388900b001147637344fmr5773806pzb.49.1686230664287; Thu, 08 Jun 2023 06:24:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686230664; cv=none; d=google.com; s=arc-20160816; b=kzPRmtfakFg8lHDYgFGFV9aPYJRog+v9/+h6+IwcL1NFFjswwbZaTSEdlorl0PHIpL w0c1PEuQqWgdIXIQitafXQhQ5GiyrdkgjfHCd8JkRDDHXOxlTg66Yr1UbO8FgSnnwca0 M720hKJ5QSORJgXkERArzmLTbNbkcEDQQGxgJFUgOsUarPoUJ0vs0aP2A7alVpXplkOv TBn4eNQPoW/ci84vRoQLHLa6xoxx7rHA2b0AHSJyI9XOuLsb8yvvkzze0+y30pLCdmJ+ FaXtYoqA3TPIt7eze4H9el6yBUWzaqK358fZZ61EVT523CGGU6JefySqe7Md4XH1d63q Xhdg== 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=5dgkaWGIfYIbjljhSSlh7Bmui4uwpN0SWAU+QRT80As=; b=P9+kkylzP/FoQYHfMGP81Wy4cn41rBc7kEYC28K6ta+phpwOT38paQy55T12rzSKg0 VBk+Ud6tqTe9buoOtWa8V3TW1wtw5baTnOZSwksVagEFM3nu0ryJj2c7XjanKaIirngr lZnRV7PaLqsSN3tNiTSye0fOXdVjT+LRAIxlY9vKofuPN6S5D7/McltkbUug4bwBY4Fd 59/pIqmvYMOE/FdFDy/saMb7Q1Ie8dyRE1+4L7bHYgXkt+UTe3ZkP4Q598B354X1h+/s 4dslq/lquioVn/l/+h5HTJ0ACoX5LdjMfmrKxkADaGnvgnegOV+hB6pLxpwj8PxoEHEH mY+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tessares.net header.s=google header.b=qVAR2ecu; 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 a184-20020a624dc1000000b006519ca72dc6si826426pfb.161.2023.06.08.06.24.08; Thu, 08 Jun 2023 06:24:24 -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=qVAR2ecu; 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 S236509AbjFHNVZ (ORCPT + 99 others); Thu, 8 Jun 2023 09:21:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236211AbjFHNVT (ORCPT ); Thu, 8 Jun 2023 09:21:19 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 339852717 for ; Thu, 8 Jun 2023 06:21:16 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-3f732d37d7cso5277215e9.2 for ; Thu, 08 Jun 2023 06:21:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tessares.net; s=google; t=1686230474; x=1688822474; 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=5dgkaWGIfYIbjljhSSlh7Bmui4uwpN0SWAU+QRT80As=; b=qVAR2ecucVW+p4KXptaFvsaVrHzHixMpWlKsxEGJts241bm/oGRDCL1YLdMk7NZlka c16QlEhOhb8Xok7xMrxaLudpRz5AioYlJqP6RKZtwORKwyqWuRO6ydKSGlSQ+0Hrw13F iE855DdN7YYdoEtLEHn0GSSjAq+NTa1uVvWAocNBhMojymEbsxj3zjmUfhSM8CI8L3M7 UHttyyevHVgcUnAPGH3o6YvlrqMIiIj/PRX02FESZJqggOR3gU01o5+Nzqjat3GISqjL t9yo+J7RIiSAI16EgWM7bpAeEQDhPbcPWP/eUrzXdgvJGsWP2Iwsk8aAflxOTEPGaOjB pjSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686230474; x=1688822474; 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=5dgkaWGIfYIbjljhSSlh7Bmui4uwpN0SWAU+QRT80As=; b=WzStJaeBPZlhKX8JzjRrj5+2mwLMQg1mM/7Dxq+dF29kuMpmNJ+i5z64R494VaErDE 53fFoCsc8nwo6/hG9DQQ8oZoEhkKcLCUYikH8ksEQGf3r9xKQu63QJvVHNkLMPYciRkj XRbOrJLvkRoQhXYK9qxOBYPplurgbbJwbDaI8vRHb86AyQQaQl5faS8g+pU7vzG60tcw 6Eevfpf/1rgq1u1Zddg0VIhExAmjkTTPJqhRfLXDQo+eL2kdnYFo7R2p0kRNzK0Acel2 64sOxF0yt441P4N15m/DxvWCKIwBI0Yohyov09R4+JIUFdW+AWtOfEQlyVEtKB2z7O5L Tolw== X-Gm-Message-State: AC+VfDyoJMJ5UQ/bHqRBsmB1xtaNreslTFmLAiRMbBCGtDZHy8IZSnkG DAPkSK453f7lLG69gSAY1se5lw== X-Received: by 2002:a7b:c019:0:b0:3f7:f884:7be4 with SMTP id c25-20020a7bc019000000b003f7f8847be4mr1412169wmb.21.1686230474701; Thu, 08 Jun 2023 06:21:14 -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 16-20020a05600c021000b003f7f1b3aff1sm5001100wmi.26.2023.06.08.06.21.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 06:21:14 -0700 (PDT) From: Matthieu Baerts Date: Thu, 08 Jun 2023 15:20:52 +0200 Subject: [PATCH net-next 4/4] mptcp: unify pm set_flags interfaces MIME-Version: 1.0 Message-Id: <20230608-upstream-net-next-20230608-mptcp-unify-pm-interfaces-v1-4-b301717c9ff5@tessares.net> References: <20230608-upstream-net-next-20230608-mptcp-unify-pm-interfaces-v1-0-b301717c9ff5@tessares.net> In-Reply-To: <20230608-upstream-net-next-20230608-mptcp-unify-pm-interfaces-v1-0-b301717c9ff5@tessares.net> To: mptcp@lists.linux.dev, Mat Martineau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Geliang Tang , Matthieu Baerts X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=5515; i=matthieu.baerts@tessares.net; h=from:subject:message-id; bh=nAiGoxd4O08hlaui72f0yC95azIdQnaelnxY4OLX1JU=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBkgdXFAQhBRtbu0GqjM4u9CPn+H7ZdGkwZJFZpk Fge/YuAqXCJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZIHVxQAKCRD2t4JPQmmg czUoD/48REKp6Kc18uG+cTTanHAy8TD8YOPHfsBVfzp8iXOdGJrzHrvKaRllLEOIKNk9XMLEtBF hu5b+Fz5MftBaMTRX1WRjRF/zwZ+XcB74rSt0vvm6GxwXTqdD0XN9jBPAHyNmMl55mFXCPnma4c O1PhcLJ4fbuivb5JdIw6D8XLDovfPrB4tKqxPK5hSi2q63uEFSnRU4pdgs3Z7djtxHPNcl6WNyF 3Hy7SQHDnmEhIxgA3MKDMQhoM4dsWl+XDUdwETLHVmxHhneIc5jZRpL71h3yV5WNH2VNAqjo3R6 erxFonYMx1LsV2sisNO05Z9oG2BmJYFdFiMk3+NqQpdFaTHBK9gaCMUp3MpqlHazQFjDobUGy0o 22SjA3QugvXcorEBskWRvfaHLj/PvSjf31GXoSIY+PifxXDH13Dt56YeGLmwuaA4ZJrFYZ23C0C B16P3w193SPyZRaYvpggSr6XARWYhFw0szX2wNCWY/ZTBnc9UriVeeaNeBa4jEO+0wWdmeREnPi AE+lc8/MQIsFkIOBH6mg9cXciLLQRXJF3U6R9f2Y+HAHrMrGqkcGYxwRde+Nc2E00VV681sj77l FCX0QW8EOlPvgCdZ3ke5W46s1tbkdjnNsRueVKA1nSLLQxAvMjX4GNdfCjJqd0rH0YoHNZfUo7i 5HguWofxWARmYNw== 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,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768141005214033373?= X-GMAIL-MSGID: =?utf-8?q?1768141005214033373?= From: Geliang Tang This patch unifies the three PM set_flags() interfaces: mptcp_pm_nl_set_flags() in mptcp/pm_netlink.c for the in-kernel PM and mptcp_userspace_pm_set_flags() in mptcp/pm_userspace.c for the userspace PM. They'll be switched in the common PM infterface mptcp_pm_set_flags() in mptcp/pm.c based on whether token is NULL or not. Signed-off-by: Geliang Tang Reviewed-by: Matthieu Baerts Signed-off-by: Matthieu Baerts Reviewed-by: Larysa Zaremba --- net/mptcp/pm.c | 9 +++++++ net/mptcp/pm_netlink.c | 70 +++++++++++++++++++++++++++----------------------- net/mptcp/protocol.h | 4 +++ 3 files changed, 51 insertions(+), 32 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 2d04598dde05..36bf9196168b 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -433,6 +433,15 @@ int mptcp_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id return mptcp_pm_nl_get_flags_and_ifindex_by_id(msk, id, flags, ifindex); } +int mptcp_pm_set_flags(struct net *net, struct nlattr *token, + struct mptcp_pm_addr_entry *loc, + struct mptcp_pm_addr_entry *rem, u8 bkup) +{ + if (token) + return mptcp_userspace_pm_set_flags(net, token, loc, rem, bkup); + return mptcp_pm_nl_set_flags(net, loc, bkup); +} + void mptcp_pm_subflow_chk_stale(const struct mptcp_sock *msk, struct sock *ssk) { struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index e8b32d369f11..13be9205d36d 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1864,18 +1864,50 @@ static int mptcp_nl_set_flags(struct net *net, return ret; } +int mptcp_pm_nl_set_flags(struct net *net, struct mptcp_pm_addr_entry *addr, u8 bkup) +{ + struct pm_nl_pernet *pernet = pm_nl_get_pernet(net); + u8 changed, mask = MPTCP_PM_ADDR_FLAG_BACKUP | + MPTCP_PM_ADDR_FLAG_FULLMESH; + struct mptcp_pm_addr_entry *entry; + u8 lookup_by_id = 0; + + if (addr->addr.family == AF_UNSPEC) { + lookup_by_id = 1; + if (!addr->addr.id) + return -EOPNOTSUPP; + } + + spin_lock_bh(&pernet->lock); + entry = __lookup_addr(pernet, &addr->addr, lookup_by_id); + if (!entry) { + spin_unlock_bh(&pernet->lock); + return -EINVAL; + } + if ((addr->flags & MPTCP_PM_ADDR_FLAG_FULLMESH) && + (entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) { + spin_unlock_bh(&pernet->lock); + return -EINVAL; + } + + changed = (addr->flags ^ entry->flags) & mask; + entry->flags = (entry->flags & ~mask) | (addr->flags & mask); + *addr = *entry; + spin_unlock_bh(&pernet->lock); + + mptcp_nl_set_flags(net, &addr->addr, bkup, changed); + return 0; +} + static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) { - struct mptcp_pm_addr_entry addr = { .addr = { .family = AF_UNSPEC }, }, *entry; struct mptcp_pm_addr_entry remote = { .addr = { .family = AF_UNSPEC }, }; + struct mptcp_pm_addr_entry addr = { .addr = { .family = AF_UNSPEC }, }; struct nlattr *attr_rem = info->attrs[MPTCP_PM_ATTR_ADDR_REMOTE]; struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN]; struct nlattr *attr = info->attrs[MPTCP_PM_ATTR_ADDR]; - struct pm_nl_pernet *pernet = genl_info_pm_nl(info); - u8 changed, mask = MPTCP_PM_ADDR_FLAG_BACKUP | - MPTCP_PM_ADDR_FLAG_FULLMESH; struct net *net = sock_net(skb->sk); - u8 bkup = 0, lookup_by_id = 0; + u8 bkup = 0; int ret; ret = mptcp_pm_parse_entry(attr, info, false, &addr); @@ -1890,34 +1922,8 @@ static int mptcp_nl_cmd_set_flags(struct sk_buff *skb, struct genl_info *info) if (addr.flags & MPTCP_PM_ADDR_FLAG_BACKUP) bkup = 1; - if (addr.addr.family == AF_UNSPEC) { - lookup_by_id = 1; - if (!addr.addr.id) - return -EOPNOTSUPP; - } - if (token) - return mptcp_userspace_pm_set_flags(net, token, &addr, &remote, bkup); - - spin_lock_bh(&pernet->lock); - entry = __lookup_addr(pernet, &addr.addr, lookup_by_id); - if (!entry) { - spin_unlock_bh(&pernet->lock); - return -EINVAL; - } - if ((addr.flags & MPTCP_PM_ADDR_FLAG_FULLMESH) && - (entry->flags & MPTCP_PM_ADDR_FLAG_SIGNAL)) { - spin_unlock_bh(&pernet->lock); - return -EINVAL; - } - - changed = (addr.flags ^ entry->flags) & mask; - entry->flags = (entry->flags & ~mask) | (addr.flags & mask); - addr = *entry; - spin_unlock_bh(&pernet->lock); - - mptcp_nl_set_flags(net, &addr.addr, bkup, changed); - return 0; + return mptcp_pm_set_flags(net, token, &addr, &remote, bkup); } static void mptcp_nl_mcast_send(struct net *net, struct sk_buff *nlskb, gfp_t gfp) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 607cbd2ccb98..1e7465bb66d5 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -827,6 +827,10 @@ int mptcp_pm_nl_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int int mptcp_userspace_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id, u8 *flags, int *ifindex); +int mptcp_pm_set_flags(struct net *net, struct nlattr *token, + struct mptcp_pm_addr_entry *loc, + struct mptcp_pm_addr_entry *rem, u8 bkup); +int mptcp_pm_nl_set_flags(struct net *net, struct mptcp_pm_addr_entry *addr, u8 bkup); int mptcp_userspace_pm_set_flags(struct net *net, struct nlattr *token, struct mptcp_pm_addr_entry *loc, struct mptcp_pm_addr_entry *rem, u8 bkup);