From patchwork Tue Nov 21 09:52:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462700 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2054.outbound.protection.outlook.com [40.107.20.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B62F171AF for ; Tue, 21 Nov 2023 09:53:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="PbNhT7KM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jRla7iRj4r1vT5gZa3PueEP95KQOLim6UkqG6W5dod7WbBBl0j78cGD1p7IjE4cjj185Wpc6NgAQqJpdWrig9PeTiZbJT1YRXGm5URRCbrM+VYxhmCyvwFXBnkcbkEJL4faYD7Ql3qDh+VGFrW49KDRLY3VbhyekqSy39QExs5GjUSXgo9E0LL4d/K6+NptW2LuZZK7VmEPDnV3OEr2YPdzjmQR1PMUOlSLNgdOXgV1TVM3P6BpBGJRBEMeU1nj/v1SZf0B+IkpkWCqUSsHiL4BKGKjKxccfCoFF+pBoxXsY5usYXx/aLeKR3E5mlJiLfW041l7mhixKZrO077hIjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=im0w7CtP3iX8S7SAEQ/Bujr0mMzfVUiEcCrdAu32FXs=; b=aBz00IiA+Om2WrsxYVcTtR8q+jseC72xKeIB534/P4+l/g+ORAKTI/HGe+y9H/6qFEDA4mRTgylBcmP77G18NMwsjNBbzv6vPjv9/1/iGa0GoafizbhwC33IV7sUhTI2/SIL5lbQHxmKCfFKxqRUn/kdycLwyVm+c4ANO+m2cKg3kBll0XfitML5BijMzCwtd3R26ebeHQa+ypO7mGp+ygB8OSxmnJ9QlscIxMjOcI6VLSyDRbR2OrKOTexDJJjenXj3svSoZvz+9+2DInjFmtmF2mbM1dZnJ8I5y7OkF4XDjYCfwdvm2dgzOVBK5pjbcKf5dRWMe2P0a72FVmmYuA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=im0w7CtP3iX8S7SAEQ/Bujr0mMzfVUiEcCrdAu32FXs=; b=PbNhT7KMeLac82NMbQabrSqTEaj9AAYdMcL4hSwrK66Z3oVViTw/rnEcUrFEV+aYAJ4qXzOnzj1d+fOJ3Er8wvZn41SyxVyKX418RDrwmhL+9cdjx8JIWKT7mWHhgWdLfBuFb5cVuOdAQvqcyLr4SHwEVO73B6Od/BE9QJwGy4Y5LHKYBqFCeXCdX08QtyJciMwg2mAlJ4qRtK5jBcdoH2lwHBcqBkVbtYkM37agk45mQb1RnfMADHxogkQvWj8MbVm+2ZPd1sb8CaFCM1rMgyE83yT7FsjVE2EwfxpbWYFJAVuMPwoJROX5YE2kR4VmQQg3HzqfYmX3QKOfHGMauQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by AS8PR04MB8387.eurprd04.prod.outlook.com (2603:10a6:20b:3f7::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.17; Tue, 21 Nov 2023 09:53:33 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:53:33 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 01/28] mptcp: export pm_nl_get_pernet_from_msk Date: Tue, 21 Nov 2023 17:52:24 +0800 Message-Id: <14219f05cd554eb7ec74a2361d8813cf12f443f4.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SGXP274CA0010.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::22) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|AS8PR04MB8387:EE_ X-MS-Office365-Filtering-Correlation-Id: c748b90c-ee2c-4e52-a365-08dbea77b929 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nmtdWB1B+ZVyiQoiYcoh4ZMiqze5Vc3rqKrrP3NNKgJeEledQ+izhhfyH2EXWMDpxZxxXO/iYWOvDV5gf35EWOjVQtFcVePqxQp0B+rDWoizwICT8Vr8LGrh72uEhC8blPpSJettbUeOUEzl00DbDyUKlKY70Eybf3X9mSeEl2bzNYWXms5I3GP6VahlYNFRbzy3Fpy2v8bsLjP3UePKhEpnfGN5siPRzDlMlj+vHDFRUipxiiPW6wgbdAj2jR5A2xc6N7+FR8bNXfVF6OKlQOxEeVpZo6+qaYQSSeyibJeIDK/6fosgZSrnpeNnfykpco0vJrtRlOze69TL80bt55yS3HNDPem92jI6xfHtMI1STh9f3xXX1rbVCUMFhH2FwpzTBP/4WjOufpd1jkZwfrSyG0DirH+Z7o+z2C0PBje9bA6SnqCEvYzYA+8HPswQHW20qq8mMRPwzCe6iI9tPdTc1hJG/FKzhf4ba3sswwDWqc0deqhP23HfrCYnIGW2ZHpBtZ2jrhq4epdHs3UlzPZNWb3jRfpPTcJVcUfggwGsW58VMFZ5rD3rAnGTPrA1 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(346002)(366004)(39860400002)(136003)(396003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(83380400001)(478600001)(6506007)(26005)(6486002)(6512007)(6666004)(316002)(66476007)(66556008)(66946007)(6916009)(2616005)(107886003)(8936002)(38100700002)(4326008)(8676002)(2906002)(44832011)(5660300002)(41300700001)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 17jYTNW2N5x1SovZvHgsc2rUpcxOuGmBvzeEcapHob4v2v8xxkIaPeCoGqAaB+errhW2ui9Yk3rm+GbuFRcwBNjTITAt5D493nx58bN7/1MnQk1NnvJz8xNuvFMbshJqKiegvNAs4v1EAf0VnEykH0RMuoFSRW5apE9EDxoe8e9o1LBYlvmE7o0bzvjwd6BX0NHMvoWXVZyK4LIz2ZUeyNZ8vGJ8G/PHvmcI5q5HqwCNV7hrQQURvYErFHbx2guJ9A/qF+pp47P/v/tiLUEb/J9z94gX3vxmZS3UwUSoRZKBBxGxggEZvT5Lrib4LohqxL0oJDs0hb0CoW+L9dmSbzLz9OMDtZeoELguJ0HJhITTFXIYtIiacBIG9trd8TYHWdf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amuXyH4x8AwphEbiRSoynqn2MiQbF4wRvnDrQvQ+ep8OzBWIIJCDaubaXBwPLUVVBXIIXRLR2NsSFVEv8p4+Z6jb/jteBbl/hWv8YL7kJwns23lTd7ULN/jstaRdAte6/FvyL2XBBQhQ X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: c748b90c-ee2c-4e52-a365-08dbea77b929 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:53:33.5707 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: DCNyxWNKiioJ2G0x92wRFnJsDbtVWcQHOJ93qKJ6NoP0+3yGGdBMbt4fnq5FZJONg+3hHJVnnZKUV7xGTcGoWQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8387 This patch moves struct pm_nl_pernet from pm_netlink.c to protocol.h, and export pm_nl_get_pernet_from_msk() helper. Then every fields of struct pm_nl_pernet can be accessed everywhere, not only being limited in pm_netlink.c. Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 17 ++--------------- net/mptcp/protocol.h | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index bf4d96f6f99a..1dcf104d7a01 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -31,20 +31,6 @@ struct mptcp_pm_add_entry { struct mptcp_sock *sock; }; -struct pm_nl_pernet { - /* protects pernet updates */ - spinlock_t lock; - struct list_head local_addr_list; - unsigned int addrs; - unsigned int stale_loss_cnt; - unsigned int add_addr_signal_max; - unsigned int add_addr_accept_max; - unsigned int local_addr_max; - unsigned int subflows_max; - unsigned int next_id; - DECLARE_BITMAP(id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1); -}; - #define MPTCP_PM_ADDR_MAX 8 #define ADD_ADDR_RETRANS_MAX 3 @@ -53,11 +39,12 @@ static struct pm_nl_pernet *pm_nl_get_pernet(const struct net *net) return net_generic(net, pm_nl_pernet_id); } -static struct pm_nl_pernet * +struct pm_nl_pernet * pm_nl_get_pernet_from_msk(const struct mptcp_sock *msk) { return pm_nl_get_pernet(sock_net((struct sock *)msk)); } +EXPORT_SYMBOL_GPL(pm_nl_get_pernet_from_msk); bool mptcp_addresses_equal(const struct mptcp_addr_info *a, const struct mptcp_addr_info *b, bool use_port) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 8529b3ae55e9..c38a2126071b 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1026,6 +1026,23 @@ 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); + +struct pm_nl_pernet { + /* protects pernet updates */ + spinlock_t lock; + struct list_head local_addr_list; + unsigned int addrs; + unsigned int stale_loss_cnt; + unsigned int add_addr_signal_max; + unsigned int add_addr_accept_max; + unsigned int local_addr_max; + unsigned int subflows_max; + unsigned int next_id; + DECLARE_BITMAP(id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1); +}; + +struct pm_nl_pernet * +pm_nl_get_pernet_from_msk(const struct mptcp_sock *msk); 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 Tue Nov 21 09:52:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462701 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2088.outbound.protection.outlook.com [40.107.20.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7AC6F171AF for ; Tue, 21 Nov 2023 09:53:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="qdEJseed" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=B4quf4ezYG+AnfL+z52bosISdbuKXoBH+wsWdGz6eGckl/JMmPlkbrnFCzX0AKrgY9H/2o5piYkLJkbUQ70lJvhiHDTz8eRdzSeH8+xKVW/i3Zg5cuZ7TL8HROtm4RGwvwu2mU7j5R99vgyrtpc/hTb4UZV5ofKlgCVgRfN5Dibj96SrdI7oDQG85pCxHSc9ixw6TpjMLY0FVVy/y9rnZSk0zjgyvTeGjzoAESvF3fv40o41eRQH5v0Cp920JRrB3gJTd7zsHZW2Dk2CM1kDMKJ5kKnrp+iFSl15LKKZPiVq4057xp+mBav6dKrmtC32ssC8DOTI0nH/Hs5hhkR4Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GWWUSY9xk98fgltOIrmPyL+RfYmmMYbkdDqwVfSOL28=; b=VLfCH8PoOLZY2RcW7Bd0dFDRf6J3AgJ3+I+fZ1egM9YUElBboiDb8hNirfByDD4Pj3oGMihV1PLsc2begyXoyDuACj2ztC1Igjc0nhfgiycc1ogz9c86KELMKQWsNevyiIwXH6Gy1/H/K/qreEfgWGgoFaqu4fnzVam7GSYQHvS6/95p2+FvLzTg3iEgMYyIEf4JbBFQeH2kltFm//DA2TKlc9WXKB/9B7Ik3YpVzSxCyoJv+Z/QhutiTlfZuh6WqA/ZGRj7v8R1fXiCcoJALAG4McDL4mzLJQOiC6BzAj4jDTDwxZMHR4nzAuBVqif73SlHF8P32e12mAwgofe9kw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=GWWUSY9xk98fgltOIrmPyL+RfYmmMYbkdDqwVfSOL28=; b=qdEJseedZJyVo90kUgt0+kOm2pdT6BUEndDNi1bFbCoTG+uYr1E/FMD3KSYnbDFbB07hhxh3X0xBMxHLkmPtbBWZeUhVxoxAYk8CZWdkW5OK/ai+fPWRxo2SH8C88ff7Bn5AQcM9qcgKnJM5EmvgpOGDinUBBF2fxOx4F7ZAakFgCs/3DjRApR+yBwGPIgs6Dips8OC/UbD1uRP4BKKl+dRTDLjIXWlQcBz5S47gvF7st3nkDPzb0V/xOCX4iCrEeikqSzkXQMUnZjF9dFNsAutmBsk1W7Q8HMt9c8/wLlkDuTHYnKFxNbg5G872vKGztJMQmX1q9VO7mLT4zKnFAQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by AS8PR04MB8387.eurprd04.prod.outlook.com (2603:10a6:20b:3f7::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.17; Tue, 21 Nov 2023 09:53:40 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:53:40 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 02/28] mptcp: drop mptcp_pm_get_* helpers Date: Tue, 21 Nov 2023 17:52:25 +0800 Message-Id: <72cc0b30f8d1a3d78042aba5f903698035021f7b.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SGXP274CA0005.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::17) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|AS8PR04MB8387:EE_ X-MS-Office365-Filtering-Correlation-Id: 5057ef51-9c45-4d5b-8ec4-08dbea77bc62 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nscv+osnVaseKBb1lkwwSj59Nw9ZYziFWXK9L/nhPO4U7ij/sI9XKfb8CkAoRDBmDhtGr+O/Gr1ssf8IKef2THXJERFJwfBEQOXJ7HD6M3z8ncE/myIz9HeLHEpvp1CmWW0N9z6pLUt9IUdKYtYbhStXXUTsl83+E681ZgtirF/3W1cdfW60dp2TRK4kZSq7aG1WfGsoKpEDE7+NcHvc+c7z7Sfd1eRIQtFTY4ONpQTMaJaLPAvI/RY1t+mDLCEwU5Cgyu+FhGMNa9fHzCE61iEB8zX09icFviQih7qj04fp7JxixGXz3NwvMg+PnPG1VZKCyd0dUwzc8dsMvBFyBUlwJdTJCK5UcaDU/GFE7I3ikfyrsCwihm0A4WXZXZa3OKTncAkjTl7DbZweI6F4iFiOaFaylDFNw44p8VaXSGdSgt7aNbSUZP6P2kd3khsw5EE2KphQGJ6G2T+vVJw0X/p+eAHN0Y6tRkbdmY/dq8wYiFLqRxSlGkFYc+wySTvtPyO9ZtI2C+X5XDpKKxhi/J51d5ZC9H/aBiqsAP0ntVZ3nlCjNPXZfQkeIGSUVLihzDZZgrYpX54WSukAADPp49L+Z3FxQyv6AJXZreNWFuMmIk/V1bcYQIKvQ4HoDSGH X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(346002)(366004)(39860400002)(136003)(396003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(83380400001)(478600001)(6506007)(26005)(6486002)(6512007)(6666004)(316002)(66476007)(66556008)(66946007)(6916009)(2616005)(107886003)(8936002)(38100700002)(4326008)(8676002)(2906002)(44832011)(5660300002)(41300700001)(86362001)(36756003)(309714004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mKyhlB8CNM1AV8c2TWmdd64WjW40qMbb9KSPH5Astr9XeHaDthdBElSTJnrL6i7MwT3eIGfeubuvzYZG5oup4/mFzERkwRz0QdG8geoFylEOQ2qdRdW0/04eGlAqINgmBlkW6myYvgJb5x3xW1B/hkwo9LG6QCsXpMSkMtNvTzFK2wbwS3wHjh4w/P1O3AkS5QCBbMXAqIbjIYlaVgfgClerznlXdRd+L3WePIVjBAckTWQTQnR4uAHtSm6OfjrM59y5uHKhppAv2yvHKRZpGoTdpIsL86clZrokjRGqm2k3SIhum7v856Uw31p1S651l0srBiXso9hUtTE6m8/CoJIKZHnMdySOa5mezWotus/82tDrXb73JSP2eMZLKAb/DurG2xJcbPXCyx973DrVcyRo4ljJHaSOqw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ADGfxupcMj3XUyEJUEKV6WBN2e4eNPlobFfR/Hgj66dPkM83fQc/Q7L/V7/IU1srguOVBt7giFHpb6udx2dQa6zDgeW0 X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5057ef51-9c45-4d5b-8ec4-08dbea77bc62 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:53:39.9432 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4/KPfsB2eyi8akuxIAweJ4oRqmMeBtG8yKjcB2OwQYCc2wvNAOUoLDDaT9S1I9ehS+DmhG0lV+ch5a3Yn+6lmQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8387 Drop four mptcp_pm_get_* helpers: mptcp_pm_get_add_addr_signal_max(); mptcp_pm_get_add_addr_accept_max(); mptcp_pm_get_subflows_max(); mptcp_pm_get_local_addr_max(); The helper pm_nl_get_pernet_from_msk() now can be used to replace each of them. Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 12 +++++----- net/mptcp/pm_netlink.c | 50 +++++++++--------------------------------- net/mptcp/protocol.h | 8 +++---- net/mptcp/sockopt.c | 9 ++++---- 4 files changed, 25 insertions(+), 54 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 4ae19113b8eb..48ff7ce20890 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -85,6 +85,7 @@ void mptcp_pm_new_connection(struct mptcp_sock *msk, const struct sock *ssk, int bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk) { + struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); struct mptcp_pm_data *pm = &msk->pm; unsigned int subflows_max; int ret = 0; @@ -99,7 +100,7 @@ bool mptcp_pm_allow_new_subflow(struct mptcp_sock *msk) return false; } - subflows_max = mptcp_pm_get_subflows_max(msk); + subflows_max = READ_ONCE(pernet->subflows_max); pr_debug("msk=%p subflows=%d max=%d allow=%d", msk, pm->subflows, subflows_max, READ_ONCE(pm->accept_subflow)); @@ -496,6 +497,7 @@ bool mptcp_pm_addr_families_match(const struct sock *sk, void mptcp_pm_data_reset(struct mptcp_sock *msk) { + struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); u8 pm_type = mptcp_get_pm_type(sock_net((struct sock *)msk)); struct mptcp_pm_data *pm = &msk->pm; @@ -508,17 +510,17 @@ void mptcp_pm_data_reset(struct mptcp_sock *msk) WRITE_ONCE(pm->pm_type, pm_type); if (pm_type == MPTCP_PM_TYPE_KERNEL) { - bool subflows_allowed = !!mptcp_pm_get_subflows_max(msk); + bool subflows_allowed = !!READ_ONCE(pernet->subflows_max); /* pm->work_pending must be only be set to 'true' when * pm->pm_type is set to MPTCP_PM_TYPE_KERNEL */ WRITE_ONCE(pm->work_pending, - (!!mptcp_pm_get_local_addr_max(msk) && + (!!READ_ONCE(pernet->local_addr_max) && subflows_allowed) || - !!mptcp_pm_get_add_addr_signal_max(msk)); + !!READ_ONCE(pernet->add_addr_signal_max)); WRITE_ONCE(pm->accept_addr, - !!mptcp_pm_get_add_addr_accept_max(msk) && + !!READ_ONCE(pernet->add_addr_accept_max) && subflows_allowed); WRITE_ONCE(pm->accept_subflow, subflows_allowed); } else { diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 1dcf104d7a01..dbf040e39af4 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -183,43 +183,11 @@ select_signal_address(struct pm_nl_pernet *pernet, const struct mptcp_sock *msk) return ret; } -unsigned int mptcp_pm_get_add_addr_signal_max(const struct mptcp_sock *msk) -{ - const struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); - - return READ_ONCE(pernet->add_addr_signal_max); -} -EXPORT_SYMBOL_GPL(mptcp_pm_get_add_addr_signal_max); - -unsigned int mptcp_pm_get_add_addr_accept_max(const struct mptcp_sock *msk) -{ - struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); - - return READ_ONCE(pernet->add_addr_accept_max); -} -EXPORT_SYMBOL_GPL(mptcp_pm_get_add_addr_accept_max); - -unsigned int mptcp_pm_get_subflows_max(const struct mptcp_sock *msk) -{ - struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); - - return READ_ONCE(pernet->subflows_max); -} -EXPORT_SYMBOL_GPL(mptcp_pm_get_subflows_max); - -unsigned int mptcp_pm_get_local_addr_max(const struct mptcp_sock *msk) -{ - struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); - - return READ_ONCE(pernet->local_addr_max); -} -EXPORT_SYMBOL_GPL(mptcp_pm_get_local_addr_max); - bool mptcp_pm_nl_check_work_pending(struct mptcp_sock *msk) { struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); - if (msk->pm.subflows == mptcp_pm_get_subflows_max(msk) || + if (msk->pm.subflows == READ_ONCE(pernet->subflows_max) || (find_next_and_bit(pernet->id_bitmap, msk->pm.id_avail_bitmap, MPTCP_PM_MAX_ADDR_ID + 1, 0) == MPTCP_PM_MAX_ADDR_ID + 1)) { WRITE_ONCE(msk->pm.work_pending, false); @@ -404,6 +372,7 @@ static unsigned int fill_remote_addresses_vec(struct mptcp_sock *msk, bool fullmesh, struct mptcp_addr_info *addrs) { + struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); bool deny_id0 = READ_ONCE(msk->pm.remote_deny_join_id0); struct sock *sk = (struct sock *)msk, *ssk; struct mptcp_subflow_context *subflow; @@ -411,7 +380,7 @@ static unsigned int fill_remote_addresses_vec(struct mptcp_sock *msk, unsigned int subflows_max; int i = 0; - subflows_max = mptcp_pm_get_subflows_max(msk); + subflows_max = READ_ONCE(pernet->subflows_max); remote_address((struct sock_common *)sk, &remote); /* Non-fullmesh endpoint, fill in the single entry @@ -514,9 +483,9 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) pernet = pm_nl_get_pernet(sock_net(sk)); - add_addr_signal_max = mptcp_pm_get_add_addr_signal_max(msk); - local_addr_max = mptcp_pm_get_local_addr_max(msk); - subflows_max = mptcp_pm_get_subflows_max(msk); + add_addr_signal_max = READ_ONCE(pernet->add_addr_signal_max); + local_addr_max = READ_ONCE(pernet->local_addr_max); + subflows_max = READ_ONCE(pernet->subflows_max); /* do lazy endpoint usage accounting for the MPC subflows */ if (unlikely(!(msk->pm.status & BIT(MPTCP_PM_MPC_ENDPOINT_ACCOUNTED))) && msk->first) { @@ -621,7 +590,7 @@ static unsigned int fill_local_addresses_vec(struct mptcp_sock *msk, int i = 0; pernet = pm_nl_get_pernet_from_msk(msk); - subflows_max = mptcp_pm_get_subflows_max(msk); + subflows_max = READ_ONCE(pernet->subflows_max); rcu_read_lock(); list_for_each_entry_rcu(entry, &pernet->local_addr_list, list) { @@ -664,6 +633,7 @@ static unsigned int fill_local_addresses_vec(struct mptcp_sock *msk, static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk) { + struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); struct mptcp_addr_info addrs[MPTCP_PM_ADDR_MAX]; struct sock *sk = (struct sock *)msk; unsigned int add_addr_accept_max; @@ -671,8 +641,8 @@ static void mptcp_pm_nl_add_addr_received(struct mptcp_sock *msk) unsigned int subflows_max; int i, nr; - add_addr_accept_max = mptcp_pm_get_add_addr_accept_max(msk); - subflows_max = mptcp_pm_get_subflows_max(msk); + add_addr_accept_max = READ_ONCE(pernet->add_addr_accept_max); + subflows_max = READ_ONCE(pernet->subflows_max); pr_debug("accepted %d:%d remote family %d", msk->pm.add_addr_accepted, add_addr_accept_max, diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index c38a2126071b..88f5b422f941 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1043,15 +1043,13 @@ struct pm_nl_pernet { struct pm_nl_pernet * pm_nl_get_pernet_from_msk(const struct mptcp_sock *msk); -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); -unsigned int mptcp_pm_get_local_addr_max(const struct mptcp_sock *msk); /* called under PM lock */ static inline void __mptcp_pm_close_subflow(struct mptcp_sock *msk) { - if (--msk->pm.subflows < mptcp_pm_get_subflows_max(msk)) + struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); + + if (--msk->pm.subflows < READ_ONCE(pernet->subflows_max)) WRITE_ONCE(msk->pm.accept_subflow, true); } diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index cabe856b2a45..8d63df5ded50 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -893,6 +893,7 @@ static int mptcp_getsockopt_first_sf_only(struct mptcp_sock *msk, int level, int void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info) { + struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); struct sock *sk = (struct sock *)msk; u32 flags = 0; bool slow; @@ -910,13 +911,13 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info) /* The following limits only make sense for the in-kernel PM */ if (mptcp_pm_is_kernel(msk)) { info->mptcpi_subflows_max = - mptcp_pm_get_subflows_max(msk); + READ_ONCE(pernet->subflows_max); info->mptcpi_add_addr_signal_max = - mptcp_pm_get_add_addr_signal_max(msk); + READ_ONCE(pernet->add_addr_signal_max); info->mptcpi_add_addr_accepted_max = - mptcp_pm_get_add_addr_accept_max(msk); + READ_ONCE(pernet->add_addr_accept_max); info->mptcpi_local_addr_max = - mptcp_pm_get_local_addr_max(msk); + READ_ONCE(pernet->local_addr_max); } if (__mptcp_check_fallback(msk)) From patchwork Tue Nov 21 09:52:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462702 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2072.outbound.protection.outlook.com [40.107.20.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38A68171AF for ; Tue, 21 Nov 2023 09:53:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="AqvDTDSx" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PfdE6fZAFu8yMrUCYdu0WnsO/X1itAtF5BgU/ObLlK3hNekew7FIyiHFLkDjEBQ2cX+XLEn7c/cyJWUfqM3NTHzVoymsCda47jUiTavb9wFyhULRJZtbKQJzlrH0koEibRarQbSWs1oq0E0jA2hxgn9LpfTTHni24vDMW7mCAm5roPNMGjcmt0tRWDaCTaRItknwRSO6TjQcQWpTzk6r9b29XdvKvQnCFCxZRBsqXavLxKFebaTpjjCuIHaXEyjgqXKC89BVBcJo7ERReBRRA1r8wXfBCuV+Qb8wWIHhAmjtE8EImX0VvL5PjqKyTs0NVTQpR0fHNBs309x9yBJGvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DIHyqT6HE6SN+ei496ifxFyH6B28w5/Nfb2pvs1TXCU=; b=amytPnmSK89jWf4upZJ8zWkRJiBK5ZixN4pKZVTIBIWKtbK0vkKYyuzJZLOmPET03HKBEWK9p7KmQtI5ARQ+M3vE75qiN0RDEHKLwV/CQtye77/u1wmjRxIKCM+d5gsHJNz5LzS2XVKHn2Wr+shyavS1MbQW42/YdCnL7kEy8k/uj1oy6LN6nzyGVaCy+v2DVd8FmvJiNZhl7V87Dd/lGPSvBeTOEaj/Pky6YEtY2mnLGC3LFAIqhSva/AJqS5rfaA8KH8gWxcfBdyJlqPvFUg5vEwPmrNtHnDMAVqVBtYYDfwHEv3wJahHR2THsvf7jlZkax4BX+JQsDWer/Xz28A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DIHyqT6HE6SN+ei496ifxFyH6B28w5/Nfb2pvs1TXCU=; b=AqvDTDSxpx+1WHPI3Od4UZU5MP+KXSTDNqLsGipqyCDJrBlLJvSe0ms4EMklcZC5/1r985BabIoEcz9gZSjA4c/2AIWrTOHEMRYzlW08KyvRKc5e+T8oBeA7MTJqDDelfv0pIM6chub32jwUC3qDC3pjXjIf9t5kEg7HmwE2fI88dk1fZ4H9bxhMMKKoPLGiDOoHtMTO/6pB78ScvSk2PRcgEu2rH3BNn8uhZVKSI3JVm3PR1Pb8JxY4P/kBduNDytUYKYq8PJMk+O7ztujKlepcabA0v79IRaB0oQkA30ocU5S9BFWS1RZATAQoHarCqW2U6u2srMrAhwUqVeRC4w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by AS8PR04MB8387.eurprd04.prod.outlook.com (2603:10a6:20b:3f7::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.17; Tue, 21 Nov 2023 09:53:45 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:53:45 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 03/28] mptcp: use pernet id_bitmap in userspace pm Date: Tue, 21 Nov 2023 17:52:26 +0800 Message-Id: <076e1b07f4d55e5d89fd4b38ba23ede690c480da.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SGXP274CA0024.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::36) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|AS8PR04MB8387:EE_ X-MS-Office365-Filtering-Correlation-Id: c83fef4a-97f1-48df-abf0-08dbea77c050 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LTDESI4O57zdJw0WXBqU5tBFurtmuBJQ4WyH1O7mtBL9tr6YliGb6Vgp+0cs9RHyk/6BPfosO8MnLUaFd/uDW8XFW4SS7qaOLxKD1kwJiM+Tp+0BLDQMh66oj9ByHE7U9Y7NlaQkiRTWHAvzhxfxjezqyhKaCnwLfvRa2ql1arr0YF28etw6i4C2GWGj0oR94cWGSbvHegF/a5WrmYv2wJxLJLZ2vX5ICaMYGbHDRK7YzgkiyEHiKkZ1SRJdVqMXkW3MUzu5t9Tvyyp7qkSKCAmsQcJe540uUDWsV5u5CKm9OCLElxXb67NBrSvOUHrma+vJ9V0X2pvxQEKerAfX9O+Znm6ScfQ45n4anBgrGTu8MnVkNXIrzUPFo1pRqKE1x7ANiT/tvvlatNHy5IgJZhDiSLrpD/eerduD34J3kIKpruXOQnEtUy2GyIxDJvW7JYdKzEBSQkIbFIPpLif/WBIGbk0i3VPZRocgGO1azbgGti5iGYWqIeegcpVqyTu1joRe7HNW2mzi8Fyq5LrNyLjCFShLp3zEG58w68Ci6h6ErOlhbD3xh6wb2EKsaRMh X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(346002)(366004)(39860400002)(136003)(396003)(230922051799003)(64100799003)(186009)(451199024)(1800799012)(83380400001)(478600001)(6506007)(26005)(6486002)(6512007)(6666004)(316002)(66476007)(66556008)(66946007)(6916009)(2616005)(107886003)(8936002)(38100700002)(4326008)(8676002)(2906002)(44832011)(5660300002)(41300700001)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yvBBOxC1vcXCA2IE27ob0EvCLz0bgWzgIQlNwnopsYPPQaPSVznvIjJE3ynJlFIe5TPNQQgJlzbbToTMKDH7GzRck0JwdTObbsDeDF5GRgXauTAJH5JujcTNR5a4ob6s746bzKueUGRn2NNeG8nADX3GDdMrgFcVpDd4KJ78Hc21ub82ziqHJox+H+QrdXnR+3CeLL8SD0LFJubj6yKPf1wiyeanCdXTIe0E8314HL/b7Gs+1CFvJi1BLiTvZkqsl+UuC8uaUevZf7uxDPQAk05ZgAAfonCfwyIQTTabqyKEUQWL7ug3HFw9RK01EQ+pRKVFg3zpRZNQ6aaX/sbWBeYQyq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3WWa/x2wzbCVbHC80/v0p64yTctdhPoG0FoYS+k0c6jpBsWbLEl7kHA9Pw3Bf/BeP5pQccLrYzfLEN/uXHV1n3howocM5plu2AYyf3yGc8FPfdQb8QfbFaEMzDmZMYGBOQAZs0ulGClrxZMwMlEcxDZmTT2r9SMTR4BoqEfMEd6M2DnxArpgN X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: c83fef4a-97f1-48df-abf0-08dbea77c050 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:53:45.2627 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: jRZWQKG2TEKUwkG4kCQiSxC5HQgLhltCAayBn2b8l50mgOaFFG6TZ+f9CPdXuXPVV6B0tAlEnStZQ22MbvkOqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8387 This patch uses pm_nl_get_pernet_from_msk() to get the pernet id_bitmap instead of using a local bitmap when appending a new local address into the userspace PM local address list. Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index efecbe3cf415..b3a606a5e182 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -28,7 +28,7 @@ void mptcp_free_local_addr_list(struct mptcp_sock *msk) static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, struct mptcp_pm_addr_entry *entry) { - DECLARE_BITMAP(id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1); + struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); struct mptcp_pm_addr_entry *match = NULL; struct sock *sk = (struct sock *)msk; struct mptcp_pm_addr_entry *e; @@ -36,8 +36,6 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, bool id_match = false; int ret = -EINVAL; - bitmap_zero(id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1); - spin_lock_bh(&msk->pm.lock); list_for_each_entry(e, &msk->pm.userspace_pm_local_addr_list, list) { addr_match = mptcp_addresses_equal(&e->addr, &entry->addr, true); @@ -50,7 +48,6 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, } else if (addr_match || id_match) { break; } - __set_bit(e->addr.id, id_bitmap); } if (!match && !addr_match && !id_match) { @@ -65,9 +62,10 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, *e = *entry; if (!e->addr.id) - e->addr.id = find_next_zero_bit(id_bitmap, + e->addr.id = find_next_zero_bit(pernet->id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1, 1); + __set_bit(e->addr.id, pernet->id_bitmap); list_add_tail_rcu(&e->list, &msk->pm.userspace_pm_local_addr_list); msk->pm.local_addr_used++; ret = e->addr.id; From patchwork Tue Nov 21 09:52:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462703 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2053.outbound.protection.outlook.com [40.107.105.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62FB3171AF for ; Tue, 21 Nov 2023 09:53:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="f25pQ7+S" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XuGvli7QtfGBEpT+pjBA4oWBtX8IFz9qTNCGqqCFgh8LIKj3BU48BkzJgCz8pKrSVndMq/KmAm+WBFM+TsljF3Cxvi4VPxYj3as2t5i02tXjBIiHAXlU0U0Ug7m//UHxzFXS3r2VwdrSnuCMjqiO0Gg2Y4g1qHkixCjtYaUEcIB6pryXuh6VgNruB8fGjwUTFbo0768i5eqHIeqFtsHELceUGon7oT//+t5x3GR3ndU6/nHzO7EpmbDp0d+IWrnCPPnjOx3IrNyxyIz3o9NdgNrsod/3WSvZcHfOkvP9w8WsReky7sprDF/+S8vOXZduog08Edi9O+Hgp4l5vj26Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QFu5NR5fYWXwtw4Q2nfrmDukq9pre3TiGE1SzTkbt14=; b=JHjRmb6Ep6WRjoS4QM/NTDFcZ+bBTpi98Q/7GZccAdGBrCMVE/w5iRTe/mZGSV1MuXaIiAOsFNpy2S7DKGrUrIyLwrTch74vS+dPSy16pg/2gs7rUtZECXU2SBOzNKgFsKgq1UHiwk7WzFPhS14vM+HOBz6Mrasfxbub77sUsUkM9aUt1qqEYXYWgDUui8iZe21Qs+QsHw4KaxapgmwIFLZ9JUvMcLBIB1zjHuQjhHODbcATW3yEfirU3B/hlKnUTjNOyYthc1RRJ+zH7sr7Y2lddVvd0QsBsia1Kpm+qDwTcFBAvw/uxlD4cX2qfOTrllPKbEarRaGtpmW0vVqBlQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QFu5NR5fYWXwtw4Q2nfrmDukq9pre3TiGE1SzTkbt14=; b=f25pQ7+SZt9ODCtLhMCKHmoPllf2K2b+c1Bq8jYbFiDe+oyLJSCYGoaBEkehjJn1WSmGfQDVrPA0tuYf5oxSM5VHWSW4ATNgCGFJdifYbRDMW1Z3gJVR7zXrOZ2kCeRQ1whKbY6wGZ6St1YGip+bKWUZqLctJ6x+t6wjRmCTC9ioYCZoY1TyWVjhWxkQ/A3ERynDiTLYdsVOPsWfOeL+ZyTv6bML27gn+KYrfy7lMn2uJOhPjgEzU/YliisLclQSzAVQiuRDMe/kMeHOuvQacwubxaJe/UOx1QkFCUZFUJJTzx6zH0YBR5ZZBh09s6MRRJ5G01lLgn+1wU9Jw6DvbA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by AS8PR04MB7750.eurprd04.prod.outlook.com (2603:10a6:20b:2aa::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.17; Tue, 21 Nov 2023 09:53:52 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:53:52 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 04/28] mptcp: add userspace_pm_lookup_addr_by_id helper Date: Tue, 21 Nov 2023 17:52:27 +0800 Message-Id: <212b9cc5467ef119574035b60401492bcf2c5075.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: TYAPR01CA0154.jpnprd01.prod.outlook.com (2603:1096:404:7e::22) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|AS8PR04MB7750:EE_ X-MS-Office365-Filtering-Correlation-Id: 85ef8c44-1bcc-406e-ebce-08dbea77c4a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1QcRYdgMVePwGMEj/5g+0zPjQO4/debo0YrQ8Xo50SM+a2nbbmnlfS6Bhw/3naatJzCS/Nw5u1Ok18WBMTcCr3AjBYfFZjNN49/xLfvVjc4WbKmh7zW4cPhNPa5n1vJCfpYjPAy+H2OnbzYfzk5gSzI1ZnvbcvB+Pr7UUQl/41VjK/OTnSOCaPM4h2WGvOAM8rhLWkt9dQ/fF1FR6dl6wQc9Efk5pMmy5dQaVRphxJRQsi0WfteJpuAckf3r+Q7Phn+xHXao84Hg32Uv9IEMJDxcAhkAtij0zEtFSgHS/GD6NBrrwwLNZkPUBgZljs6PX1wWwrTneII8y71SgHQqzWynOSRq6MqgvJU2KrLEjdPqaDIyO4V7HqpMrOcFwd5bBYY5WBPAGTIGfcvX+NFrY42gGih1iQsTUteNxqU8bNwhA+3GFpMiwCzovoO7/CtnjZ3lj0CAMSSa92MJ/ZBvqw2H1yOHxXQm95kUn7rfH5hA08Bs+1AVHOTll6+3TyW8azbI2ziN+fOWNXywQprv6NKfByKqDR2Dj1qnRpbL70vnhWb5/bWq2zI0honKH1Qq X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(376002)(39860400002)(136003)(396003)(366004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(66946007)(66476007)(66556008)(316002)(6916009)(6506007)(36756003)(6512007)(6666004)(2616005)(26005)(107886003)(6486002)(478600001)(38100700002)(83380400001)(86362001)(2906002)(44832011)(5660300002)(4326008)(8936002)(41300700001)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: NzxnzUcJ9aYkxvtjrVcXrgp/iSSfFKCCg5mirzvgb8GYtid1mszmaaqgSyWtNLtBvcdOdxSL6VVDia38UtkGj6fhqo6oDA3V4wKY/g7d4CLnpNILvw7Z5qm9xNQ3CCuQ/3VCiTbMjPwgK1vtY7R1txPjAS0+VaQuiDG00h93MFQH2GJghYi6mDw9MEg1Id60KKGrSZ8aN0NwpPfDDet8Ii5SgMYzR28aXr0mmPdcwOFKGzyx0IRz8wfJWUQ4ZeO6X103HXoGoyH/YsmM+y/AI44oJgZ8L/KBITwNEbb0C+WuKy0mtXHALs2AWOHDkR27PO1oBXQTGwNs0XItt+hxHw3icsbZxTjAJiKhtl1h2oVSUnietKI32+kitId/p0ODAHxiI34UKHTamI0+/qEOHuHGQj/4/5kQPRrL9TiUNui0DpHvdGDuBMPuNCVnEswMJXbPRYo9DPPX4EbViOOVOAon+0VfoKioI9jAIDNlS5E0i9lf63dQtYxgRGDk9NwvNyuAleoX/O40qjUyfgb+q+hMUXeloBoI9mQRBBXkfF8RR5ZvQGELDyUpLPE360QeKqNC5fAYVfPmrWOgBNgi/Jght3mhtr8mpKZa8OC9nSMhiI1uxsCH+ChTWrbqK6GKc241pr7hn6LcG3l09XGV4BVXHYRSwWAa+FOJzbU3QwsosxXA0K/+o5ymlop2uc2M/M+9jPmeSmy7Mx4OjeEfzBa9V35kyGujumiETdqAb7Sbx3xkDOygEpRxOffz5Qb8Z6fTSrQ/JAmefPT1b4eTGXf7sNortU21ohIVittdqIeuoO4JvuhSGxtM8dx39Etne8BOJWaGlbuApK/ib6C78JV87LjjaFGlmxiQ9kEXVIxMWXz6nJPfF+zG1cGmMsQjGK8zYF4hPPcvkX9aBlHHjGyaXWIChYpK5OLcMKO/JXrP8+SM9pVAWuJQAfJ+nIgsHA8dFZugin81usR62onYDprTLSBzL2So0UDUaGeDTcV/NXMST8lhqKeZjjS4FWMKmyhFwR9epUKG0pbBsMiKjrJrQsFItBImpoQ1Y227aufg/0rkoBeQEeDcs2dYMOvsNRuPUpizOuitNm20htzUvmF+XzcNBpUn8aYZFtOxwR06fLDBhiLXJbgVgQqy8RPQCEnH4cof33JdDhVQY9LwT3OTr7ipL1DMqmo3X78KzV4nIebO9SJ9MFngQmfeCIXeK68eys2+IvfPZqTMPvpy2Jz2Rcb/dcu3jFvbrpxTycY2xzGPT8uj9Y2gmP8Io2CLx0LTJVqroogBiPz015U3w5RZwoNE1eSDUgpkzwIM9izG2nGwc7G2RnP8BkfT8po6fUPae/WOPk2w5j6UyChWp4DuFgc1HZ1dRAM0mU533VNeb52ahnonWZ6kJ54E0I4+EPFmfCfPWgSPfKdUAIejJZGEA6bL9pll+VoFx4npUCUe5FQJKikXCon6qzk1ygN4PJq1KV+tyuavWYQFjIsefyK/5rzkyZuvDzZ5vGPz9b4w4KJczhNA6LAVHlwh/7olyoV0D5YbUFw2xu2vgOvEHkoMyVK5qB9H+LPIG+17PibM5Mie5qMjIF1ckZbIsy45 X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85ef8c44-1bcc-406e-ebce-08dbea77c4a2 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:53:52.6355 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0+3lNjFoGNGezr9ae9IseGkYjFwaC3L99Xer8iyD5bTcDpcuZFfci8Q3HRrp8sHwQGbcHt8dnGFdYcL50lvyug== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7750 Corresponding __lookup_addr_by_id() helper in the in-kernel netlink PM, this patch adds a new helper mptcp_userspace_pm_lookup_addr_by_id() to lookup the address entry with the given id on the userspace pm local address list. Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index b3a606a5e182..6999296cd5db 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -25,6 +25,18 @@ void mptcp_free_local_addr_list(struct mptcp_sock *msk) } } +static struct mptcp_pm_addr_entry * +mptcp_userspace_pm_lookup_addr_by_id(struct mptcp_sock *msk, unsigned int id) +{ + struct mptcp_pm_addr_entry *entry; + + list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) { + if (entry->addr.id == id) + return entry; + } + return NULL; +} + static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, struct mptcp_pm_addr_entry *entry) { @@ -107,15 +119,10 @@ int mptcp_userspace_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id, u8 *flags, int *ifindex) { - struct mptcp_pm_addr_entry *entry, *match = NULL; + struct mptcp_pm_addr_entry *match; spin_lock_bh(&msk->pm.lock); - list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) { - if (id == entry->addr.id) { - match = entry; - break; - } - } + match = mptcp_userspace_pm_lookup_addr_by_id(msk, id); spin_unlock_bh(&msk->pm.lock); if (match) { *flags = match->flags; @@ -247,7 +254,7 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) { struct nlattr *token = info->attrs[MPTCP_PM_ATTR_TOKEN]; struct nlattr *id = info->attrs[MPTCP_PM_ATTR_LOC_ID]; - struct mptcp_pm_addr_entry *match = NULL; + struct mptcp_pm_addr_entry *match; struct mptcp_pm_addr_entry *entry; struct mptcp_sock *msk; LIST_HEAD(free_list); @@ -284,13 +291,7 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) lock_sock(sk); - list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) { - if (entry->addr.id == id_val) { - match = entry; - break; - } - } - + match = mptcp_userspace_pm_lookup_addr_by_id(msk, id_val); if (!match) { GENL_SET_ERR_MSG(info, "address with specified id not found"); release_sock(sk); From patchwork Tue Nov 21 09:52:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462704 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2061.outbound.protection.outlook.com [40.107.105.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB978171AF for ; Tue, 21 Nov 2023 09:54:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="OEvWBBKs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i/CEKCOD3g7T5k28VaeARdDf/c5FRaNGFKsPPTd4ZRjy6C+w7n5NAzPeWKJWd5BeptzlMwkLf4HxsPxm6LWzXv01nXjSWLIn/t4saUc8XZ95K+i4tA5WG5CvQxVox9CQwKXoHg9TRG7aGLJ9dPFFuK/+kEiXbSv5I0FcrjkPEOTRuKk05VJz+SVvbv3oawQGKBt6/VMwtDYkqdEO90nymyb13QBUX6uYncqNQo6Q7REFJl1YADHbH/p9kciJYAQRv9cHx0Wu2oX3xqYKXmLlWLpIXpSi+mUbvtpyOruG845ZqNVzl6Op2zXD451LFXRWaBBOHwAFIxQ/Mo0kZqZ47Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pdLYbK7vXnu1Q5Sj+OUn839s8mJ1ffI2svEYGzcGgdM=; b=Vz0JDAhBdq67Leu+6DVzktdK3ww6xgQwxF+P7U9dvRmANnCeQMfRPWMqWohZJoGKqaOCAnHvlwEa8UFbI+uKsn+2GhyfsbkyQUa00OvPQpseJKaIt5PUooarMygMZ61SLGVQ5Aig0UwfrVsrJD7NY7WwM9gSi5aXNB8mikuFJ9BgLktrwzdvDhbca7Jql+EHIkbLlz56N67sxgfXfYsAtPXF400CzcmAtPg2cqxiWVVdvM44xntp6ADe/Y4Og0Kl9WFSHqLWgznd0Lq4/r75QiJELM3HtPc7/LudgxpXhp4p8wfhny+iM4vPDCXE6FLTq1NA+s7uU3rDs74KckFXYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pdLYbK7vXnu1Q5Sj+OUn839s8mJ1ffI2svEYGzcGgdM=; b=OEvWBBKspFgMYN7i84/G0dy4K96FdRKhi9bMA7IkwjNPfAxepnfolrxhCc7KMMMLOWQX69D+pPuerFW2BwTE4FGnQ67+QnsIYWgL0oLTAR7b728Moj0KJZlmZCkU4bnR1OGDE/gg05FMhPopGAClafMHoJtj+LV4xtOqM8asxYXb7ygcR53kOMTSvBPdOngPXMHOckpU/EzT6HtjSd6vlSTflZR+vRWiXyeIbB0kJra/zutE4imavka4XrxiHXYT8kHnA21EQBvPZ0SUXk04hu8ThRpOFGjWKmZmMwiqkZdO2XTJ7lIWIa2v6I8NaXYfh+ijVHuQUyZZ/OS5ai6ZEg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by AS8PR04MB7750.eurprd04.prod.outlook.com (2603:10a6:20b:2aa::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.17; Tue, 21 Nov 2023 09:54:00 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:54:00 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 05/28] mptcp: drop lookup_by_id parameter in lookup_addr Date: Tue, 21 Nov 2023 17:52:28 +0800 Message-Id: <49ca7641ccf2dce423b7f40462d0ba8f612a1658.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: TYAPR01CA0158.jpnprd01.prod.outlook.com (2603:1096:404:7e::26) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|AS8PR04MB7750:EE_ X-MS-Office365-Filtering-Correlation-Id: 97cf36ac-441d-4e10-2bb6-08dbea77c8f5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: otdWUkW5bRwoeR4P4JU+IahJyDmnCEMeuGVhBxd1idJNEbNPRi5SKulIXHr2nGnVCmeFW0MxTZRBET1HeoUn7eDKakUMRxQPfAPaYuwYEa1CU2NsyaO8DbkJAenbfu5SATfoDgacMwt20QAOSN08W7QSilSP+2NlDvO+mLjN+hCME6UYvuzSlaLW/a7WHoFHQJywDs/xBaPA0zwaouJ52DDhTqaXILj2Z+nYwljC5GFsRanOHE7Rzr4YeBwVKhCgv0kMPh0CWks0zn46HQPOk3CqHKFD0Z+TmAp0yzN+IizhS9uGnLb2J6R+Zd7uFstIfLgNSCTMoGdg6FZM1fCxYoV909zv53qcS7CRRmVHiZ4Gl7RBHteO3OBRyJEgMy5T2gEePJdxBJdJuPw3gR5mP6c2O44x8rZgcKGGxDcjRtsJNIXQjcmovAGjdkW6hvUXYbaf/Aq4wC1joNfcuALOHiDnD7BEZSo2SH+AQ1VPGSBp/bIJlCWc5BUblIjsMrx0G0saOE//cpMjLjfAhcr8+1/DC+dyGhorw5ZYy/JIvlUlMgmoWp3OtZDqjQ/leGrS X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(376002)(39860400002)(136003)(396003)(366004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(66946007)(66476007)(66556008)(316002)(6916009)(6506007)(36756003)(6512007)(6666004)(2616005)(26005)(107886003)(6486002)(478600001)(38100700002)(83380400001)(86362001)(2906002)(44832011)(5660300002)(4326008)(8936002)(41300700001)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiS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iBuYtkZEH541Zo63MzgT+K08zs+yGnkirShBhhYUhVQd0p6/G91OWYKuDi6fOVa3IoXO/OkZlSa4PN4Bvdx6lKbPKtB6MY9FKJXgSilkx4EI8/TyB5Dxt5vX9MCpqWiox32xYqW7txpWGCVrG+/T/zFpXvWP73mqG34QalG12ZSBXEwNCbDKi2ZZmOy7Z0JjHGKHj43CFPGi14PGbrDak5Ea9+zD8nXC0qZ3X6OZzFHr+nxb4hi5dx1sKBuJ80spRTeDVEIsoKSvHxeJ5yCr+AibsVeKyy+4Jqb0RSl9Gao+uD1gLr6HKXiZ0O1dWrS0MxUxQY1AlarbeNl82SkuuWHR5oi7vZSglnJhlCanSlPGnQgTRoAKLs3acUwRbS1qNY6KEP3ThI/mf0mhYglm1rF3BfVoVRBeDtVMynN+8WYraXlxqpnwhDDiePNuTM8eaRS1SVATexgaA/p0FcNEp4ClmVQBTF7C2IRIR5KNEHjlZoQzdmSX7pcoYKaSFf/9pqfG0l3p2BzmdgmNhgdNoevFM0JUy9 X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 97cf36ac-441d-4e10-2bb6-08dbea77c8f5 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:54:00.0812 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4i4BJlMC+Hkueia4CubXFcjxeJgcWcjA2h2fyUCgWuSIt/2rnkAq2HVxblif5Z1Q7qNiSRbjupBo6eT51Vtk8Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7750 When the lookup_by_id parameter of __lookup_addr() is true, it's the same as __lookup_addr_by_id(), it can be replaced by __lookup_addr_by_id() directly. So drop this parameter, let __lookup_addr() only looks up address on the local address list by comparing addresses in it, not address ids. Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index dbf040e39af4..4cb52df57ba5 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -458,15 +458,12 @@ __lookup_addr_by_id(struct pm_nl_pernet *pernet, unsigned int id) } static struct mptcp_pm_addr_entry * -__lookup_addr(struct pm_nl_pernet *pernet, const struct mptcp_addr_info *info, - bool lookup_by_id) +__lookup_addr(struct pm_nl_pernet *pernet, const struct mptcp_addr_info *info) { struct mptcp_pm_addr_entry *entry; list_for_each_entry(entry, &pernet->local_addr_list, list) { - if ((!lookup_by_id && - mptcp_addresses_equal(&entry->addr, info, entry->addr.port)) || - (lookup_by_id && entry->addr.id == info->id)) + if (mptcp_addresses_equal(&entry->addr, info, entry->addr.port)) return entry; } return NULL; @@ -496,7 +493,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(struct mptcp_sock *msk) mptcp_local_address((struct sock_common *)msk->first, &mpc_addr); rcu_read_lock(); - entry = __lookup_addr(pernet, &mpc_addr, false); + entry = __lookup_addr(pernet, &mpc_addr); if (entry) { __clear_bit(entry->addr.id, msk->pm.id_avail_bitmap); msk->mpc_endpoint_id = entry->addr.id; @@ -1832,7 +1829,8 @@ int mptcp_pm_nl_set_flags(struct net *net, struct mptcp_pm_addr_entry *addr, u8 } spin_lock_bh(&pernet->lock); - entry = __lookup_addr(pernet, &addr->addr, lookup_by_id); + entry = lookup_by_id ? __lookup_addr_by_id(pernet, addr->addr.id) : + __lookup_addr(pernet, &addr->addr); if (!entry) { spin_unlock_bh(&pernet->lock); return -EINVAL; From patchwork Tue Nov 21 09:52:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462705 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2050.outbound.protection.outlook.com [40.107.8.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AFF3E3C078 for ; Tue, 21 Nov 2023 09:54:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="z8ZUOrPJ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mF6A+myGcuDDj8PPqwCfVWcBPwT+H9A+HWqxvZ4ouhF0xsOBAZVJZysPgTmxpfJUYwpcmYHkFj/UMBGIwekfKCW7v5wGeHO5o1M6ZPM5Wjm8HIAUxXx6s8Rl80pY2KT/eLeNE2KCAt7UVxi8KOUI+I2+rxvvK7pyq4rDatgJTHO6aaqkygtfZICA/ahKtKmswCWCLvFX3WxqESmF9/4QgQfISvLvBLrsZrS7qnH2E1DiOleJJ42tfFJIIoQi3S2iMf1lE/jlivncoc1AbPneVr7nwE9dsjO4M1IPeTnM8B7qlE2M70huCPgP5YH/xfMEfbt3jicgj8qZTQzr1OMxcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9I9BhsUgHu9NIyvVUommWpfzUKT8CPGIVlfQ/Lgp1ME=; b=DjqfnqvBPxP1UF5G/TSb6xjtcyOiLPDxQb0exeem1IGew49+4lLdTvEw7iDeOXFiFU206MbIwMe1KT0l6I/1TfUKiRjVDefy0ZvrvwriB7q+Te2hf0bY5n0ClZVV2hTPQMGhpKoCfSD6ro8nzXNttExvTsuAV01wpq86oQy5zSgN3BCZs/FoRoRhhxK/diVFnQHTczXE7PzzHtSR/gourp1UXyZRC+Q7ejlgg50OozLzCAmXKknDj0u0AAOKwaZDKzRVBrKBE+gm7TCBrzRHTicVv813LZEREFfkVsz1Bn7g+6UtOsP3FHJ2RTeWbqU+sX3F6wHTfnxZlFHsWNqBOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9I9BhsUgHu9NIyvVUommWpfzUKT8CPGIVlfQ/Lgp1ME=; b=z8ZUOrPJFTfEmIiA71fgaoaSWOLE/7+8c5thbrBQrmRKYLgMvSPgepqA+qqkjdLh2w9y9q0LfsmlmECa4yMnRk4/Y562pXxkWTDERMYoZFLRbiKhotJW3yoe+gEsI/UOZ/99lmFfRdq7Klw0zk88MsDNWD6bU8wb5ZtFW0nI0p+tgAZ4Px30eZe37rB8G6T2OQFho8++9kK6kry1DI4a4ltLsY+u/lwu3UwZ5q9ulSJZPExCqQMttt56LbaVFZYZDRIaWfkP3Pc490ym11Ri580DawL5te4eFUGCKYLOTyGgqBOBdMUgiroVMHOkwgF2QPBmRC8RuI1l46ww4XMZKQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by AS8PR04MB7750.eurprd04.prod.outlook.com (2603:10a6:20b:2aa::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.17; Tue, 21 Nov 2023 09:54:06 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:54:06 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 06/28] mptcp: dump addrs in userspace pm list Date: Tue, 21 Nov 2023 17:52:29 +0800 Message-Id: <07f28a3a25e8d5448f4bbfac6fd27310dd40adb6.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SG2PR01CA0153.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::33) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|AS8PR04MB7750:EE_ X-MS-Office365-Filtering-Correlation-Id: 679bc27f-a5f0-4c0c-0dd3-08dbea77cce8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N8H+6j8HCemGMgTYLycNl3PMqtFFX6VwGXUuV8etHf4HoC2XZdpwr3McP2/OG0VmEEbO8zlER1FYAHWW0ncVVrqyRrpBlb3QnYy4j9e2caUCatP2gZk6E70/5VZ3x8kXZzPb2drU081X8Yr1ET+B0aKIw7oFUnmT9d+HOUe+xn1h4hPqS7vc3m+L+g2p0dg25G1UHM4Vc4f6Ycn91eC3qdKHc4w6WLvJVDL0uZuCFe1EzxCc9kcjcI7tGvrvMzKfi35KV/CUHizq2Dci0/SRh2lLRIHpUzyHqup4KgqSTRLXpkAt74ulesv/yEdqAi2ON+gpjV35c7GapoBMOhuw5Qv0BYwe5GNNHJJRb11Nc9xvxOHJVWwiNSxR6+Jvb7tG/MVtpjdVeJk/LnUVgdheyW/YoQMD/EUXeP0I1RddMSYNmmTs/sr3K3gBtv63IOaxN7AWiPEhjbgS+mMqF2Y/cfujO8SmzRcxQktVKQdNnTBOpyB2G6asmegZbtPfkdQjQd5Yis9RqFLCiRK2UxP3WXewCrGua85Qs9i9voPvnoc2foOSag1ID1PEytiYAfI7 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(376002)(39860400002)(136003)(396003)(366004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(66946007)(66476007)(66556008)(316002)(6916009)(6506007)(36756003)(6512007)(6666004)(2616005)(26005)(107886003)(6486002)(478600001)(38100700002)(83380400001)(86362001)(2906002)(44832011)(5660300002)(4326008)(8936002)(41300700001)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OA7Rb724K4wkhZ/OVAKuTgQcKo21m9iQ5JWtklvsr+MnfRrNMysjNU41WcgbaOF2rRD+ODLO1sMkwMP3M3n6zxTsDvCnqNkLCIWQcAX+PiPWkZoiKwKoGephKCVT/WN4TbAU+puZwj4ufmaGTABuC1gJ9jbbjjflGoGTxO4O9lylErnERvjDif7VEbAXc9bFzhfcVdYl+AEHkp6erwzze88NslIuXfqZRPMSyn3jFZNmJTtLz+n9b9l8ndSkAbb66q7bffv/554uHQFp3zUkOOJseos7Z5lsAlSPRD+b2qMCU9XDxdVLhhrnQRHFJzRLb8a4UH4LDc2YFljEcw6yBZHy/8VhaSZZc5FImkUkRJIdGY7aE4qfYDIgqlvuDx1UHs8OQOxclBARjvCCNsWfcVE3biS/lvMfnr324q++q1hSkxb49iTlZbrNqg2oRXAUuSJzvd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rdv14K0e7c4gNq5Ulwh2Hx6kQiAWxyFKLvghWK/YkFOk7PCO+nov96bacsrWRxjy X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 679bc27f-a5f0-4c0c-0dd3-08dbea77cce8 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:54:06.5255 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vAKho1U59ryIhkRRGme8l8cKLqnIDiYuC5F2aUEeKCqP83dVZ+/2VMAQlPIqeA8ogdC1fHRlwxp9Ix25EtZGRQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7750 This patch adds a new function __userspace_pm_lookup_addr_by_id() to lookup the address entry by the given id in the userspace local addresses list. Invoke it when dumping addresses from netlink commands. Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 9 +++++++-- net/mptcp/pm_userspace.c | 25 +++++++++++++++++++++++++ net/mptcp/protocol.h | 2 ++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 4cb52df57ba5..08b4211fbcbd 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1673,8 +1673,13 @@ int mptcp_pm_nl_get_addr_dumpit(struct sk_buff *msg, for (i = id; i < MPTCP_PM_MAX_ADDR_ID + 1; i++) { if (test_bit(i, pernet->id_bitmap)) { entry = __lookup_addr_by_id(pernet, i); - if (!entry) - break; + if (!entry) { + spin_unlock_bh(&pernet->lock); + entry = __userspace_pm_lookup_addr_by_id(net, i); + spin_lock_bh(&pernet->lock); + if (!entry) + break; + } if (entry->addr.id <= id) continue; diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 6999296cd5db..5e45e36ce1d3 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -549,3 +549,28 @@ int mptcp_userspace_pm_set_flags(struct net *net, struct nlattr *token, sock_put(sk); return ret; } + +struct mptcp_pm_addr_entry * +__userspace_pm_lookup_addr_by_id(struct net *net, unsigned int id) +{ + struct mptcp_pm_addr_entry *entry = NULL; + long s_slot = 0, s_num = 0; + struct mptcp_sock *msk; + + while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) { + struct sock *sk = (struct sock *)msk; + + if (mptcp_pm_is_userspace(msk)) { + lock_sock(sk); + spin_lock_bh(&msk->pm.lock); + entry = mptcp_userspace_pm_lookup_addr_by_id(msk, id); + spin_unlock_bh(&msk->pm.lock); + release_sock(sk); + } + + sock_put(sk); + cond_resched(); + } + + return entry; +} diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 88f5b422f941..c30e59278080 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1021,6 +1021,8 @@ 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); 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); +struct mptcp_pm_addr_entry * +__userspace_pm_lookup_addr_by_id(struct net *net, unsigned int id); void __init mptcp_pm_nl_init(void); void mptcp_pm_nl_work(struct mptcp_sock *msk); From patchwork Tue Nov 21 09:52:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462706 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2049.outbound.protection.outlook.com [40.107.8.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 648B43C089 for ; Tue, 21 Nov 2023 09:54:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="VYSGlFBS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b5eExSjUnHfbaRmj62fr7nZlOeuOe1jnirr1YkKwe6VuOPX+G56d9uEbORoCwzcalRyybNAtqimGrKH2JOq4vgZ5wbT5j7w2550BrGVOU+0phOUEQ3KZ75szqXeKs3xQb3ecm6wqZMDxdswQqbPUfY8TNoisCBoUvxUFuLn20xy2jKwia9SjOl8yoUi4Jc7SdZ1WGHnp7NLENHkzdwe5rIaMgAWCW0dasoHXxIj2//tb4iJ8M00P+IT9mDxwPde0RHmtuEQHqgdF+x/GjZq7dxndXJh3LJD5A/hShRuk4NHyTc21eJL7AlqIGY8c21Hmn4IXEuwYB5DYCIehKqlI+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dph7slE2gv8EAzbuXoW1AIj1s2dm2ND+F4+zezBtKwE=; b=T4V8s1YsOJfDv3dP/obkFp841tiXi1W3LOyj/klnHwOAKnQFKBfmfpBUUghHJrBte20YMI7BRk/MNsjUc+1lfqv+Z0aY8xaIgG98U7jTTe6WF7pajVslnNpsx02tRn/dOi7n0444WLHppHpneltDw39ca1365dCJlX7ZDC3qKlKS5jb4ibrKgNOB8TrPNYojIgZRp9GO+A5doeOuoZ1TOnpYTemqI91hGxKRWjJHxhrym208aPWwWWOGaWUNWui43ucOXvQ4Y2+l7xlUGj/NG+qWyFB81II89twJqveWAhxIwtTjGvHqe9Kz8KqF2g+BSRuyFZ8fdxJvUsWX4Y4oMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dph7slE2gv8EAzbuXoW1AIj1s2dm2ND+F4+zezBtKwE=; b=VYSGlFBSVvJeco0uEUt/buVO5UB0vAf4SpvHdDbJwjVZQbW3u5gNk6dfkiIEOTGvzRDQsc9Nj7BI5STkQA6T/CSA0k2K+89zcqKZtOI6/NSWJZ+THPO7LwqihbdkQ2yhZM362gG4roKZwESwDB+ToNw0WMToYqNqCGBqIhdLlgoAHskP+PyBYHOUBdf0zFrx/6Iv2kesGmEvr7k3z/DbDnasJn3S3IeO+1i8IenDqcwZTtOrXkOx/LvG0R4Vn3wBCf8PrIGCoVCMK8l13RZajapP2cFRhneLyCyiHXxImq2ORlAerdj/7b25zAx0+qwC7u0yYLNTm4BG3iGseUj0Tg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by AS8PR04MB7750.eurprd04.prod.outlook.com (2603:10a6:20b:2aa::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.17; Tue, 21 Nov 2023 09:54:13 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:54:13 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 07/28] mptcp: check userspace pm subflow flag Date: Tue, 21 Nov 2023 17:52:30 +0800 Message-Id: <662671ad849b15c44967221623090db6ed52e1a4.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SG2PR01CA0154.apcprd01.prod.exchangelabs.com (2603:1096:4:8f::34) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|AS8PR04MB7750:EE_ X-MS-Office365-Filtering-Correlation-Id: 9c6824e6-2bbd-4ffe-8d95-08dbea77d0d8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YQdF7FTdNJAUxkdhMudQkQkqFIVv+FHnGpkHOVI+RpsRoQ6N1XlmRe1blfDjC57ulcOTEW2ofXW6ugnPgc0GSfUCncKAASiC3r9lKHJEKyNxckaShi+qKGh7R3a3l9FZfiY78QvDN+1HVKo737FDdtWIST7SEaOZMfIu708puViKHvQH4WodAUyO6OSZ+HjQBHwfc4rS3GiDfVc7/5POCI4/nBwKFc1H3lFjVoSqh7pdiiJys3k9b4axog+RXpH7bfEjnqjA73BoE2xGFw/RgbHMILPmtXwq4caItCsq1i9sXzTHtb+i8ovZ9zONTvR9o4EAgNY2ROiC5JXbJOYeOVTCzWMP/m/6E2UNYvbcZWoCmC6QQo8VyD6XMr6spQFDC809pUVfeYQuh81RMq3k8gszcjcPVqQYpOd02CRGPmixRkMtopi7fNSG7TfK+dzDPjyedc5B69Vha3fxRcAJNy6avpIr8Uj1bc+b/HRa9R4f+z8hRsYizwuEG6iDC2dztHLlwasCn0knL82rk9g+FR8rJY2dgUAJRXhqoa/wVyplsSywZJTyH1gLsEYdlfEJ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(376002)(39860400002)(136003)(396003)(366004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(66946007)(66476007)(66556008)(316002)(6916009)(6506007)(36756003)(6512007)(6666004)(2616005)(26005)(107886003)(6486002)(478600001)(38100700002)(83380400001)(86362001)(2906002)(44832011)(5660300002)(4326008)(8936002)(41300700001)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ghahx1JW1tRPCG6GWmCAqY+PAnjssDXGVPit1rJ1ZNafkmD2Jhjqnr0tICrj9elut5s1ckdrs3BUYPlFE5RIunkh/FdeCl8M4tQB4VVbnRVcsMjQx3SFb+xaIpnV5oLg5fCIaNqFqA7+f7J2AsUza4rXgNP3COV4e6t9T9bsVC6v3aXS71b7EZA6Jq7m8jWYsMQHxwzW7INz9+beyrja1csu6b1dk1YuuMBAP36wN1Kitb77kVG4dm97oQCOB3G/2YTM/nCVvgttZaqyFO34FuU3Mj3hhCy1VnWdoCHTgpXkavws8FoUhv7/bOVqMTOgSzt/U+NGkD6q6IQ29fbTS7lgIuNjqTCC5PdaZYHTQNJ0e5HTnja3NOti3gsgyH85Gszh8qYbaKRCscJJHaCUC3Mp80OZAOOmPZDDcoJtWPofgrGRHtwgximGiy/FnAn/rVzLjcl6Z7OxMAJSejomEve5Mxor5bsBoEDqe+Wce7Ye0IWr10XoDXmKvvEWEyl/qpWwVuRKT7he8lOhT5hpxvgfo9d7q7Veh0SN7GOft3sQVTIpVGxh0QhJnBXpTLv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9c6824e6-2bbd-4ffe-8d95-08dbea77d0d8 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:54:13.1637 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NRkBvsIKmwYtOXCj9G1TgMEX0sC0PIm1hmEC1h7KMTrpPnJNYBGItmfR5cV7zo7T2iPVF5mRfrkYLr89W/X1aw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7750 This patch uses mptcp_pm_parse_entry() instead of mptcp_pm_parse_addr() to get the flags of the entry. Add MPTCP_PM_ADDR_FLAG_SUBFLOW flag check in mptcp_pm_nl_subflow_create_doit(). Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 5e45e36ce1d3..de10be21bf26 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -347,12 +347,19 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) goto create_err; } - err = mptcp_pm_parse_addr(laddr, info, &addr_l); + err = mptcp_pm_parse_entry(laddr, info, true, &local); if (err < 0) { NL_SET_ERR_MSG_ATTR(info->extack, laddr, "error parsing local addr"); goto create_err; } + if (!(local.flags & MPTCP_PM_ADDR_FLAG_SUBFLOW)) { + GENL_SET_ERR_MSG(info, "invalid addr flags"); + err = -EINVAL; + goto create_err; + } + addr_l = local.addr; + err = mptcp_pm_parse_addr(raddr, info, &addr_r); if (err < 0) { NL_SET_ERR_MSG_ATTR(info->extack, raddr, "error parsing remote addr"); @@ -365,7 +372,6 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) goto create_err; } - local.addr = addr_l; err = mptcp_userspace_pm_append_new_local_addr(msk, &local); if (err < 0) { GENL_SET_ERR_MSG(info, "did not match address and id"); From patchwork Tue Nov 21 09:52:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462707 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2043.outbound.protection.outlook.com [40.107.8.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E5BE3C077 for ; Tue, 21 Nov 2023 09:54:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="hP0HVZN/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hPhFN7HkPWbjeQee7kvJ4pM5vBqeJPBf5jKGhhphvwnc+t63P/N1q6h+wNxpdhQeYkmYLyaPfHR7ExcRFl6Pqrnm/GuaEHt1B/qVMS80L11AMMOJuoMrs/HzxHqem+dKqv3dG0YWEotUDzUCK7uGMSzwZ6wWYbV6s6H3PP6WFPWmcitHb0mMj6ilwTDmwIkoG2cnTuAdpoWY48uUyvRiibOTOGe0Ud4HTrZHk6q0B/L5ZBPFY1HZuaJyoVZujDe37WyLoARhYS/9aXExEcjaDv9QdYrP9Hw4zBxaf9Ppp74ccbOKPLjI3V1RY2UDg0CpsrCpoonLAcWTUgfYjhMOoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bOp2TWhtoPPob1E5rhy13X9kUGO29azvPp9LWLnT+zM=; b=hnLD5yXn5l2eMVFy/DPIjHC7yLZK6vDTcr7sPgtMjBIKO0mBU8sj81GAdMqUnt6FVzs4G8ymHc9lxoe6aq+LvOczFMGBgKD6RFi3CDEeJdDm1QxteICrr7ZMHn5LCFQ3itsjMRIgJ+ejntVqhJltU5ETp3wLP9oQvbdBDEB6YTepGKX5JgakUjFw7Xk866HHxEKrpgmhjBeW6Y6L8VyZg6wJDE3k3rwdog3naa2aj4evJLOJVxF9TDAqd8zHHC9vvjlTLXnsjMhVdcu3e5E/JnMTW0Tr/SwfZq6PmOvTfSEoY7pj3g7z9dqvZH8dJiTxhQtEUKu8hgnpRdetuxMr9w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bOp2TWhtoPPob1E5rhy13X9kUGO29azvPp9LWLnT+zM=; b=hP0HVZN/ICpk2M8VYZ459QejlFxb7IptTWuzTZYJvNznjJHFdPugTJr9ratNkRPuo7eal370J8RHRVbAKe5XOBcXp7rPRMq+gZ0fScFFlxbYJhPIJPeJ3NcMg3o5nQBFj1/SBUwfnqSCrNJxDWT7Ygk6dco5an8sZidnZ/5lhFp6BmIbMR94ouBv9AAnm959oeOWxaMQ89Z+OpLT/HTjVepqfI9hi1zbqdOoGzRo8xm17Shtxot5sT8CC5JWu3YTJsQErzo80vldqt0iddMVvuk+xbSXTfXF4625kgtdI+JdDljBHlfoSQ7PHQB+MLcEMpFjbzAYqZFW8jNFXTQZWA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by AS8PR04MB7750.eurprd04.prod.outlook.com (2603:10a6:20b:2aa::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.17; Tue, 21 Nov 2023 09:54:20 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:54:20 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 08/28] selftests: mptcp: add userspace pm subflow flag Date: Tue, 21 Nov 2023 17:52:31 +0800 Message-Id: <37c21db4b03b769dbec59960e0f1ae07cf9250fa.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: TYCP286CA0352.JPNP286.PROD.OUTLOOK.COM (2603:1096:405:7c::19) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|AS8PR04MB7750:EE_ X-MS-Office365-Filtering-Correlation-Id: a012c6e4-f682-4ffd-1d4a-08dbea77d51a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pxXPk4eKzxEC0UdGApiVAhd44s7hvh7CUuVp/P63PF/Bfw8wnRtn1y/ZYrS+IiN/dyMmfIFHy9NeuRAekn6rSeehoVomOTDqWIxYrqU9iXbD8/P2Gavbd4MyryNKFSnD1ZE5APben49NbNXTUIWb/8S/QDsl/8uscdQNDcA9peN2hNVeTTxWP2AOdHiAK7hnYUxCN9OFazdaGW35Zr0zz8wKyy5//sWhmHRzWQ8SS8bphaTiotfiAW4NN/l9K9P1+DUGTmzQbaQJw2TIp1NxF9rmhV9ybwN9nuwDXmGgzGLSYZWm9B5s5sPZ3HDdepYhdzo9J16LK0axN7EhW0CPjKc0NB5rxHAa+g7ArdDredxV2GrfUJa9MakNopDQnd1FraiUAnUnQba02GFkYpGZOw+bhUUb1YH9VuSl7/pLaQdhMOahIAZKaFXC+3utOU3UzlCsIHp2t2D3rJb55wMqUViDXO9ZSR62SAv/ft/ivlx4Ce0iBqbipv0N733q2CxCSR16IvwUdKn7ravEZ3OQMl3t8cu8VaEqzViEpeqOgyrymK9/00cfEpssxtHt0v+r X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(376002)(39860400002)(136003)(396003)(366004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(66946007)(66476007)(66556008)(316002)(6916009)(6506007)(36756003)(6512007)(6666004)(2616005)(26005)(107886003)(6486002)(478600001)(38100700002)(86362001)(2906002)(44832011)(5660300002)(4326008)(8936002)(41300700001)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1c52u/2t6iGwtyl+t604RqivOQeyEjPQwTnhuegJIuU1v5Wb5gkmlNPzK2VbR22vtC81YpQ33zF9vLTg5djQertUz3YOKd3tXTO7faxDi7atpqj/hgzeUQihNkOPGINHj+mZsgp/S5nyoK1NUklSdRgRvada9pjHZ459FeEVq6Zn3hIvDKpfsgYG4AyR13Xqw9MBpKmYCCYC0eFB6ziVpKr0hbsnesCmopfEgNnll2W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blz3sUy8yM7WT/StZZH8chJORJSYysUwcPzh5XMlN5/xT6xYP96ISkglVNk1SaK1X1Fo/heze9DC9GPtmJSTfiAGv21ZNLlmfHgRHCeCazb2+XDx87LUGifO0FQNUZUXWPnX+PV5vnE7BZDrWS+A2YPcgAwfOlyvhcVQV3tqV3T0hIW3oD4YgCN9a9euTC3q7FqI684OpHgwpl4piJOoCJfPXJtZPL/kn+6ksKwR0SFCR+qynEChu/LwTdD1nz/RVAIxZEBCLJ5oUHE3AXQ2CxP5la0 X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: a012c6e4-f682-4ffd-1d4a-08dbea77d51a X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:54:20.1513 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 48ebjAxNr3B15Q8T3BW64tUAyyX/i2jV2NCRDbNIyFaTDn2eBrIT/LhEi59rghwvyZv9w75lGuOyKjYR7NRwnw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7750 This patch adds the address flag MPTCP_PM_ADDR_FLAG_SUBFLOW in csf() in pm_nl_ctl.c when subflow is created by a userspace PM. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c index 49369c4a5f26..e97856323ec3 100644 --- a/tools/testing/selftests/net/mptcp/pm_nl_ctl.c +++ b/tools/testing/selftests/net/mptcp/pm_nl_ctl.c @@ -453,6 +453,7 @@ int csf(int fd, int pm_family, int argc, char *argv[]) char data[NLMSG_ALIGN(sizeof(struct nlmsghdr)) + NLMSG_ALIGN(sizeof(struct genlmsghdr)) + 1024]; + u_int32_t flags = MPTCP_PM_ADDR_FLAG_SUBFLOW; const char *params[5]; struct nlmsghdr *nh; struct rtattr *addr; @@ -558,6 +559,13 @@ int csf(int fd, int pm_family, int argc, char *argv[]) off += NLMSG_ALIGN(rta->rta_len); } + /* addr flags */ + rta = (void *)(data + off); + rta->rta_type = MPTCP_PM_ADDR_ATTR_FLAGS; + rta->rta_len = RTA_LENGTH(4); + memcpy(RTA_DATA(rta), &flags, 4); + off += NLMSG_ALIGN(rta->rta_len); + addr->rta_len = off - addr_start; } From patchwork Tue Nov 21 09:52:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462708 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2058.outbound.protection.outlook.com [40.107.8.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 49ED13C078 for ; Tue, 21 Nov 2023 09:54:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="uacqQDoY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IPwXASqF9yC7wNNaBpohgOfv/RhVpqiGxeFBjXVXGN3sosu76nRQFoiZziYD91OBhZifKSG1gtpiP3pL1DNjuiueGjcgSLKlG6aKWnwHsYvfsbSsdp+GMCYy2TAZQcy3B5eVzfyQ8zUJkGgDs4uiw9Er2t4Y8r2VcIxjkgb7Xnlghryqsd5qb0kC0VT2x+uL3qKvCrPvO0k1Owi0gexoSg9herPAPgA0Lin51NjcsLGM0qUkMNy51vg8Yc8poJPH0rsywWWICqexCQXNiuHexdlnjNn6wDXIHQcX1VLkTJU9fY20TmPA/VZnpgGBkXHUQh3BHue5l3rcJPVUU0kdUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=crNiTFpMjs7yAPN8QhN6HNu+J2Et+4KM+5JXUFciygI=; b=NWjfgGYseVrvkln8kvb+KmkGSKs3++F7e6FcZ1N1PEsxXfBYZ9KAvxm0aDCGqj+59AJ/v4PMowa1px8tye0Nu2JAM8C+bjCL0udORRkJjPb0wpiutThZhy7RTHtQ+I4kErKHHVUeDokUFMhp4MLjDAYokMy18OoeoVU+vGuGqn6RjW9xgeydrAQnmyTTZ/unC6rTXhyhUxi0n87+ukTMMv6/r2ZFGBjMYL2h99Bqu+XQMXOQ4yItZoKYhINEdKxyIqCfMS+NGWTukJVpq9TQFrPItynUg7g6aIRN1PA++XUvcWmZJGwKbcqMfkOD61mG/WmQIQKCFtRrZAiTSsUuwA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=crNiTFpMjs7yAPN8QhN6HNu+J2Et+4KM+5JXUFciygI=; b=uacqQDoYEUcHORUjl6VdajNUSyfkWs+NsHSPY+dgn0AQo7FxFUtqfeAcueSnvKpkXLbADWkBtSokHFq3QKopAXEue3I386c3Yyyg+gZrgL6mPlHWhLFDWNLmSz+3N75Q3d+/cp+vCvkOyVKrrY984ueVESzgGySEiAnhmbv0ojolSExXGNTAuISeZcNuqBIfAalYsUsJ9ytdlHYvDNRfTRrWwnWYjJ9UNz+VlmbMD5t/Ru+NHqajmN9jKaXDx6Z5rDGFfTkSmYzbTtsT8/t8k2OqKtLhQWfMdW0eKzdvVRddNtrnFdomgO8NaY6SgEg/Ck2tQyI1kT2UDILnZA/4dg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by AS8PR04MB7750.eurprd04.prod.outlook.com (2603:10a6:20b:2aa::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.17; Tue, 21 Nov 2023 09:54:27 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:54:27 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 09/28] selftests: mptcp: add mptcp_lib_cleanup Date: Tue, 21 Nov 2023 17:52:32 +0800 Message-Id: <1fdeac5cb3c1c117af407a4b9e626b82b9405d89.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: TYCP286CA0357.JPNP286.PROD.OUTLOOK.COM (2603:1096:405:7c::15) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|AS8PR04MB7750:EE_ X-MS-Office365-Filtering-Correlation-Id: fcdeb031-b0e9-4ed6-4a17-08dbea77d959 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k8hRHqMMevWM8kccoSxc0tybA7DKPUfa5XlhwJCfmyDQDCMo843pcNiz4pFPpRfsRgzOl0WwrcjeYmheavF3Auk9k+iz+DgApw+0SEXlDwer0HgSg8e7Di/D6Z6XC74a6FO+9ANANRnoSqte2FZ6ieyShXSA+mGZ4ao4/eZKGeY4WLChF043n+XblNVTiNYhHAjBwMM1Z8r4+SZBgb4yV+ie2M99xUiqghzvFrC3JhgoIQJPi4ydrK6Tzq3PVZb+4JFLLcL0Dj49kRIIwgQsjTa+TEgZhqh1sH2kDoJToP9LE9VzJAaCO6cXFIbBqGqLd3+JQvNS/TFrZlIaEax0+8A27SkW2OFSjuzP2OpCvYT605lIpaIDziaA3SUR4rL3iqUfzrw5RSc5+UNIDoWS9JAkoucSYHBspemIe0g7bXMuFNi5KvMUYI//nw/B/5eK1xcTgBubl2p9ueRKz/XSiTVLE8Jz43MN1vrDz7JOMg2+Cd7Kr94IMtsrWl/Ac36WTK+62OPgFarKIJerxVrz+N+SjHaGaiiYYDj3TGlwIa4sbVWE3Ag7Dx8H/r33LbZl X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(376002)(39860400002)(136003)(396003)(366004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(66946007)(66476007)(66556008)(316002)(6916009)(6506007)(36756003)(6512007)(6666004)(2616005)(26005)(107886003)(6486002)(478600001)(38100700002)(86362001)(2906002)(44832011)(5660300002)(4326008)(8936002)(41300700001)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: r/A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eaUe20aQ+7djkDa4GkxP6chCDgcnbxdDdCiBzYn8E8Vo8J1PJKjfDAllYv0xNhuiDm3iQ4hYbEG27WTAbAf32lN4HY2d6d+drokWiFgZw3Jwo8oQPFryYi2WKytjpAJieuvta3gDzpmw+krMoLw/sCYM3sgNTZs0yQdZXIZEtFCvl0GjZcqRdtjSan2YlmAvENZJuwekHGvXdvCpC+rR6VmRraPhzbZZw4HYVhbmZvXdwkybZBjKmB2vQUKslrRLpvKj4TL4sd1DXP2omstHnfUfY3nOUqi33h0UwxYCIOwAa7WjEiErmJuBoZwCA1SW9qijvIbWgR14J+wl5nbQ0lOppwtuoqalOm6pHnNUv6db9ZckYyEByylVlyQJ/ayRrhJKNqosfwTNNdITbiwy+N4KKW4HBPDuq7GPW3AlYVdHwTEAcx2/fI5tdnw2MuIbSB+DV3lFxA2fSi5Ty3GD/Qm+D9wECxa3cbNGVfriynFQzyhvjm43Ft X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: fcdeb031-b0e9-4ed6-4a17-08dbea77d959 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:54:27.8599 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BxOmqtBTb4nnjYdp4HuocwCyFt4J+pjxwbul8iWHJJBGWhTXtAAknUHCWvTVXewALR5i7yx5XWPZhSlD/3Pz4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7750 This patch adds a new helper mptcp_lib_cleanup() in mptcp_lib.sh, it's a public cleanup interface, being invoked in every cleanup() in all scripts. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/diag.sh | 1 + tools/testing/selftests/net/mptcp/mptcp_connect.sh | 1 + tools/testing/selftests/net/mptcp/mptcp_join.sh | 1 + tools/testing/selftests/net/mptcp/mptcp_lib.sh | 5 +++++ tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 1 + tools/testing/selftests/net/mptcp/pm_netlink.sh | 1 + tools/testing/selftests/net/mptcp/simult_flows.sh | 1 + tools/testing/selftests/net/mptcp/userspace_pm.sh | 1 + 8 files changed, 12 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh index 95b498efacd1..a678ee21973b 100755 --- a/tools/testing/selftests/net/mptcp/diag.sh +++ b/tools/testing/selftests/net/mptcp/diag.sh @@ -31,6 +31,7 @@ cleanup() ip netns pids "${ns}" | xargs --no-run-if-empty kill -SIGKILL &>/dev/null ip netns del $ns + mptcp_lib_cleanup } mptcp_lib_check_mptcp diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh index 7898d62fce0b..98f4e82789ba 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh @@ -143,6 +143,7 @@ cleanup() ip netns del $netns rm -f /tmp/$netns.{nstat,out} done + mptcp_lib_cleanup } mptcp_lib_check_mptcp diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 87590a43b50d..98b6814af0e5 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -198,6 +198,7 @@ cleanup() rm -f "$tmpfile" rm -rf $evts_ns1 $evts_ns2 cleanup_partial + mptcp_lib_cleanup } print_title() diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh index 1f8be9dd0e20..cbaa55ab89b1 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -299,3 +299,8 @@ mptcp_lib_wait_local_port_listen() { sleep 0.1 done } + +mptcp_lib_cleanup() +{ + echo "cleanup" +} diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh index c643872ddf47..75d8c648f9de 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh @@ -85,6 +85,7 @@ cleanup() done rm -f "$cin" "$cout" rm -f "$sin" "$sout" + mptcp_lib_cleanup } mptcp_lib_check_mptcp diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh index 8f4ff123a7eb..fd413b4c8123 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -34,6 +34,7 @@ cleanup() { rm -f $err ip netns del $ns1 + mptcp_lib_cleanup } mptcp_lib_check_mptcp diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh index ae8ad5d6fb9d..436500c55e12 100755 --- a/tools/testing/selftests/net/mptcp/simult_flows.sh +++ b/tools/testing/selftests/net/mptcp/simult_flows.sh @@ -34,6 +34,7 @@ cleanup() for netns in "$ns1" "$ns2" "$ns3";do ip netns del $netns done + mptcp_lib_cleanup } mptcp_lib_check_mptcp diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh index 6167837f48e1..005251b61d7a 100755 --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh @@ -129,6 +129,7 @@ cleanup() rm -rf $file $client_evts $server_evts + mptcp_lib_cleanup _printf "Done\n" } From patchwork Tue Nov 21 09:52:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462709 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2044.outbound.protection.outlook.com [40.107.105.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 103823C077 for ; Tue, 21 Nov 2023 09:54:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="aFc1VGXW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ABzJNTfrLpK7oZWAifrJlHQ5Vp0XvgKGcCOVOWetoShSJUbWPfaf0QZnY0DV/Zg5hqnzMcOxweeBkQnLsh6W0H9exc+iGkDmiDLcj+HpHvczkVaT2eySRJNeWJk9hqiYJHeaT3nm+IFWbhMQtt5KZVNb2mwy7MMZqz/It3omJI+jC2e8XsbaP2wIlHiXZbNinORkCCkOh6Uo8IUyLVrnZcAiDuy9/h2HzZHPo1wdLRWRI6g3kFYqsiSCdcYbTQM15nj9UAQwEIRRO0zqLRtyXKMP/UHi911W5xzAQvO6AVOC8d0DQkZ7knGwmDTlEQUYqYythVqLF4u4SJkZwZxXaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9MCqP+9ev3Zn9Zhu2iFrljXS/zRzUA1qKs+uUfko21U=; b=K8oWkxJk75G0GBHSC2Rf/tiQlluVihO7aAfYsHw7eshEb3q4uHfkvZvVOJJmIBFiVVmcME8tghWXV8KM1aM8d+Sut8QguckxRV7lTeM6D8POEiTEMpED/Rx7DB2lu27zhxVZfSXCDFRn2EOiEHuZi9Fe0QSawCOG/5tLa/mrAtgulAcjn+Itl71o3EayyOlu0RISuRUp2tAohZjTjaneBn5c7esIKvSv8GXNDaFAzlRmF61RCbT6MX42Mor5u377kUVkekycYSpSv4mp46PNfYmcdoqUKP5553i4xo5TuNJ23OlNBvROzfLoAnjttq6kAj1USRADFckQrb4wUlih4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9MCqP+9ev3Zn9Zhu2iFrljXS/zRzUA1qKs+uUfko21U=; b=aFc1VGXWFXAXeESGxfANPwTP2Iqse5UeBBewtiyQ+un2KZpJK+0qgzXM2AXbTogrYMkQ1evs4Wix1JqKtwKNnXnLeUghahXrggVHjjxDw7PYwtfWdXLTxGWfWSecOHevEEifr8s+Hz97d1rhs8dyOkpSV2oU30mIzsFMa0j4dqzgJckkqZkhTyml4ywBgIpmrqAYfXc8ocSiJj3eoEqJ0c0rm9F/7U3YiaONEJg+ODxccW8B8rAL8MpK6Y2PZZuqTmjuRloBWj5+BYDd+uos40+IGFVNwjSwLkFFjlj0hmv3/E/mcAPGyte4AW+xlvEPxfEgo46Mzyci9LeplO42PA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by AS8PR04MB7750.eurprd04.prod.outlook.com (2603:10a6:20b:2aa::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.17; Tue, 21 Nov 2023 09:54:34 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:54:34 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 10/28] selftests: mptcp: add mptcp_lib_check helper Date: Tue, 21 Nov 2023 17:52:33 +0800 Message-Id: X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SG2PR02CA0136.apcprd02.prod.outlook.com (2603:1096:4:188::16) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|AS8PR04MB7750:EE_ X-MS-Office365-Filtering-Correlation-Id: 2450bcaa-16e9-4513-7bc1-08dbea77dd3b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: T4mGAjFDZLmIrlxhhGUIPoMHTuEWzJ2pUr89+I2joQVKi2q4LMwOOXHNrsnE73v2ZxMHAFJHuJE4e63jfYXDQIOySe9Cnh/cXnCDQ2NS7p0hT/RYzXf4bmeJvSiRUpJ20iQcpeG6MfUPzM6VO9WWCCE8okVRM45ARz6ZHVMhmd1aV6zcmoHONKjoVckBlibFnZcy+kCi55EEYDvxkpKTAADZX/8InV3GDeHufJVhEgcVJD9eqbV8sL1lwLS45aqgcxewdTeaqX4saRhwduhpAYnP1NT/En6JHvz2vPJBRtoFWkonM3kjILoVUslDC1JCvCCs/qovjrJcIda0mayvwbOurLN6FDWlex/AlLGQ4hZoZQUVa7Bumo8I9Wsp10Zcc359OzhFjzbD9FoBo+MbVVzNjVIdGZs8H0EJFXfovsyGxCBYLGGgszN6ugsJVSTXfom/M14qpI5uy0bCOYQSD/dkdZatujVjp1YGnY3mRxVUS3YsWy0i5bLjsQ6DtvtugKPzMb4S3jUhEuY6HqDbfB0iTYKPPq/eueFYjc2Fn2GgXW9C4yC9qoxecG4EkMpB X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(376002)(39860400002)(136003)(396003)(366004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(66946007)(66476007)(66556008)(316002)(6916009)(6506007)(36756003)(6512007)(2616005)(26005)(107886003)(6486002)(478600001)(38100700002)(83380400001)(86362001)(2906002)(44832011)(5660300002)(4326008)(8936002)(41300700001)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pR56fH0VvfPtj8nj+arHuosjcnpwRx72cRx3yfFxnPSAGSJQECzmFFHX4BDPMKDYTOb7So5NxTnRkDpxF6gnLy1Mrs1DiSKLzPfnNBKv/ta8CZnbaiOKJkyxKMQSyeMf4Xy0cIH3ub/d6EiqI/5g4H/8B5ms1tyiKaWl2Xl7yEFm9QTPSJ/XdG5hofiJdGYcF9k5ycLU0skquPHVQ+c6IeQrSNIXEb1pX/4Gq94GmNKYU+D7DydRksZlFqpEjK3BcMyXhtLy7L1MqIS+iqn9MYep6qMxhr6avnmL/TGut30+0Uac3AdLl5FvX36VP6WDaAFHKez10MlaOmU1QzI7YPSLYzJNtcT4PPliZqFpwMrfAjw1S6muR+EHhHN4DkPc9ZRF7tMsGqRRzpAJj79+eoERaA9qqF40YriKg8s4n5GUqb7UJGELFOtfYG8sAR8ZH/hdHrgC3O+IO5XBiDDYS0Pj+Zby/tuQL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jEVx+7zRv/tRcsPuG7lCDVBFHqz4AwJLmrzbtaB1iXX6TOL9zveFdj+vuOV/gpZ+exMynWvYKLA5DtDb8rcF3L07Jvg== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2450bcaa-16e9-4513-7bc1-08dbea77dd3b X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:54:34.1315 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9X1UvaSRKiZ07pa0Gmpy1WoQfT/L+ifh24f0IKxUqpdKoXzGN10jM/vA9FGpI+l6e93XfdaTA4P2Td8jeaLmxw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7750 Extract the main part of check() in pm_netlink.sh to a new function mptcp_lib_check() in mptcp_lib.sh. And use mptcp_lib_print_ok() and _err() in it to print test results with colors. This helper will be used in mptcp_john.sh later. Signed-off-by: Geliang Tang --- .../testing/selftests/net/mptcp/mptcp_lib.sh | 27 +++++++++++++++++ .../testing/selftests/net/mptcp/pm_netlink.sh | 29 +++++-------------- 2 files changed, 35 insertions(+), 21 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh index cbaa55ab89b1..39bdfc6621d2 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -300,7 +300,34 @@ mptcp_lib_wait_local_port_listen() { done } +mptcp_lib_err=$(mktemp) + +mptcp_lib_check() +{ + local cmd="$1" + local expected="$2" + local msg="$3" + local out=`$cmd 2>$mptcp_lib_err` + local cmd_ret=$? + + printf "%-42s" "$msg" + if [ $cmd_ret -ne 0 ]; then + mptcp_lib_print_err "[ FAIL ] command execution '$cmd' stderr " + cat $mptcp_lib_err + ret=1 + return $cmd_ret + elif [ "$out" = "$expected" ]; then + mptcp_lib_print_ok "[ OK ]" + return 0 + else + mptcp_lib_print_err "[ FAIL ] expected '$expected' got '$out'" + ret=1 + return 1 + fi +} + mptcp_lib_cleanup() { echo "cleanup" + rm -f $mptcp_lib_err } diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh index fd413b4c8123..8d30d4a1db57 100755 --- a/tools/testing/selftests/net/mptcp/pm_netlink.sh +++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh @@ -27,12 +27,10 @@ done sec=$(date +%s) rndh=$(printf %x $sec)-$(mktemp -u XXXXXX) ns1="ns1-$rndh" -err=$(mktemp) ret=0 cleanup() { - rm -f $err ip netns del $ns1 mptcp_lib_cleanup } @@ -53,26 +51,15 @@ ip netns exec $ns1 sysctl -q net.mptcp.enabled=1 check() { - local cmd="$1" - local expected="$2" - local msg="$3" - local out=`$cmd 2>$err` - local cmd_ret=$? - - printf "%-50s" "$msg" - if [ $cmd_ret -ne 0 ]; then - echo "[FAIL] command execution '$cmd' stderr " - cat $err - mptcp_lib_result_fail "${msg} # error ${cmd_ret}" - ret=1 - elif [ "$out" = "$expected" ]; then - echo "[ OK ]" - mptcp_lib_result_pass "${msg}" + # ${*} doesn't work here since there're spaces in some arguments. + mptcp_lib_check "${1}" "${2}" "${3}" + local rc=$? + if [ ${rc} -eq 0 ]; then + mptcp_lib_result_pass "${3}" + elif [ ${rc} -eq 1 ]; then + mptcp_lib_result_fail "${3} # different output" else - echo -n "[FAIL] " - echo "expected '$expected' got '$out'" - mptcp_lib_result_fail "${msg} # different output" - ret=1 + mptcp_lib_result_fail "${3} # error ${rc}" fi } From patchwork Tue Nov 21 09:52:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462710 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2085.outbound.protection.outlook.com [40.107.105.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 144853BB49 for ; Tue, 21 Nov 2023 09:54:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="GW9UaB68" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OcRISQYlSpTpuDlp9vFukWUWTNAkl7iCh2LIPuf4kS0MHxMdDjSWrtSUH6bfWwtg4bOoRkxjTuHaQus6jUYcT0Bd/DiZsjaUJl7Q8AThyagXlwg9RT2vaHpWf0+7EDZjiSlDLvRAsyJrNSl4TILIEfGVsIws2LHPkBsrqk7dB1y9jskUrp9FVgaEcipSYN7FLBwiaHJvPyB3/K7RRg45yoopmpU22mNr/ddNW64Enxbdg8KGgIGymFZQ8jD7F2qqLiedj6Fu93IKZds6jXTVKotOSbSDoQKMY6nMcr55cAPFHDKthPBmNy3qYEgfMOqb4wqE3NgNzq9+vyHGq+ZRzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UnjZaB7bRb43ZitZcS0sAU7VHwQ51rokw2Rj2Ke/7Vk=; b=i9lzhqZpSq3UaDsgR0YFv5t4XzdLt6GAC2gI9qVHy9ZvIpWR1KMdIcqGjGiM3vMbg2/0J4+9HPKZ1YkTkjfUHhQUzanz6iWrR3KkSVQ79rZVZKNao1NwaOaaiPFDRvYczMh+nSl7RTtRPPw+0Kzvb9hPUxgCzaPjCbMFAaF7RlTJJBcXDe/N7imsHD4nZTjT3D3yUjB+2Tk2mstzbCiCMhuCGFQkchIdShAA3iZUzJ4WsW7ha91/7kLtbLWKP6cqxpRmhvOruKiSoWlU1KbMLaX4SRdQ43H2JHaH2pcB8ZukjhnYaHsf1rtFLbFelSLedn9tgYvx6U0RUKmIBKWYaA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UnjZaB7bRb43ZitZcS0sAU7VHwQ51rokw2Rj2Ke/7Vk=; b=GW9UaB68PDqjzELyd1nA1vZL58ou/oZN6mtk6sRudpvD5uSI4iG7p7ongkqSe3ZWT3vVLnS4jFsEoJG/4w06vpPVAGMFwIyLseTWvnIr4DaRRHn+mriutSvjj9iBKNZMRNQVSQrm8gPljdDQFzCgvn/9yoTUTS5zuIfS4X6q2PIBugT/HuMZWnBuqtvHoIoySDuCqE1AL3TRUxniV6mScaUnEQP4UGrGfW6JL0Z8WR5PiCSed29RQv442bhpMw9fn4oWsOFY+6vyexKpZw0q4qJjRjKb0jGWbOKdNJ7IxYbMWA24p1eyzYKeyRjnaUKlQoIpwldudiQ30qkEtC6SrA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by AS8PR04MB7750.eurprd04.prod.outlook.com (2603:10a6:20b:2aa::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.17; Tue, 21 Nov 2023 09:54:39 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:54:39 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 11/28] selftests: mptcp: dump userspace addrs list Date: Tue, 21 Nov 2023 17:52:34 +0800 Message-Id: <6ffc562b0456bc522f88c8a567a55873eaf0e2b4.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SG2PR02CA0136.apcprd02.prod.outlook.com (2603:1096:4:188::16) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|AS8PR04MB7750:EE_ X-MS-Office365-Filtering-Correlation-Id: d74ddb15-f7b1-4c12-b696-08dbea77e063 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EBfznEVyxfODpbSgvOYq3Aw1ch7kuKn3/uQkXm3U1ZbWVX6Ht2Z/GTpdjmqFKLHOh+t7brDk/JlsGkItWmRUUWWGFMJ4s8dMKpB+mYQ/N/2hSOI7d3kO5u+4MzFOyhMRBc2ihuc7mi8tyW6tn8MVu+5HnVjZn2WV4DdVF9Rf3Iq1SyBM9173yUPELMenDNHLcDO8xUwGTW8jioVNP/937l4y15LW06Ysh4nCOu1GLmGsqxPdh5GXdIdVtJDComXV2jjgIyXXEnQ/2fXL+FqwokLMiMq+Vej5IWo8babuaO7Cin7VD2CYl5Wct9dA6QVGxmhoH/Q3kCIqDreZafE1yY63x58OyG5Yud0Wvmue+pVlLJBUcObgrHTqzY4AQgzBw4YV3H7+jH6XJ3K1/m6kKDVuxIhm/yWbLPF0Wacg7EGTR3XwEAK048D26KgOt53CFHeAws+aValaf2RQ37H9SIqumUm0SDleTTPe/gdeldrqUxPuzxdtVGmHfmAGPtaoeuNPS30ge/y24Wp6rQULy4Cy1wjST2S+qAkLWcnFJQ3uB2zxpbyUOBxFWtHZYxez X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(376002)(39860400002)(136003)(396003)(366004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(66946007)(66476007)(66556008)(316002)(6916009)(6506007)(36756003)(6512007)(6666004)(2616005)(26005)(107886003)(6486002)(478600001)(38100700002)(83380400001)(86362001)(2906002)(44832011)(5660300002)(4326008)(8936002)(41300700001)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mHGwWfFHsVYrHmZIv+UX/kHrqLehl8uZMRN21JmTd98L30DXqAmoPhE9TJ7kAd9Ml11z5h8bBdkdVNeqIFrBI7rbg6r9QqDZkl3vfS2rlid/eaZO/jPJBcoxF5oLWbBQKdwyVGh2cl1uaHvyzGePF9YwYd+KwRKayirIx8blVYhDCf1CqGQGKkA+JWgt6als+TCjsP3dmsMx1C7RhO0BSp1o9/EZFH+YlwNqU7mfJiy7qW5+1BqUrVypVpl0DKm5/+7e0OOTHoFd1KkUv6lUiJfKUuaqsp2tjiAJ1N1vPp3CZeNCINCGs4L8NR7CQ6ghu2Yvhe5MFUfz9NsF9dMZ5TZap/zTCh1OXWhmKYSYjUhlb9kR6HzCLXSG/OVi9BVthRKUJsJw9VUvtuwS6v5GNR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yIi3ZEc76vru8U8IM8ufcZnWM6whRYaI4NuYulE3E3zY8DHi9CQ8QHTcp+0FIS7gA7VFAbvQDSxk22kdtz7+u2OmpA5cXSvNXZKf84PDWajNDgdOa9xBKlrlOgJMX0zm1Q== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: d74ddb15-f7b1-4c12-b696-08dbea77e063 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:54:39.4846 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UH+OYLRBUa/WENcjS72tln8VnMdQ9ScjtUUUfE3GnXi4erk626HJrlnnux4M2GGhDj9UyVGWWk0ditm8Tpw9gQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7750 This patch tests newly added dump command for the userspace PM. Add two new tests for userspace pm dump address and subflow. Use the helpers userspace_pm_add_addr() and userspace_pm_add_sf() to add an address and a suflow, and use mptcp_lib_check() helper to check the outputs of dump commands. Signed-off-by: Geliang Tang --- .../testing/selftests/net/mptcp/mptcp_join.sh | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 98b6814af0e5..eae9f84423ee 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3511,6 +3511,50 @@ userspace_tests() kill_events_pids wait $tests_pid fi + + # userspace pm dump address + if reset_with_events "userspace pm dump address" && + continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + set_userspace_pm $ns1 + pm_nl_set_limits $ns2 1 1 + speed=5 \ + run_tests $ns1 $ns2 10.0.1.1 & + local tests_pid=$! + wait_mpj $ns1 + userspace_pm_add_addr $ns1 10.0.2.1 10 + chk_join_nr 1 1 1 + chk_add_nr 1 1 + chk_mptcp_info subflows 1 subflows 1 + chk_subflows_total 2 2 + chk_mptcp_info add_addr_signal 1 add_addr_accepted 1 + mptcp_lib_check "ip netns exec $ns1 ./pm_nl_ctl dump" \ + "id 10 flags signal 10.0.2.1" \ + " dump addrs signal" + kill_events_pids + wait $tests_pid + fi + + # userspace pm dump subflow + if reset_with_events "userspace pm dump subflow" && + continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then + set_userspace_pm $ns2 + pm_nl_set_limits $ns1 0 1 + speed=5 \ + run_tests $ns1 $ns2 10.0.1.1 & + local tests_pid=$! + wait_mpj $ns2 + chk_mptcp_info subflows 0 subflows 0 + chk_subflows_total 1 1 + userspace_pm_add_sf $ns2 10.0.3.2 20 + chk_join_nr 1 1 1 + chk_mptcp_info subflows 1 subflows 1 + chk_subflows_total 2 2 + mptcp_lib_check "ip netns exec $ns2 ./pm_nl_ctl dump" \ + "id 20 flags subflow 10.0.3.2" \ + " dump addrs subflow" + kill_events_pids + wait $tests_pid + fi } endpoint_tests() From patchwork Tue Nov 21 09:52:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462711 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2053.outbound.protection.outlook.com [40.107.8.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3CB2F3BB49 for ; Tue, 21 Nov 2023 09:54:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="2AMoBrTv" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jUluhowZH5fhQuvxY7yFz2CZvmxOoqtw7kmaFGvOEZU56CQ6q6GBicEsNQKJhWj2D4mwHLXuoMl31s2EThZbh1O811lZaYOn6+mim8ORWh9Z7LfkO9c4nOTDdn1tVGHjH9omw0yCSag2MiFaYvyP3HVMJhuKU39L/zm9BGK8D4hKY4oS7Ycu/ybHgsFuOlVV2yoCgkWSnaZtNStHm57yd4t3YNtpb9eFe69oqcbS5BE37ODb9YPcUBIxbDJMo76edrhqbn1Jfx1Ro+kMpR4BlcC/buEBTtOlL054eWNCuXRPNXWetEdKVsQPNpYdhRTCnczxG8YL0c34zuXCHKn9Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=e8cF9N0Tt7Wm0hCVdx2El5/WoarZD0AglWoxn39IpyU=; b=Z8N4KFYpimVOBD6QyHYwaLCM/pCYzFkJcScjus/Nxy2hgtmkhdYBJl29cvKRpM0SV8xPCEWq0EtpnFTeaYSzIzn3QDdnTdXAMkIjFJYWaGNj4Zhw2k6yrp7vsty1mXagGQd5yCL1jFq5c0xGS23nDMnwZIzyh1CFm53BVDbk/MmuFMsuhRFZY9keu6W/oTvx/ZxF1KgphBjnA5aVgatUzcVLTMbaOQYOkdNXZpaJT6Deq9Yw1HQ1pDvCh2YFRBoahjg94yVNcpfoR8BZc9qnqV/1ImqwuMGgWvTiJrST4naojpalRlPP+51mnx3kf/5yddHwCm+irX0Fe19K2yp89A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=e8cF9N0Tt7Wm0hCVdx2El5/WoarZD0AglWoxn39IpyU=; b=2AMoBrTvkk1nOX8SiR1MWNpUrb+LOPe0FQsRt5H4cWaA/hURoLO/an/J4KRlKszSTr2tVaXUVDEAI+dAzEGTHShJGVHoksthw3IaNtQSQnIEFhq/4tDv3TfRnLECYW+2JEDxBfP0usvf8ZdyxeuvdfBFq9/zvk5fH8x38Z1vDSL3NJCGIYHIsVFettPjQFqLqsDfN+UdDxps8n0vXCduTJtweedouSMstrv+l0Ld8kKEY0hyggDOzsTcH5vysxIUpN2tIZCX1VEFCGa5VVwyJiL+OpxK+1ZaOJQNy4xRqKSIzpbrLGFJCnVxS5BkevqTkj0RKIaBT4YNv2NSXUwdJg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by AS8PR04MB7750.eurprd04.prod.outlook.com (2603:10a6:20b:2aa::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.17; Tue, 21 Nov 2023 09:54:45 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:54:45 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 12/28] mptcp: set set_id flag when parsing addr Date: Tue, 21 Nov 2023 17:52:35 +0800 Message-Id: <55a43ff03cae9a70f9129ddeece8f83f1982d36f.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SG2PR02CA0124.apcprd02.prod.outlook.com (2603:1096:4:188::9) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|AS8PR04MB7750:EE_ X-MS-Office365-Filtering-Correlation-Id: da0c85b5-5601-40b8-2381-08dbea77e441 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9eA7oSL7iMQyeRwpS0fGLITqUur2A6jWhq7X0MjIDcER9aJz756bEEEJiLVdZ2LNhwGUv8RXIPPg/7qXNYfSaalja6k4XYYWGdcG2lZNr8C9RSXANdFUGsb55quql/VSkuSvY+eV2guJ+v4LVsmJzfhrVJin7MRjVQH38m6LOEw5EyJwPWESbGVxFwWqZqnVdU5Yt07BUJXIFnwoRC+n+DIeOe4PYGdhFQext1joeqG5SbKH+s0ocVz9ikmhpBZugToDJ4X0zCvuSfE1PTHTPlm1vWdYtyyjrClpngEbAmUhB99/iniM6INUp47Td/LOftke0VkZt2gciIJWiJuD2nEbiyE4adYmg+mIOR0rvFlQodwlCdM6Kw2XOVPYlWUe3G5QAvlxCJFSaqC9zJ8/g9g48cccs9f0L5s1vK/h0ChNHNbB7q4vX0adeayz6IdBbZMfzhPCuImkkXSr8jTCMKSUrMwPgW2MSx+Gf2dVIOG7nv/uq2xOZghVnJAmFO6BUW/p9OWV29HAVgC0qG7RlVboO08uX2csJpqAAi5dSrL/tEvFw2wVf1KmjMhHtkmU X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(376002)(39860400002)(136003)(396003)(366004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(66946007)(66476007)(66556008)(316002)(6916009)(6506007)(36756003)(6512007)(6666004)(2616005)(26005)(107886003)(6486002)(478600001)(38100700002)(83380400001)(86362001)(2906002)(44832011)(5660300002)(4326008)(8936002)(41300700001)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fij3Jy+2sTTMCmML9I7iOzFx6kS5W9uDMa+mlK1z6YpSYxOVbPaPhpZgGlgq696O+ycrh3gtqT9NYu4Gfrf9/sJTHHTL9UlRA+zCgW6ZvBQdPjHTZLfjYR26DtMW7xmuJaQgx79ICz5BD9b8eIqdNAKHz5S0uvqVYIAAHiFUQkA2U4V6NbUQp86OZs3KmBsCWcHrov/t2kaDdMRuTVoTxWcHy+QqcUJQIEJ1MscIVV6o7V6rUR0rLIjiWufsxJT9uCKJtJ+zLzlTbZn7HLL5IVgfrukjL7G7+/xh0nwu6AMDhNwEkAbTIDFmkOYJyKCU/ks5WJcU1ktChhK2uSyudcXyC7wzT2NIPazPRVP6xXR/BlUZPFALLNZ3bPD9fK4tc/SaXZAqmurOiBFu3YpaDHz4eQOA5pSGM0y5nUnVXBBvOfNcSTGBVullucNPqKAfRBaj2rOaVEVFespvj9tj+c4kyHrKUf/+iW2XhqMmAy5V4ReyNbIBSc3gO2Gn3jaT5PkvcbC/7oRpznDeFMfEEjLc0AuOXDmBdCXTsng/ZW08zAU4y9rCrDGU4SBdMXBjvnLXgQt6Zvg2k/fvzeXTqgmUhlCUyqVwGzyTxGAiVcw7Ob31cpq+cur1c5IAhHtqz9/veji6mx+RsvyFDeCyF9Zl2Y6DtMPrgYcnT6nh/WtUuRKf5tVBNXjkfcKl/6p8TuU4rJ4pdJwakZRLzO6HFqYmuZnM6hvF5VwGK+k3QxI4Ri7HbQRdIgdJsEThGEY+9f7/WyzfCk5a6SfqP75Xb6Cw75CFCIsyiz7ot14uZ71K2d4LsUEoDN3kE3y47P5kqTEWeI/662fTLdTcTp4ePrDENpb0WUZSr2mDb1dD2A0mgLaRI7Rd4cU3zaArKsw0VSA1JTNzg9IglTEfkI9IUPV+OWeq3llzu5x/bhKVCForyVDlESQra664TjuSlrKfs2p6ELsC0lkOXV+o47oockQyfF2rP13E2sB8e8iDr1U3djHXnCBn4/uqYkcajFZ/LvfzpDWMvXO45Xhi8Xm/xJCtKBqxywy7rgaLeTm7gfA+8fB7w+JhHk1nzqXixhJDbHX70NG3RY96BAPk9kJ49I0zgiJqgI5z8XuouhKPrC9aDkadv6iXynLJXLH/h69EoR1+E6OLFEhjb+FOfJ/s8905Uj6TrrEpf5IzPzFCeTz1/FANulen/3OL03i71n02VT/ei8O9uS9KMhp4DnYUkf4V1yz8oYeZybt6u1v5FGMAcXrDGmHX4r17X1mkAyfzbT7Z1g7IJSRXOzbbUhazMbCDrmbqkb056kriQTqQ4bPM95SWSmmDC4ZYdxL7gAGGod2/Zlov/XSdzZpaK1rb4a4CQ+g84iEI35awQUdnQFNmz+2A6ZF1Vl5nVMsaoHhUQrxF9D80QAmG4jyvlnUVcLKaEWkrx9uown7tGJ8SIE8ySYxbwCDbIpd4RrigigXcJqyyu1R30xNyurxkB7L7qFlSH6pur0DXO077cKk+KHSZN1QLZmnTtpABKoNODl4FxaM9YobcUQPNEYTlmbAvOiiCEkOC9ewYTlVMZmbp0LZLqZHZC2Kdkan35oL2KMpoS/FTDFL3/O6nXUBuBu0Oew== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: da0c85b5-5601-40b8-2381-08dbea77e441 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:54:45.8680 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 65DYwmf0Uh4x33peF8v4/nmhZEILYgdXSKzlFg58VwmmHB5yByblU3uShbtkUu55hLAxBH2ybd9AU3Z1YVzt7A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7750 When userspace PM requires to create an ID 0 subflow in "userspace pm create id 0 subflow" test like this: userspace_pm_add_sf $ns2 10.0.3.2 0 An Id 1 subflow, in fact, is created. Since in mptcp_pm_nl_append_new_local_addr(), 'id 0' will be treated as no ID is set by userspace, and will allocate a new ID immediately: if (!e->addr.id) e->addr.id = find_next_zero_bit(pernet->id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1, 1); To solve this issue, a 'set_id' flag is needed to distinguish between whether userspace has set an ID 0 or whether userspace has not set any address. This patch adds a new parameter 'set_id' for mptcp_pm_parse_entry() and mptcp_pm_parse_pm_addr_attr(), and pass a 'set_id' flag to them. If an address id is set from userspace, this flag will be set as true. Fixes: e5ed101a6028 ("mptcp: userspace pm allow creating id 0 subflow") Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 26 ++++++++++++++++---------- net/mptcp/pm_userspace.c | 6 ++++-- net/mptcp/protocol.h | 3 ++- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 08b4211fbcbd..4db37baf74ed 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1108,7 +1108,8 @@ static int mptcp_pm_parse_pm_addr_attr(struct nlattr *tb[], const struct nlattr *attr, struct genl_info *info, struct mptcp_addr_info *addr, - bool require_family) + bool require_family, + bool *set_id) { int err, addr_addr; @@ -1123,8 +1124,11 @@ static int mptcp_pm_parse_pm_addr_attr(struct nlattr *tb[], if (err) return err; - if (tb[MPTCP_PM_ADDR_ATTR_ID]) + if (tb[MPTCP_PM_ADDR_ATTR_ID]) { addr->id = nla_get_u8(tb[MPTCP_PM_ADDR_ATTR_ID]); + if (set_id) + *set_id = true; + } if (!tb[MPTCP_PM_ADDR_ATTR_FAMILY]) { if (!require_family) @@ -1172,19 +1176,20 @@ int mptcp_pm_parse_addr(struct nlattr *attr, struct genl_info *info, memset(addr, 0, sizeof(*addr)); - return mptcp_pm_parse_pm_addr_attr(tb, attr, info, addr, true); + return mptcp_pm_parse_pm_addr_attr(tb, attr, info, addr, true, NULL); } int mptcp_pm_parse_entry(struct nlattr *attr, struct genl_info *info, bool require_family, - struct mptcp_pm_addr_entry *entry) + struct mptcp_pm_addr_entry *entry, + bool *set_id) { struct nlattr *tb[MPTCP_PM_ADDR_ATTR_MAX + 1]; int err; memset(entry, 0, sizeof(*entry)); - err = mptcp_pm_parse_pm_addr_attr(tb, attr, info, &entry->addr, require_family); + err = mptcp_pm_parse_pm_addr_attr(tb, attr, info, &entry->addr, require_family, set_id); if (err) return err; @@ -1239,9 +1244,10 @@ int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info) struct nlattr *attr = info->attrs[MPTCP_PM_ENDPOINT_ADDR]; struct pm_nl_pernet *pernet = genl_info_pm_nl(info); struct mptcp_pm_addr_entry addr, *entry; + bool set_id = false; int ret; - ret = mptcp_pm_parse_entry(attr, info, true, &addr); + ret = mptcp_pm_parse_entry(attr, info, true, &addr, &set_id); if (ret < 0) return ret; @@ -1423,7 +1429,7 @@ int mptcp_pm_nl_del_addr_doit(struct sk_buff *skb, struct genl_info *info) unsigned int addr_max; int ret; - ret = mptcp_pm_parse_entry(attr, info, false, &addr); + ret = mptcp_pm_parse_entry(attr, info, false, &addr, NULL); if (ret < 0) return ret; @@ -1616,7 +1622,7 @@ int mptcp_pm_nl_get_addr_doit(struct sk_buff *skb, struct genl_info *info) void *reply; int ret; - ret = mptcp_pm_parse_entry(attr, info, false, &addr); + ret = mptcp_pm_parse_entry(attr, info, false, &addr, NULL); if (ret < 0) return ret; @@ -1866,12 +1872,12 @@ int mptcp_pm_nl_set_flags_doit(struct sk_buff *skb, struct genl_info *info) u8 bkup = 0; int ret; - ret = mptcp_pm_parse_entry(attr, info, false, &addr); + ret = mptcp_pm_parse_entry(attr, info, false, &addr, NULL); if (ret < 0) return ret; if (attr_rem) { - ret = mptcp_pm_parse_entry(attr_rem, info, false, &remote); + ret = mptcp_pm_parse_entry(attr_rem, info, false, &remote, NULL); if (ret < 0) return ret; } diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index de10be21bf26..3d4258d2e269 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -156,6 +156,7 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) struct nlattr *addr = info->attrs[MPTCP_PM_ATTR_ADDR]; struct mptcp_pm_addr_entry addr_val; struct mptcp_sock *msk; + bool set_id = false; int err = -EINVAL; struct sock *sk; u32 token_val; @@ -180,7 +181,7 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) goto announce_err; } - err = mptcp_pm_parse_entry(addr, info, true, &addr_val); + err = mptcp_pm_parse_entry(addr, info, true, &addr_val, &set_id); if (err < 0) { GENL_SET_ERR_MSG(info, "error parsing local address"); goto announce_err; @@ -323,6 +324,7 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) struct mptcp_addr_info addr_r; struct mptcp_addr_info addr_l; struct mptcp_sock *msk; + bool set_id = false; int err = -EINVAL; struct sock *sk; u32 token_val; @@ -347,7 +349,7 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) goto create_err; } - err = mptcp_pm_parse_entry(laddr, info, true, &local); + err = mptcp_pm_parse_entry(laddr, info, true, &local, &set_id); if (err < 0) { NL_SET_ERR_MSG_ATTR(info->extack, laddr, "error parsing local addr"); goto create_err; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index c30e59278080..0460cb391ede 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -881,7 +881,8 @@ int mptcp_pm_parse_addr(struct nlattr *attr, struct genl_info *info, struct mptcp_addr_info *addr); int mptcp_pm_parse_entry(struct nlattr *attr, struct genl_info *info, bool require_family, - struct mptcp_pm_addr_entry *entry); + struct mptcp_pm_addr_entry *entry, + bool *set_id); bool mptcp_pm_addr_families_match(const struct sock *sk, const struct mptcp_addr_info *loc, const struct mptcp_addr_info *rem); From patchwork Tue Nov 21 09:52:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462712 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2042.outbound.protection.outlook.com [40.107.8.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 278123BB49 for ; Tue, 21 Nov 2023 09:54:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="tUnQY+Ny" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gUyuEBRGnd0v+KOB3TxGI8Mz3NYgJLSfRywdTmFHZriGaVqYu9EOd17+DUm69QgsRWmzZRjygToYcT21KdOX1jPo9zMKaPVabbSN5WXVDAspPsuz9Q8GRRfO3QrYBA9/+lmND/M2wh6vxEkOV5nnvShfv93DciJRbilyQo2SKlDrnMSIywifpa2YMUHDa64tX4XV4cCHVGC2JZVH/0FBua4eeYJgvQky7/kEX8818UOw+oPBfuic9dp9O2cqfqUo77nXyL15qC6Q+ajSjfU+Z2c9Z8gbAzbRHzUYH+U4/73OQuRXV6GIqZWccbbC557Ja8tN4xz4e2MQ9ctvmBixqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Sv6SbZfaNpoauTaauA4Q4ikrqXjzoN6RyN0lTmIDWjk=; b=WYt9RhmBggLIpmoVqI4IJGj61Ay1f+jyP95qBdZmqgk/iPs3AL+vOHnESEHgQPsVinqpQStFBFNONXKOVe/aouM4Q/MIzvXp5/yeHmxSHKgifoQJyNkuABhOLHBbhLfTzoUsaWnJe5DZkwnVM7/OH8MyABawxBkk0zv4A2hUEn4RFm160ExyMVEjX3UIgDpTyvY+XDWGW2fYodc0pGhQLR0pg7Mm9I0psdymW7WCkCIXCYYEb3yaPAv9CzBP/igKseFoGdaXHicsUX8gDhNF9i+K3NXBnnWfyEV8OB4dLEE3m53OH5w7NW4Jt5BtqsdVoFUqiP0Nh55FQsd2TPn9mA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Sv6SbZfaNpoauTaauA4Q4ikrqXjzoN6RyN0lTmIDWjk=; b=tUnQY+NyCdyPvKv2aDUU4LJfFLLP7wbCg/eY9JJ9+segG7hbQS84ataNGtJigoG2dv6nby7U4LjNoDS8o8+AJKWBNhWuSaRL57S+O+y+rTNE/2YY5xExsRXTK/wFoOHxeQZLr4E7g1yV7J79L6Ac220qLIszulQ3BLf8D2LL0v2etKO4JhCpd864uIPgG/ySbP99W3ZC8s68c+DHuS9UjQxDJRlVs7u2o97dZw51zxwDxxUTBmMOWfJCBLLWZcSRqtQgyf278Plrp7L6SkW1dSGjJXhcZHvlmhCNX+VNQn90xF6zOp59iYmlIaxOFTQ2x/PEL32yKNbRgJErmHR63w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by AS8PR04MB7750.eurprd04.prod.outlook.com (2603:10a6:20b:2aa::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.17; Tue, 21 Nov 2023 09:54:53 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:54:53 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 13/28] mptcp: use set_id flag when appending addr Date: Tue, 21 Nov 2023 17:52:36 +0800 Message-Id: <99e17e0aec758315b1aad49db5f4a610d592ad50.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: TYCPR01CA0168.jpnprd01.prod.outlook.com (2603:1096:400:2b2::8) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|AS8PR04MB7750:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a75de6f-1b29-47f5-e9c9-08dbea77e8da X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uUpRUNQj4TfDuzPDlxFc4Rj9nimSYBGJmu4E5cp/GYuk2SIY0dVKhm5yuPZhLDEWmrK+/Np6r+H+9ctT7JID5G8E/Y8h0jXz7C2P1WmXd8L9oP57W7IxLt3Ch8dYHh4DD4oR7/tB97exexpnEG0E0MGDitU5WjP/68J+YXnAbV7dAFe+AbSgJu9b3RBjDOLGvHcZsOQbh8cyt5ajHRxFT4CIxDgoniyn5FH3ZyWWTsIvDDUqWLfO1bJhEaGpS++km0xjWjXYaHItg14mZx0KEQP1rF9eFM4fBQygs3ItFdgIfkN92tW309E1lHcLVIBGASXprC2VPSz3CDwSk+K+JzzYgWJ063cjed2LvWOFGfSXBJPbY+Tv1sW41esgwQ7/KIbX6wAIox9HU6O43dBMCbIq2qFWz/UjD7qPSyrqYMxoZnxKjfUFueibMKQQXMFAe1E1R4ZHT/3ds+LFsDeCwf5O8Mx3oDUIXhIfLutQG+lMa7ca9I7sWmP5yZzzOc7JqFtn2muFo033sRaKfsIzgp+v8DVrsK/tWjWOMOazL2WevcfIbDvLfLQSkvgWyk3h X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(376002)(39860400002)(136003)(396003)(366004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(66946007)(66476007)(66556008)(316002)(6916009)(6506007)(36756003)(6512007)(6666004)(2616005)(26005)(107886003)(6486002)(478600001)(38100700002)(83380400001)(86362001)(2906002)(44832011)(5660300002)(4326008)(8936002)(41300700001)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PLPar3l9JAQxAEDeLBjGdOx6OOofOYrzvywhC6L4Ya8cR/0mp1/e++7RTOpOrDt2OK6kCbsva3zEjMEbyvNBHfxOBoRtyGaC4xWnF1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6MiPmbaL1zGZG341slF955IyzzDqK5PDURnTOXNRiyzaD7f5VrN+ncUHwWcufoHsv8oVri03lhnYcD8dXKtrg8yyQSjIpJG396voFCwpBT61J1V3p2xtsT9wQGx55cuP7ogO8Oi0SJeEl90LJHpkPJQUuLu5ooA8+NLdBh08ovplE0EnDZ+Idxb6tLqy/uLxFAeV3Kf7EhmJVtYCIR+a2u5so8o2fK4dAhqBMXUR52DtJsyg+OezEhgxkS8ME6m4bOM0AiUAQZwDgM49Iwn5Z5F8K7DOdSasv0nEHtdcMt+3OUB6A2f9um7dIxuYRnK1og5WnASvKuzN2G5wWKkjC50ZWbtiDmXwhBG1kl298GVjhBRSAiiCrAQZCJZfwI62FRNvrt+81yYv3F+yLnlTenZsDv715E+fC0alWVFkadsUOGN9/kgRCwJevQ== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7a75de6f-1b29-47f5-e9c9-08dbea77e8da X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:54:53.4759 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bVtmoV8E0VP2QHC2z2pLgFY+PSFNzRgKAzqixSUppGa82E9raXK/n4R0YZh0hhhkpJ4l+JZR/NkJ7sIeikJWxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7750 This patch uses 'set_id' flag when appending new addr, adds a new parameter 'set_id' for mptcp_pm_nl_append_new_local_addr() in pm_netlink and mptcp_userspace_pm_append_new_local_addr() in pm_userspace. Pass the flag 'set_id', which was set when parsing the address, into these append new local address functions. If this flag is set, do not alloc new address ID from id_bitmap, just keep the userspace set address ID. Fixes: e5ed101a6028 ("mptcp: userspace pm allow creating id 0 subflow") Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 11 ++++++----- net/mptcp/pm_userspace.c | 13 +++++++------ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 4db37baf74ed..cc4ac206f848 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -855,7 +855,8 @@ static void __mptcp_pm_release_addr_entry(struct mptcp_pm_addr_entry *entry) } static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet, - struct mptcp_pm_addr_entry *entry) + struct mptcp_pm_addr_entry *entry, + bool set_id) { struct mptcp_pm_addr_entry *cur, *del_entry = NULL; unsigned int addr_max; @@ -903,7 +904,7 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet, } } - if (!entry->addr.id) { + if (!entry->addr.id && !set_id) { find_next: entry->addr.id = find_next_zero_bit(pernet->id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1, @@ -914,7 +915,7 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet, } } - if (!entry->addr.id) + if (!entry->addr.id && !set_id) goto out; __set_bit(entry->addr.id, pernet->id_bitmap); @@ -1041,7 +1042,7 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc entry->ifindex = 0; entry->flags = MPTCP_PM_ADDR_FLAG_IMPLICIT; entry->lsk = NULL; - ret = mptcp_pm_nl_append_new_local_addr(pernet, entry); + ret = mptcp_pm_nl_append_new_local_addr(pernet, entry, false); if (ret < 0) kfree(entry); @@ -1281,7 +1282,7 @@ int mptcp_pm_nl_add_addr_doit(struct sk_buff *skb, struct genl_info *info) goto out_free; } } - ret = mptcp_pm_nl_append_new_local_addr(pernet, entry); + ret = mptcp_pm_nl_append_new_local_addr(pernet, entry, set_id); if (ret < 0) { GENL_SET_ERR_MSG_FMT(info, "too many addresses or duplicate one: %d", ret); goto out_free; diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 3d4258d2e269..c9dc25fa8540 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -38,7 +38,8 @@ mptcp_userspace_pm_lookup_addr_by_id(struct mptcp_sock *msk, unsigned int id) } static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, - struct mptcp_pm_addr_entry *entry) + struct mptcp_pm_addr_entry *entry, + bool set_id) { struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); struct mptcp_pm_addr_entry *match = NULL; @@ -51,7 +52,7 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, spin_lock_bh(&msk->pm.lock); list_for_each_entry(e, &msk->pm.userspace_pm_local_addr_list, list) { addr_match = mptcp_addresses_equal(&e->addr, &entry->addr, true); - if (addr_match && entry->addr.id == 0) + if (addr_match && entry->addr.id == 0 && !set_id) entry->addr.id = e->addr.id; id_match = (e->addr.id == entry->addr.id); if (addr_match && id_match) { @@ -73,7 +74,7 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, } *e = *entry; - if (!e->addr.id) + if (!e->addr.id && !set_id) e->addr.id = find_next_zero_bit(pernet->id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1, 1); @@ -147,7 +148,7 @@ int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, if (new_entry.addr.port == msk_sport) new_entry.addr.port = 0; - return mptcp_userspace_pm_append_new_local_addr(msk, &new_entry); + return mptcp_userspace_pm_append_new_local_addr(msk, &new_entry, false); } int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) @@ -193,7 +194,7 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) goto announce_err; } - err = mptcp_userspace_pm_append_new_local_addr(msk, &addr_val); + err = mptcp_userspace_pm_append_new_local_addr(msk, &addr_val, set_id); if (err < 0) { GENL_SET_ERR_MSG(info, "did not match address and id"); goto announce_err; @@ -374,7 +375,7 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) goto create_err; } - err = mptcp_userspace_pm_append_new_local_addr(msk, &local); + err = mptcp_userspace_pm_append_new_local_addr(msk, &local, set_id); if (err < 0) { GENL_SET_ERR_MSG(info, "did not match address and id"); goto create_err; From patchwork Tue Nov 21 09:52:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462713 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2063.outbound.protection.outlook.com [40.107.105.63]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB9783BB49 for ; Tue, 21 Nov 2023 09:55:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="vLfNqLFW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Azx9bgLrKofYoxAQDGbR9VKTRe6HkLwkxUU26DnsDyJiGBR1Z8Ql5Pf8s+H7WYufiMb4mwrIILv6cPDWSH8WodvYEP3i4GkLqoow57Eed8UoQ6cZ65NlaYRs+7Tfu7Wduc0EZv+lYTuDZ3wSNKwkyWZWODdYqX+uGlZ/fbGpFmGg1BrBQtUcJBMKGsp7RYlQyaNC47TI43wwoX23ocrMN+9y6UnJjkdQc15wf6aSq9rEbBHd6T4vb8iMtkLfSVQBd8sSb4Ui8lbIBcwXaXqwdsBZ5K7dH3ItHUAq/2ePlngcQxy1e8PhBweahFCy0erK+W9DkyzzgemNxJrZ+ZHpmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+W/0yUoZ1wnZFt80IkvapzV5PXq/PasaOPYw4JO1yqA=; b=SCXZ3MXTFQGCb0EQD3iJJlinG+di/dmcL8g5yCaSoNkQcBu5cqn2SxpJYDdjDKXOhMBZ8Oq32Ko2CgAHZ6+50bEpXsNkuWdXeh+lIGzgKQUwC3wFjCCuKtt9oA4u3ZsRx171sDVGirQnWqfaP80ow6qnsE/SC1cm/kTH1HepJHlnCml93sVbhOBs08CMDbUa5wrA09O9W4VEFG5/AFayTA9T8NxxHLY7Px0p1wVUFoQ9NCSzEgPi+MRLrd5Ek/+RHVMBfkxtBkuohfusvE9LTecOsBZtkYpRG2vbCKmFRYAgeE3YUa+KZBDKlXgmIHCTqc44I2NwSOk9uqnuI3B7mQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+W/0yUoZ1wnZFt80IkvapzV5PXq/PasaOPYw4JO1yqA=; b=vLfNqLFWh/B8ZUhGjAuD2E7CASeZZQ5HZ9Ho/aVUteR3DzD5oKq2yuCVu3R4OU6pYmol7cUQ6rPvj/2ivM3RDZgIX44V0Qo8QPLg6bzMWJpzYOLyQHn3fdFgXF3pj/+XOGHAveyF7g2NKnWXqtz9+bYsqWmi3mTf/CEvwRquFxftZ/QsgY8EQIdTOy45OU16RIQs92JBIDTlCcNWQQms0zdN0Utib22gYnqAuphRTV06hq3JeeHz6cfCNz+JcOYAzyp7tmRGLMoGwqq3YOeqpB0NNlNOWkKCngwXzAnBzK4fg4DnEzdFk+Sfrf/bK9zKmr++nZjEJhHlbajSuZKWFg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by AS8PR04MB7750.eurprd04.prod.outlook.com (2603:10a6:20b:2aa::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.17; Tue, 21 Nov 2023 09:55:01 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:55:01 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 14/28] mptcp: check addrs list in userspace_pm_get_local_id Date: Tue, 21 Nov 2023 17:52:37 +0800 Message-Id: X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: TYCPR01CA0173.jpnprd01.prod.outlook.com (2603:1096:400:2b2::11) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|AS8PR04MB7750:EE_ X-MS-Office365-Filtering-Correlation-Id: 34686a26-8046-43d2-d88b-08dbea77ed5c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JFZbNWb7bDWCcVYI1Hyk6sbWJ+JHnn+ie7ZG9RwJguFN6Vp8TKxBWX78FypDcSoZlmyPZDzanxz4NJZPRqLg9j7J/y8I4wCD6NhBSnFhWb9b4uk5x5r7BpHV3Tb6CeUK9RqGNCcQM2z+6AD3qPcIUFgrj33u2XTaBTmvKjXuFl0ki6mytMAx8DN6Q4GfprzKdcjjlduPbgNrDOpPArbFSNri3BU32HY4tadzDBlw/UVWbWA5m6gxMRpJ/v+znCDUjzOqh5cr67/mG+KsW3V7XqyuGyj5DuTeskTF91Speqotnf/5fhg1HeczbkqF9w+2QwUqAicbsnwfHuXp7zg5rgqEv24fvvo5lXGjOKhogWJ6hkCncY6mmRDX2quRdCOZYnlQVJSeV760/yvPtE8MOs5q/7xRO2xspF47R0Fiexpvbh6UOyhXN7DMzlCPeQWZwPZNUwMrBCEhrax4zfEygkyDtJODz63iMjNOnoHDu9XiFkmnYRPd5YuTwreo5CfLjU2KsfAqDA8XDWLRGQp0d55J7rHH695t0UPrmUxZmjWL7sDiZ8OkZQiA0cLne+m2 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(376002)(39860400002)(136003)(396003)(366004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(66946007)(66476007)(66556008)(316002)(6916009)(6506007)(36756003)(6512007)(6666004)(2616005)(26005)(107886003)(6486002)(478600001)(38100700002)(83380400001)(86362001)(2906002)(44832011)(5660300002)(4326008)(8936002)(41300700001)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Y+/rgTrnW74J++hiB77y7NiYF6jiOgJrbihW0VXqRbs1cuu+t8jCBxbKqpkHrjNWnkxAJ61p2YzT2Vh/A/d5SLrb3kdqDioIkhg2lhx4z4pQRsEObw+hBLQjMZec5Y0s/t3a9+wTSzTDea7hyLnwPSLRgOF8WAzDcnHNWrgIKoiJET0/mqZhmGcGaXhr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VpCbS4Qkx8Fj5qfaIDopJv+SFN6py9NcGUgawc9QscdObt+2xIy5AKynuFsgUPVFiCfLSQ1ds+z1nkNwBSvGi9A2Z8rb6OaZpfgg941Ja7FDluVlFp+HT3yChGIRKSdr+HDaZjHjcn4+RdxVJLZJ+TB86fYGAmMmtBKkR7tXpjgb7wKypCC9ohzKFdxKAyBZfUGrZ36Fom+pkcczrDuMh4B8j/lc8MJbncuz4SDHcQKuvdPcjAqz7qcpKFLXVBM2LopLRF+d820bfYj4SN/AxDfpEzVP3lZB9kJSMaEn/JqO4EcvHoM4+sExtK6xhM+z7yITIXWuFpFgrb0g9H4FPF105Yjw== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 34686a26-8046-43d2-d88b-08dbea77ed5c X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:55:01.1568 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HxHVZNukUGOL2rv2iDQdatfOrMTjahIr3QM92OyQDmuuL/WNInvdpOBq4tADAm4WB0tMCQnuGzvv6jZc5w5G3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7750 Before adding a new entry in mptcp_userspace_pm_get_local_id(), it's better to check whether this address is already in userspace pm local address list. If it's in the list, no need to add a new entry, just return it's address ID and use this address. Fixes: 8b20137012d9 ("mptcp: read attributes of addr entries managed by userspace PMs") Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index c9dc25fa8540..489bb0e61118 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -136,10 +136,21 @@ int mptcp_userspace_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc) { - struct mptcp_pm_addr_entry new_entry; + struct mptcp_pm_addr_entry *entry = NULL, *e, new_entry; __be16 msk_sport = ((struct inet_sock *) inet_sk((struct sock *)msk))->inet_sport; + spin_lock_bh(&msk->pm.lock); + list_for_each_entry(e, &msk->pm.userspace_pm_local_addr_list, list) { + if (mptcp_addresses_equal(&e->addr, skc, false)) { + entry = e; + break; + } + } + spin_unlock_bh(&msk->pm.lock); + if (entry) + return entry->addr.id; + memset(&new_entry, 0, sizeof(struct mptcp_pm_addr_entry)); new_entry.addr = *skc; new_entry.addr.id = 0; From patchwork Tue Nov 21 09:52:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462714 Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2068.outbound.protection.outlook.com [40.107.105.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C29013C084 for ; Tue, 21 Nov 2023 09:55:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="k7ynx+Xl" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L12fWq9r4a1Ox45P4VzypR4XHwfXe14s2PvnxVP0Cv+t7linMrhiNEd2MlPle+YvBjvCGiwbZNWJu6hpP4RQEQDM2t/RqZyZLLc2YXWAGFxUMp6ZFJcHfU7CN7GbzfS+k+6macpxMqI2T6cd77RjbA6XTlGtKBO8Ip/WKwCTuomWy/2gQOWKwKvayjlzCj9a7IdDDkc5eLCDqIk7+5u026m0ucWFUGKESGecuqnOJUQV8cRjnzg2LzGXFbplNI8wq68Ijg710WR5iSX2gGJSWRnnm+vheB/7tZxa3bHP2prKWLZaSs3jd4yv2jq8tUM3sYIc81QzEu9bnoK6tD/Tww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MR76IQ1dXbU9YiWy2FB6TwbaXjBjpBAZfYIDvebz13Q=; b=a1BtS2PFMumJM763842KQCbkSW9UHErsUloZ/G2okdCO3oaIGiqiWjgD6jf3nBVmZf/TGwlIDMw+qvYEgzJHUW4FiwOVkmpD1HqFLSOn1F0jvLytTO54+xhVBjJx8ajWVhwELEkpSwK2frQaJZdLeNem+G3BH6/VzMhDHmUa5d7o2t7J2KelS4SBGrbvGhnSoym5pJeegDN7iYzDyU5S23CkwQKWpkV8sRW1nOrnj+e02aO99DV3idQ7CcuKnpXhvR744H0nNSGw6s4KfFgTKdnaNFFJg4qQMQAYk7Sg9L6RQz84T/KdVdkiVax0u/SlTFrqtigVQN/CU+ZJ1koyeg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=MR76IQ1dXbU9YiWy2FB6TwbaXjBjpBAZfYIDvebz13Q=; b=k7ynx+XlA/y2a5D/HuAMBe9bFSEiYJnn/IhnX/L2QjoZZh0GTPcb4/5A+GgwA/R8Qea3+LrOoBLd4gK/pijEVyaEh9Wm37gvMoXt/9q0GQ3dSvgBvlm8NW3RpaZTe4xhMSjtLz3HJz5b8XRoIdjs6VukiBZLq1PqKeed5Z1gXp71Ifoi5Dza7tWsmOgrh7QSvPEYaFe56zPVUkTmWNRJHWhuAzpGTIr7WGoxH5LcCPHbg23CedrnTqS3y1MMwm3UogXGV742jA2UGXrMgJBPTwvFV50B3n7czvDfeXAVW4ibGdOAVRGgG6TTCePAI65yQ1MXZnrQ5oMfSaIH4syByg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by AS8PR04MB7750.eurprd04.prod.outlook.com (2603:10a6:20b:2aa::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.17; Tue, 21 Nov 2023 09:55:08 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:55:08 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 15/28] selftests: mptcp: dump after creating id 0 subflow Date: Tue, 21 Nov 2023 17:52:38 +0800 Message-Id: <123f0f31fe8a5bce793f8b893fd34d47884b1ab0.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SG2PR02CA0017.apcprd02.prod.outlook.com (2603:1096:3:17::29) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|AS8PR04MB7750:EE_ X-MS-Office365-Filtering-Correlation-Id: 17291f36-9fab-4332-b78c-08dbea77f18d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2Mc81kg9rp5qCpHk+ArIXcr/Xro0x19zpEHNBjqP+WuycMrDhGpeRA0ppY+ENOKuy5UalfUOfR6U5fnHbg0a6fZEWsDKWtuAMIoGQlf4MLH/EO6NgCdrYnjvcFEBPXlH00WRESQ7WNpNR14OlM6d2r8ZooAh94p8YonLYBMdb3CC7oYVVPAf5ltm2ZUNuJRJfZoGxksF5L+izXHS5wVC3TktwuZH2+OWXDyGhzO9HMuAumxGk7pTnR2lMa2r/SY00UI87qoTixFQtGhuFPvQofdPYWjAPPMoUq6URzUI9oMxmRQsgjLbZ8oVRkJZAhGzYWEBlt5Wu9xMBA5W44n2Oj3HDRLO9CyX9XeOZJKzZzQiqQc5N4RfRvZzNm/XHXp+IXcAg6k1G2OepJp76JAY9YpSmtIGcNVFxqWTMR52qC5s8cGsTv7489umbJC9xy+Zo0ZPUhQHZAki8IpUqL60660ur4s17dkICdXP8qBEUq8ZJn5Pgu4wgJhRjXKhWX/34QYQ8+m0GXd/WToBJ2gsuYxXaYcKo3lm3MRJD7Lio3BK32vuHonMTyubRx7DdIBR X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(376002)(39860400002)(136003)(396003)(366004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(66946007)(66476007)(66556008)(316002)(6916009)(6506007)(36756003)(6512007)(6666004)(2616005)(26005)(107886003)(6486002)(478600001)(38100700002)(86362001)(2906002)(44832011)(4744005)(5660300002)(4326008)(8936002)(41300700001)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ukTCNf765X7jYDy8ifskL2epeJKmuoQl8TsRfJVLdzekVYCIFkkzGBBbeLDBRIAG9wM6NLF/kbYEPkolw0eMwRpmpY2nXCNRWWbq5ygLvJHVq6gblFVTQhhWJlwRjeXaJQ+KuXeL7NWsT8m2yVgd0C9b6TAfKkbwDMiNX/sE36GDp/9v2MwvoeMe1hxpan+Qb4KwaGn3IUlaPqRffMLj8xMKM4/WlO9gEw5+KNcazA80SCBfOBDK36tFxka46DuZ9Nb60p2iCFfxD2ITIJocQ+3nPSbNHaU16/7rMUSI+bIe8oLOPYuHMT8rHfNKE80Wjys4dQT0KsWtANK+QVRIh5cdfBDNC1mKx1HbHp0vBMC9z85pThoz+Ca1hevUuRnTGHBpspn+nK/2KKwcSIIuh6UnpeeCujWXTJ8Q8ftURth60Gdagx5GtoerNULrt9jZgezUQ4P3dx1U6hPFkGkll19Xm1Gco4zFC4HsWP01ACuYgQqaXNlgTHTDm7KurXFhRQsK9awoOqgbBSf13E018iAy2RzcXFMeiVHo+4OYRPmI4IOwGBUQuKHNAAy3mPSw64iHz3akHg7FxtDYEJA89dfdC3uW4a+qWCEwvzaqZJRnaWglsAtg== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 17291f36-9fab-4332-b78c-08dbea77f18d X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:55:08.0932 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2PmCdNNKcln0TFKiaOby8TvYcZxphULty7My8KBhRXepYkbv0jZeszaA9LT/i6VrjO7LzU7mCKVSVmORwhG10w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7750 The output of dump command after creating a ID 0 subflow should be empty. Since ID 0 address doesn't list by dump command. This patch uses mptcp_lib_check() helper to check whether the output is empty in "userspace pm create id 0 subflow" test. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index eae9f84423ee..a269448bb61a 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3455,6 +3455,8 @@ userspace_tests() chk_mptcp_info subflows 0 subflows 0 chk_subflows_total 1 1 userspace_pm_add_sf $ns2 10.0.3.2 0 + mptcp_lib_check "ip netns exec $ns2 ./pm_nl_ctl dump" \ + "" " dump addrs id 0 subflow" chk_join_nr 1 1 1 chk_mptcp_info subflows 1 subflows 1 chk_subflows_total 2 2 From patchwork Tue Nov 21 09:52:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462715 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2058.outbound.protection.outlook.com [40.107.8.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 013A63C090 for ; Tue, 21 Nov 2023 09:55:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="k7BC5FFs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RrbUpryPCC0RwhaOi26N8MVgcJndcSFrCC8x/8F3ys3U7heA931CFuCfzwQekBKTp7NaGRERtiSi9brbLWtrXlW5myYQk+Y2DeGemk1jFH5jD2RIiFXAhLMFh4Utnd70fJUacRfVhLQUVDmddOYIhxhBlPNBJfkyh52qnxwdPUMfUacnjLsOBt4qAgU36WXtUa1rrNwDwL33k2yVlcqFr/MhpphxEBsjYGC9LcbirlhWaDow7DaKzqgXCDl0t96fzFzGeo5lIFWWn66QcJsQEt2ga/rovQxfC4eweUFyCDxn72H8HSMjkAWMDWT0DVJRQ2HZY6IdM6K79wq/oaykXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=WaR7AP/rwQiyk3znsFR72rf1Cpe44kDc4AYDX4mVVww=; b=bbKym6rzl8oqEbxhJ6tTeW1siEDjizy/XqtoUXO+dVsjchaZHnrYgls45Le+TFk48IP0nIMXu9ZCyBIwuJHeh9oGUDtNelFvTV9qBJPKyIcvWk48PxGi7gvpNsHTfGd7goTpG7glRWoovydduc/eBpJkSbpQeuYjXj0xZx6/QkrWE4Sz+navjFbiPqeAdCs0xoQ8w6c5+jjrk1Ia6oUIz9pX2iVzHye6qcrHSYHOFJUrCTZ2JaPi1Swi6xto+IaZCaMX3NwKVZARR8F0G0O8i/Y+okl2VbR5L/OA5UHYbdhp+Dntza1hXIwWCaFEUMIvoo2LSVkQfjeKQtNgl89awA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=WaR7AP/rwQiyk3znsFR72rf1Cpe44kDc4AYDX4mVVww=; b=k7BC5FFstEOvxb9cAoKiwisYBH3d2WKvDHB5CBPNNqkNhsOIAUU2GyIcVpDIe/+VTi4KDWqa77n6k4XE7ukWxQQE2MIr4imCIlPQCVu2XICYJwf50QRtageJOSD/lWGrBIAiigbpdFxGECNHcVCRySwSnnZFIjxA451SXCdyWpKkj43mCrw/Vh0TMoxERvzjqSlHcyC35/zmWK1oPI8I1IVxuexy69S9VHsmLc4URhXZ/WIwA1hoccmNLMMSbVsnc6yKOdQFF+aR01UJWDFAgkITXjnjNsp5vQg6+br6SulXYNEl79FNi4Kd27FsHneEteemtXEZ5qiyDvFl3bgVOQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by AS8PR04MB7750.eurprd04.prod.outlook.com (2603:10a6:20b:2aa::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.17; Tue, 21 Nov 2023 09:55:14 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:55:14 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 16/28] mptcp: make pm_remove_addrs_and_subflows static Date: Tue, 21 Nov 2023 17:52:39 +0800 Message-Id: X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SG2PR02CA0005.apcprd02.prod.outlook.com (2603:1096:3:17::17) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|AS8PR04MB7750:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b7a2797-51f1-46b5-614d-08dbea77f547 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mb9TylbMpRrnTG/hXrSMmelK6l9K0Xzo1Gp6HqJ82XinagqG4rtojHZXb2ymCDlLe/0jkn/IcVqv9ZnfQ8YC3ByhwSe4rVPlTVSQqt0sRSXoGQpVTXlhPRLHRq6gHomnTG9WSdlbZIW+7K9ZXoa82aTFEWVBMoNv0MZqsDrLduZG7Cr30dzwpKukMJHe01245jLKvSQ7YD+LnCDzNMl3Qoiph5l392ANdayoVEHMi9Aq+ejbZ+B6P416f51wZIEIMMKJ3HBiBgU2AcRONPkRUT74Wrvv4yYg5c6A8Yc/ghV/Q20QIY76VG001/Iq0cO5THoWyD/S55JU1josAXsb+8ZHSJXGdJ3pRHLyimuAMzg+hxD92xwCD7sfFp5lkF/QS13yt/Zb2gzZbiGpa8fd6Gb4juH1QnDwSzd0h3qoB5cYdpIDmbH7whwaUrtCA4mQO+kvFstZ3sBEValU+ElIGswNUK2neuak+43zg2lUrv1MicMd2vfwQpsFgpWQFEomtbRj5eNphxJI8hiK8SdgRURrafMNlT2cV5ZuSjw/E+jMAspZHLjcSIojpR9UY/vr X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(376002)(39860400002)(136003)(396003)(366004)(230922051799003)(64100799003)(451199024)(1800799012)(186009)(66946007)(66476007)(66556008)(316002)(6916009)(6506007)(36756003)(6512007)(6666004)(2616005)(26005)(107886003)(6486002)(478600001)(38100700002)(83380400001)(86362001)(2906002)(44832011)(5660300002)(4326008)(8936002)(41300700001)(8676002);DIR:OUT;S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RklKAajmNwH2AeEo7SwQ/QGUthCeLyqFWEPUsc2nmSsOVCVOiRsXPhqRI1+EKpR04jfRen7lvodwzZ9yFdSHzjOs0+SSY7lLEXd/AQWvpP9q8lA9saKMHohy15yIgicJEh/LV0FQ1hbQxM3QEEWBDkVRWTdzm1WbNT61JJWeuNetsiwGTSsWJLW5qTyyZX5dp4qR1x4yERt/XQUCvSiT5MzAbU+GERvkWoLzm1ZKqzZy6jpkPmwNpbe2bjD1mzyhfuMwJDcp28LNEwtk1VBomAOsV1fpEYEHeIRL6G+QiG2OXCkbiA+bMbF97nqsGoatL28fOEcHW8ngDGCFDhs/jEgGbESGUCi07LTyZ+cNlaicQa+eojYgekovxaJtRJhdYlO0wksf2M2jyeN46+9Tz5WuLyQWECJrqJK32As1o4F6B1GIbvk06vp4WmueCt54CZvKwyqJxKlfxos34HT5xc9mhnKGkUIyh0kUKUcMKVD/5lmnfUQ4YbsOe2dP0UkN0a7/eYCQXsAIz7ZCwg4mu6eZdR1br6xgEAb4okM4XUZAPK8lNMiWWdqKNmtSa1gzsOEj0Nj7zAHrAiYp7EbgKz3JlQ== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b7a2797-51f1-46b5-614d-08dbea77f547 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:55:14.1858 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Qm2DCPHwRFkIqqpLF+z8kImkYV2eLjFsnEmnk36ZoFJlz/cPmyWef582yS/VeiJ29lFKpA/4fZZutd1WLmqBzQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7750 mptcp_pm_remove_addrs_and_subflows() is no longer used in pm_userspace.c since the commit 8b1c94da1e48 ("mptcp: only send RM_ADDR in nl_cmd_remove"). So this patch changes it to a static function. Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 4 ++-- net/mptcp/protocol.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index cc4ac206f848..a510c7d56d0e 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1489,8 +1489,8 @@ void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list) } } -void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk, - struct list_head *rm_list) +static void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk, + struct list_head *rm_list) { struct mptcp_rm_list alist = { .nr = 0 }, slist = { .nr = 0 }; struct mptcp_pm_addr_entry *entry; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 0460cb391ede..ec5557697c11 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -941,8 +941,6 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk, int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list); int mptcp_pm_remove_subflow(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list); void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list); -void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk, - struct list_head *rm_list); void mptcp_free_local_addr_list(struct mptcp_sock *msk); From patchwork Tue Nov 21 09:52:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462716 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2045.outbound.protection.outlook.com [40.107.7.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 18C523BB49 for ; Tue, 21 Nov 2023 09:55:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="4/dV4n8z" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WCifD+JyhIKKNS6prGZNNgCOznxfY+eEhpLZGc9d41MnogGCAizBBxwXV6viwPcUwnSJhlC3TI2dOX2Ex1sgYegDep88y98cpK38nSUSdi9oBeA5kwScGrum3ZPywmq6KklZX5kb6TZkHOhEuXvYbhAI4HhG48szvkXJD1/+plreQsxA48PbBKkuEdheP26WAvkI0oK+VUSsgTkUbU0l7ZvpOP580NHIU+YaPsMuCGGi+AbeXiAjdHFVsOKv0KZraF/H+KsS/mcGefPwO9R0DWWSpTc8NuOLGSMf5mWnCs5IK6u9qnKT2Kgqpmoyf4uzhPyt9XadFow7maF1nVXTWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eI70D7SROC7m5ZxU9wMumEUgLdE1slM2yKP+UoKBM0Y=; b=lsaC7h6iqJ4pZVvzBVIZuXJ98ZZ8Mvwg94vFchx/bKMCfVCTwqVXIZWj7+/R6/wpSDVL8Ejy/93I9dPDq9nK3YIp0WIEte0jRibwwrwfA+Nh5hFuompaRPVgYphgGplIG9q68IYfiuJygexan658NRvurqX5+2AOezE1OCn4kDTf2FbFW/N7tBzyps33K2FL8+5oi6kgx6tEWpFVPsGwp9dUeTatVzkUQvxqFWPCk27LM/jfshHuO/ho9z/LHIhSpTXHE8VZNohvB0fRELNeIGHMt3sNH86Fkczlft05AWV/eLbM3NL38b13kSthVpkWtlRcHbyNft0rifNj9tQYWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eI70D7SROC7m5ZxU9wMumEUgLdE1slM2yKP+UoKBM0Y=; b=4/dV4n8zbyzfKX/SR4kUayN1zma1ssHnyUm2fQixIAyRv37jtzXCewP3LhIGaSA3mZzSry3M5OQ2eii334hKxt+Ejb/wAZw8hpuEm2YJT+0eP0+my3goPPbIEwObHwhT/pKE31A1a9isgDZ77a7uaDhYJ7Npc0MxIx/Bg7YIu97UFr3lrbp1RcUOiprTh2Ku2uuzmoXVnF5EYaLExrMnnPjo+HjYHf3gnQXViSPenZGyt2sssZ3ioFV9DgHJmJlAgDjS4P5vcyfZlehRfHIoS4L2rPdMASDtafwyaxU//bli9o3brFHJtXdIUxrjwb9AfrnpDpfkethBBvrAb9b6Uw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by PAXPR04MB9667.eurprd04.prod.outlook.com (2603:10a6:102:242::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.16; Tue, 21 Nov 2023 09:55:20 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:55:20 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 17/28] mptcp: add a prefix for free_local_addr_list Date: Tue, 21 Nov 2023 17:52:40 +0800 Message-Id: X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SG2PR02CA0002.apcprd02.prod.outlook.com (2603:1096:3:17::14) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|PAXPR04MB9667:EE_ X-MS-Office365-Filtering-Correlation-Id: d63f41eb-ce8b-43bb-44f3-08dbea77f91b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LobQvg/pn4ya7uCoTAjYNI0wN0Ai1wduLP8Z8sAtldSudYsJtTD0isVu6uiiBxSzi131TrRKLPyN/R+9+1fhrmDtbNZkjWAfGmTYqdpWhW7P7XGRx7kagGIHVF2Sixx6ReBePWwXDecF53OK1KsQFxch2vp89DDIPrITUuRytZ6P09RMZ+Gp7NhYhRMD8W40sx5tUtKKsnGNAx09ngHLb6VoczVflACEq6JM3XoDP5ocjoLB9DlEBMqQ/Ntial0o3LkOz8O9LB4NQrgTCdp1Q69bDJJR/vXHLgj3FSeWM9j7fQT3vD4iqIKeLfS+aJHHWgCZh/bS1n9uAlOCilcuQU2xsbxUlgSo8txR5uGwnNcKmsDHxpZV2+NvZixAdXfbwCqVtUwjXh8i2f6o0lGaPDRI6Bwq4f8jY1qX996o7G1bwgXVcb4aFJXL13PqpATJCZZr4bwtuKdMy67lcGsc6GcNS1HGYDHJhRId6uhVTNyL3gxg+zpocx0gePRGutry6vIBW7hRdFLsNHjsvXywItfyBxJES2HXpuXUKrXv1mqEc00p30+mghEQ/JvOjbJG X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(346002)(39860400002)(396003)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(83380400001)(6666004)(478600001)(2616005)(6506007)(6486002)(26005)(6916009)(316002)(66946007)(66476007)(66556008)(107886003)(6512007)(38100700002)(8936002)(4326008)(8676002)(44832011)(5660300002)(2906002)(41300700001)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: h51YeoHV3rkWI9sKFu3bab8iy6CSiU8hpBy5eW7C9WaFd3Bfaz3mB+ey3Yd3Ktsyxj6bLXNgs4IRIelL3QL2fAWh1Vv7hSJea+lY7YcsWyWMXsyH2C65nm4izhNQZq6181meeysxf/oSS0qDT/IIMvdAA2jqX/41JfIOoHPQ/0kcuMS1Fm1ce379mrzAmglnRCg2WcqcRzSTE1cwytEWwLEsDQwDsgpTswqjHCnMw9Kg/5MUmNQhxL68CzPfUi9O0ZEfkv/5fK9lYxIcddkh4WRwmeBTV7fmSSSUJUc2AcAblle253OEe5etmRfrO4lMN7SMC6CWtojufW6aPfKwlArpai2ec/HNQ8LVpGk983p/2wRd7VMV1nZ4CRE+o0pCkdbwGmq1b6q+6vSfxqC60sm7bjeHkssdVLaLjqtU8cI2QGkkqCWJ4abKucLocLRNlspm0sdMuiSYOTuzcZQWmtdEOZT+JeJCrF3SPM+Z/QwZAcngZwxto2yqsYwKez9lYOIJbAJaY7IeUMPqGCAsyj7/iQUE7reivy1W+3EtKtkJwFd5MVQgmtmwWEg3XegWblJDrMG1WmvBW7/fechD3JFMV9NWKNiftoSsrf4IlhakQsrr6QKpYiM1zSF12s8QBAKiDmxnG2g66z3WPHe5dq2UL8343i+cPFP8nwIA4zLPxIzi7toj3i7FWCN/x0x/sxHguOZy4ASS3ikyRV2VelRSVrmFiPxO/Io6h4JvnVggN02qDsrR1jRSNUC0sptiHJGnZfb5RmyF0c1WNd693Vqa4B9cq8A6c9KjdC4MfKbNo0ITmK2OxZndBxcx3JyWjPtOwA7cMhxgMeKK3z0m48olCSXOt/i2LDVCCuQroxtLgn1uZPtEtk2Jn/v2PPNN6RBOHxw7V0ARRDNSHULDHa8RQAWbFI+JBNAU2hAGVIvkqNh6OZXwhpxL0Kas8hDYzUhx8p56R+RLa3N0vznzRNVUvAhpw4ZHXxlF2DIhCnl1gJuorV4QhOO8Z2DDW6Fv0Vvh+QioraKxYXS/ADdobCjoIAuFPHSPDerObNHjvQ18gqyg4r7q1h4NxVZZUF0FG07h/xdBv5pM/aFtklWnx3yTdX+vqpHsdL+YZoK+cE7YE7pC69iGK/gFmexrgX+tIIoOujaLbr8oi73sxX+nfnNy+k+2IEN+ga6XQv7wCzSyO53DE9m+kTwyravJNUrzGA6IGpko9SXVZv4Dl+2JeM3DKdGaTo1IAJRLjsGdmrnUwhRazUm2jaGjFznfF82k2NjAqPYi+dZepYIu9MJv/cmuXSK3JVE7/16doaQEU/WqBBqU3v+VUjcU/KtpoVqmFaijHnqrwSUa3YlxqShsmN5UzBRTSDsawrHC2YuCi6PciQjEp99BAHba1ayh5o3qITqG5T8C6YADfMCjmArYs9MReZfhrWtf9Xx4Lq5ugntkgM1Te0ef2jgyHnp0HukAtsIuCW45l+j+2e3urlA3wuyinKB0ygybdYMfH3A2eDOuUf+r95b/ePYZEx/hrZQWFUweh72y7XwIYl74qUm2lp0ME1mjwaUN6axvGenHYjYopvoBCbfFLtVN1fkzv39m88HkgO/SZFdfDO9brnv64A== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: d63f41eb-ce8b-43bb-44f3-08dbea77f91b X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:55:20.6113 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZHwJWiv5ezucnyjjM5AxNq89Uq7pnS3RgEuTwb9jjGI2Z/E5hhNUVmW5IcBhkitW1wufRpu/OM2xuh/WJdTbkw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9667 Same as other functions in pm_userspace.c, this patch renames mptcp_free_local_addr_list() with the userspace pm prefix as mptcp_userspace_pm_free_local_addr_list(). Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 2 +- net/mptcp/protocol.c | 2 +- net/mptcp/protocol.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 489bb0e61118..87cf27dc1d0a 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -7,7 +7,7 @@ #include "protocol.h" #include "mib.h" -void mptcp_free_local_addr_list(struct mptcp_sock *msk) +void mptcp_userspace_pm_free_local_addr_list(struct mptcp_sock *msk) { struct mptcp_pm_addr_entry *entry, *tmp; struct sock *sk = (struct sock *)msk; diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 6956fde61c68..f2f0ce608219 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3321,7 +3321,7 @@ void mptcp_destroy_common(struct mptcp_sock *msk, unsigned int flags) WRITE_ONCE(msk->rmem_fwd_alloc, 0); mptcp_token_destroy(msk); mptcp_pm_free_anno_list(msk); - mptcp_free_local_addr_list(msk); + mptcp_userspace_pm_free_local_addr_list(msk); } static void mptcp_destroy(struct sock *sk) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index ec5557697c11..94126212da8c 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -942,7 +942,7 @@ int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_ int mptcp_pm_remove_subflow(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list); void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list); -void mptcp_free_local_addr_list(struct mptcp_sock *msk); +void mptcp_userspace_pm_free_local_addr_list(struct mptcp_sock *msk); void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk, const struct sock *ssk, gfp_t gfp); From patchwork Tue Nov 21 09:52:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462717 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2050.outbound.protection.outlook.com [40.107.21.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2AB03BB49 for ; Tue, 21 Nov 2023 09:55:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="kFKdaHcE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JTtcpIgUYKbzp2aGQCDzSTeP1GfqTJF4HfKcpuinGIwXJR0aDmGVqU7sgoCJL+F08OyVntWvPnuiUcQn46MCOFiskeg2eSbvoPDZf0DgHujQJgrp4sopBJ8Px2MnWhZ2SQGhKliQTSDk8KXLJ+pxIHPrDYd78t6b1ao1lxVMmKH8PxHoL2CFLrOF2lhiVLoBx1n/r+L3nwJINxD4Otenc7N9DSpa1SsuN5Qq1ImNPcrSxe8iusNOj47wZ4y9g3klEPW8Zv3zzjNgk9eqoNqoCQYPjFEH4c+aUtnLZMzL/Fx/AS4WEjtX2KO/OmW+ArdW+JSYUlAaMG0aAAKQ5nDJzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cyO0dDjGQ8YNpkhOtnfh0sLwo5M8qTyjkoRsOX/2DU0=; b=fndYXqZQdguihvBKPZnbIW2rVqrAZESAx3quZEf+sm48qVSa4y/7UGYAmQD0eY1fpILg65V2oLR3t4mDnkiUSWx5EWxtOZRiWft3juPlzlE0nmsPmalLskh1V0mdaEXIeOp3Q4VFV6rgiCALXLXKj6/7+8UhOj0rscHLZiCOoDgxsBz2XUNoJ/HQJKHJJ50rIECfAoolPwobY9P8jRS6MfgVjdUkz5D1r4Vy1GxE8jeyLgetC8x7cdA8+76RhGszLX5g0fkdlEzd3H1ox8JpvMUKtdZ5oh5ctrzOg9cmrq2g0e+7q2/TTNK65Xp4tCmr7ZMrz08v1XxfVBfUh4Gy2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cyO0dDjGQ8YNpkhOtnfh0sLwo5M8qTyjkoRsOX/2DU0=; b=kFKdaHcEKOka5vD4199GjJU0vU4YRihJbnCtcEZwZZUKaO1QnG0QXBeiEP+GfRT2Z5TRsskvJkOY3mVD/gYIIwNjvukTv25h8bJTmiYmMGGTucfhFPoV2XIXd+Ss35UKdxBo5aMzUhald2KlUZZFQ/NIPZ0kyLKTto0f/5f7tSYPreFmUcm2Y43TAx5TYpz8gtIw2P6F+OvS5lh9JUFSvECl3WdlIpKYHLE5QCziHBB0WTrECRbE6W/WwO/+EUh2liIGiwHaLZaURwSMonnOF+HBiXoH/6pppqs8CplF1KGNE8WrBhgJmqmqQECxxZ3S/LnVHKfKKT0ZJMtsaA3big== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by PAXPR04MB9667.eurprd04.prod.outlook.com (2603:10a6:102:242::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.16; Tue, 21 Nov 2023 09:55:26 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:55:26 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 18/28] mptcp: add mptcp_pm_remove_subflows helper Date: Tue, 21 Nov 2023 17:52:41 +0800 Message-Id: <2fbb194df90383b1c28ac607c51e8be60c1f501a.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SG2PR02CA0021.apcprd02.prod.outlook.com (2603:1096:3:17::33) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|PAXPR04MB9667:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e130209-4829-4449-a0ac-08dbea77fcc6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kWd4MdUYxcOVhnEv6pwOuZNnEvoWoJaBTmP2k+a6UN57paUpyCQRr1H3TGogxV9COHJZ74znE81lyzpeygHAj93SbADR7NNSldIxfru1FirLM7KwMOA1TIH+GYakVG7vDmiPsNIdt3OVjGDoscSmRrC0d01iSIbMZNzEldIsFA4fk0KE8kn/ijJVl+w6HNx4wrN+/GdHJZZp4Bct2yvKsfNcUDzo02SnSA1G9qbM+z2kxBg0Y4KNTzmyCpDm2sKkjZ8VFjpVrczVyFqB/akLECi9TwTqmTh7XHuZic+ohCPWT9irfeI/gOocscUkPwA6muGzKmNRNHO39T7Rj/YLazvGuSz5DYNMfflAliOIYe7uBLrrsIdJ/GQx0+yhj8vF8cwVnrQuvwYPMs1tolk5A7MQaKVHe/3pIUuLnx/3sYkH++M763+Yzkzoh7KuQbtxcCr7sku6vgoVQ8SE7PKmGefLZoTxCGhoyj+F6UZck+L2Ai6CwjVQ2pEu/9p/ofhDqL8CIJV0H1sHou2Gymo8hK1xU+k37kOWsRh/UK3hsaEBo8DIAddHZTkoAQC4SIvE X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(346002)(39860400002)(396003)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(6666004)(478600001)(2616005)(6506007)(6486002)(26005)(6916009)(316002)(66946007)(66476007)(66556008)(107886003)(6512007)(38100700002)(8936002)(4326008)(8676002)(44832011)(5660300002)(2906002)(41300700001)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PvT+FqjMNegrIApSydWPNpMNUrQdpqd3wnBDYykUm8eQjLViKWOil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ndCYfJA1H/dmbv4Tsg11yJqzIsUABlfKAQAmLhGHTxoHXM4acvSg+YlNzP3ivlf6lWm1CShbktIfZtzyeaLwvUPOYeLE6xdjZ9mWgY9ynLSgr8v8KRzUFZXLIeq52OPk3EK4zfII2jsKZCJt24FlPsST86E/1+HZkMVUaTzmeO2lWMQR1bRyFpdZWRCz9CP2tbarRzFw62AardcCEnRR1sOZBTbVziZHiS6YbHwO47btQ0TTTCkbRiFvT8i6O3bXO09O4YSyQ/XEqEcUzTXXbCacAgH3ks+pm1qyZ3ZM1wJRabo9UuRCnLiaiSuvY32ZfB3mefOk/nBGF6QsYzUPfwlA8lkZCk+HIAzAbx9pbF0PV0/hOWn9LWu2gINU5qpx3E6KwHLlDIw2k+zrLPFmG1mnuiLMNHIIVYPIWJN8VZGdhHroFe0sTLr45hYL92nSmtGJoVZ6dWhj91vb1I2PW4JwpEMT8DWQ== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e130209-4829-4449-a0ac-08dbea77fcc6 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:55:26.7795 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ImjnCeAHZrSks85DAAcQbGdwSG4Bi0OaXDaXaSEBS7Qz245ryCCVmEDP13c+w9DROUN8Tz39cyQwKG+RzOUxew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9667 Similar to mptcp_pm_remove_addrs(), this patch adds a new helper mptcp_pm_remove_subflows() to remove subflows related to addresses in the rm_list. Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 15 +++++++++++++++ net/mptcp/protocol.h | 1 + 2 files changed, 16 insertions(+) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index a510c7d56d0e..a4dc2bc8fb55 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1489,6 +1489,21 @@ void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list) } } +void mptcp_pm_remove_subflows(struct mptcp_sock *msk, struct list_head *rm_list) +{ + struct mptcp_rm_list slist = { .nr = 0 }; + struct mptcp_pm_addr_entry *entry; + + list_for_each_entry(entry, rm_list, list) { + if (lookup_subflow_by_saddr(&msk->conn_list, &entry->addr) && + slist.nr < MPTCP_RM_IDS_MAX) + slist.ids[slist.nr++] = entry->addr.id; + } + + if (slist.nr) + mptcp_pm_remove_subflow(msk, &slist); +} + static void mptcp_pm_remove_addrs_and_subflows(struct mptcp_sock *msk, struct list_head *rm_list) { diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 94126212da8c..efb24c05a7e2 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -941,6 +941,7 @@ int mptcp_pm_announce_addr(struct mptcp_sock *msk, int mptcp_pm_remove_addr(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list); int mptcp_pm_remove_subflow(struct mptcp_sock *msk, const struct mptcp_rm_list *rm_list); void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list); +void mptcp_pm_remove_subflows(struct mptcp_sock *msk, struct list_head *rm_list); void mptcp_userspace_pm_free_local_addr_list(struct mptcp_sock *msk); From patchwork Tue Nov 21 09:52:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462718 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2052.outbound.protection.outlook.com [40.107.21.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC8913C090 for ; Tue, 21 Nov 2023 09:55:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="Gz3hrVqN" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZL1ZFFcl8iyRxhgVHDk3BPltaccZ3aaExDE0Q+ZiZHXm+u1DPmDEpm0r9SJIURK54hvMX0cZIT9wZmGbpLAMw4xd790y+RsbB5lisEUdMJc2ipEHm1hEytQJCERfMnDlL05ULytS6W4nFIhcUtNRsapcYr4xyeb/OifAM2voEHCc00VUGVC1juhJC31hGGEx1FzVV2u3P7vYmoyVoAwzgK0B9pT/GfZPheerZnPvvzugCD6dGW2ksYSCL+9MjQYfH2HNEoUCwo8PzTh5Oz9pGWMF4IL2MgDVxu0blxX042ReNOgmQNsebWNYtQDdBdqS6gZwut6CDyksAImWUXIHmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LFHe7S+Hy0deBz2+JZd2T4avlxaVx0U1hIAvevaw8cs=; b=C7TNAZzFzbMEZGWNjmotYj1VSXPXjfGTOh6Q9LO+PjvCiuIIEmrxcuhBkOlbvlNimnAc4ZHeuYSJbAm3all9+P380NEneeEhvmSwioDgbhg6HrfZGNaF52ioDAFWCh29iMZ2qdHHwPlKrQNn8798BOOJVtOvCce7CyeHwYVeoUCYNOVUL5XbTRLwdT4LOWBC3ygjemyzNAll0Qk/qCqIPxjVyxM4e0SSdPs8uX6WpTNv1gcC/kA9RK9GHIpYxLwZJGJNIKHRyFTyM+rex8sieZGSWbtEygwB6tzlFXjlVU1l5crmzAEo9q3U5Vyhbx63kcXcnEToRZAL7YI8UtXiWg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LFHe7S+Hy0deBz2+JZd2T4avlxaVx0U1hIAvevaw8cs=; b=Gz3hrVqNyiFFrKy+HphYgGKhjTHLwg89J3fd5Z3+PxVm9FopIT5eDPec8YpXz4PsB+b0utkNGNbqCd+eJYFSZ8PZC4UmAbXQ6PR6YcCC2rGmi0ewdqpqY5HPQqiIEe+HDaK7+lJmFCpIQDVJJFnOrzEMQrVk821F9Z6HVUJfOwgrS1Y/b3NY3MzimwxOzJgY3tnHDoOkPCRTJY6QSjr6bHJiUabRHd7pPp5p9wxy+gYBKHScZApuJu3KqgYtZGL2rXAh1V3R/51HFw93vmjoM2b+k78DrSjCPQVH23subwHt8d4UMkWouBEi2UDNdwyWhxSUoWHKKXeeCpM66IiijA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by PAXPR04MB9667.eurprd04.prod.outlook.com (2603:10a6:102:242::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.16; Tue, 21 Nov 2023 09:55:34 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:55:34 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 19/28] mptcp: rm addrs and subflows before free local list Date: Tue, 21 Nov 2023 17:52:42 +0800 Message-Id: <8b2e711211e64562cb3492a563489fb6e128e304.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: TYCP286CA0012.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:26c::16) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|PAXPR04MB9667:EE_ X-MS-Office365-Filtering-Correlation-Id: c561a720-9026-4291-f09a-08dbea780169 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r0REWCeYgdgUtPsTJb2gTIuasL1fapi4aMZu0y4zT6Vvzsir0P2gxhY8sjxpIdunTrmtWRU0xjP225ykSanjTwq64iI5BviyrfhQCGxtq3IiPTL1Rx+6dfejMwyXCa7u8lJGrC9SoumNi7V20sTdyIhr4FI1gpr4ISIzcDHjoLCpgEYXTZsx+qo+Gx9xs0DBBebNTx2X6wk0N9HsJcLCyS1aw+2gbwQQOXTMvQjDkO2OXj9PpfhFJpP6eATwQO/oe8i9IMaYSAIDGzdq1NRXWiKWbQzTYPQl7jD3b6UVKWI/Z5pQoDTLZBrbsBeGKprg62a8CdBPGSLQz3hpFQgXBF4w53PWsD3X4oFQSSD/C7gVugF9hohCR2wabzr2HC6Q+qeigKDECrYYPPjvupCzx4R5YGIE7hha4dlvt/fcYN0At5OIYRgztVsIQP6JoZoQebGWZxAgEQiAcduZEHBeUVTUT9ZONimVJKHQl0mztPgeik1Al3WHTOgq1/qwGlHQ90flH94DaGamFR/7xFcjJm74kjvJrnavsfzWZ6lRZYIgVHoATC0qTUXwDfAEm5N8 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(346002)(39860400002)(396003)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(83380400001)(6666004)(478600001)(2616005)(6506007)(6486002)(26005)(6916009)(316002)(66946007)(66476007)(66556008)(107886003)(6512007)(38100700002)(8936002)(4326008)(8676002)(44832011)(5660300002)(2906002)(41300700001)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JCKbw62MEsS/C/sjRHHC1YCjEMXoGzcG8DGPvkTW+QGPfeQeO/UoSWtKigtF60h4ybmOSWhgjdroy0enSw0UUC4Oz28ExF9KYcpW4O/J6sazak3t1Fjzy+x7CewESHHQuNj389r48uKb/0p0nLCH48RsCKBnm3qtYzDEVoESYIkCLbExoFRhZSuB9ibfPLMyyQONNHyv84ejm6rrUyjPlvi9aAUBfCoQsxQDg1t0N4zS3r4cboPu7XxnjQnykFmfO32zHBxMSpXLCR01zN+7QUqPuD9DxFgcnPbhFbbBi29Amue5RORGIAYF1NiLt2U7i5GARuGqQY7zo+QkiMgiBn7e1uCu759kZJvEDEnsE5LpCq7jCcfnQIiaLsYCTmrV8pAGag1o76IQfh3LAmI+jk4ShTCBBnZzxFIXU2FuQeLBhMGohBRXW8MrrW1pqZO+iK7IWIy/A3npt6CeMZmS4JimdUi6e07EVkigm0WPqw3APrOLyc1uWDWG3xl4mMr7CrjQpON0GTXAcUFQx3x6za/ejKfu5r+QMKzdnZERQyHxF8jKlFgXtGrIPkEPslneAh09hP0yLSCKi7mZPICrztpEIZ5bh2Zyj3Y8R7vsBz7mL1Oa3YTI7FKGtmhlXvvncRWe7jFso3S1j/U32Kd14WObaE5sTeAX89yR+d1wSnlpzKFBwmhGKKXbUTMa3okahtVIPjaN0gpkZI3VRYIKmwZQre6aVNuhMZHFFmyGKbAs6j5WlnGyjYNozzCHVoLwqqn1z4twdGPUd1aKNgdjCsIBq+0yRCPHRUkz2g9NWhqR6XoWTSuDIDkF5x6lmtaBfYkvPBfu4cjTaUv3CGqo//USYait7kJ6dSlW+bPpglNdv4fChNABpwOoA9EwQz1kPvtbUvdl9R3PT91bigmzUuRAwxyj6KLk2rtum2eOfX/bQq95bCeu1bFvHvFE24QAv5NfQBGevEFvkIZzTf7wEq7n8jeJP4IMwZsK2gL2FL0OhfesC9Ii+fJa/3RTGOfLV2kcpWF/EcYYlWju6C/YOXCQ+JoiubQKabnO5NPBYgNh2ZBngZ5LF3t4xWHxq3jVGVALm45YPArwfrpB54znWli2OMBaU2V2fE/aP48awinWSB1rnD5N12X6P8zttknFBQ4FZ1oq3QAr+CmDVP0W/SXxzLiA8WZ5wDDoqgBMS8krctgBFnE4b7Bjjb8zKUlkvlvZayhUYG5VFI3gmdh7lIZenNY4j1NINuRBE1YfMDR9YcEwy1z3avE5ubxBvUJfcP64QCiM+Hkm732wYUIoFNIXUeL11IireLNZWNtw4vIL/cptCC8UyF//RdiLfZZZZqV5rIUEpU1T3ljVWTC2ezmh5qbCz1NTlvVNyvdmbei84rlSbUnNITGGcIjukuZvPqCMwWjzZVyHf6PqoDrIEUE9IQivilTQos5mIfKZfC06n01fwJpWA28AAyyXpmo7Uro5Y7s8FcwVqzrqqYk5OPZXFY8Ze7QtVBN3AwdgZxQLDjHDAsJ2LUkWbe1xHb3iIdC3s9wLPw/2k61/gwd8e5PuwSWrGsAim8fiTNOU6gd/Xv46k17EDfii0dmY7dTT+wSZhFpgeFfhLVKNcJTtPQ== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: c561a720-9026-4291-f09a-08dbea780169 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:55:34.8629 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YIp3eqZS02fmiu6eGf+X7BXIJY3fJ+gV4VysRybf46t1y8Ke7F/foJjMzyoDS8ETvwiK4b9c0z6cUezxvcIP1Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9667 Before freeing addresses in userspace_pm_local_addr_list(), RM_ADDRs for the addresses should be sent and the subflows established with these addresses should be deleted. This patch invokes mptcp_pm_remove_addrs() and mptcp_pm_remove_subflows() in mptcp_userspace_pm_free_local_addr_list() to remove the related addresses and subflows. Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 87cf27dc1d0a..674262face65 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -20,6 +20,9 @@ void mptcp_userspace_pm_free_local_addr_list(struct mptcp_sock *msk) list_splice_init(&msk->pm.userspace_pm_local_addr_list, &free_list); spin_unlock_bh(&msk->pm.lock); + mptcp_pm_remove_addrs(msk, &free_list); + mptcp_pm_remove_subflows(msk, &free_list); + list_for_each_entry_safe(entry, tmp, &free_list, list) { sock_kfree_s(sk, entry, sizeof(*entry)); } From patchwork Tue Nov 21 09:52:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462719 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2051.outbound.protection.outlook.com [40.107.21.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5812BC8C0 for ; Tue, 21 Nov 2023 09:55:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="Dpk+16n9" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cvio3ZMclqqWuiaIhK8C7u1IBpRmrzGtIPv0VxuX1GrpQAJp0eq1PKt/n2X5etd2+Bv1twx13JFZGq682cw9M+g2Wy5SpAsfSTe6h5p4Vy59RWYBQR8GjJiL/ev6c3IQQQepdKsrpVcPi7iwiMQ+sSUa6cxPGO5oGev+d8CJu3Thv54F6pN4PrDQoYSahLvFRANbAtW0teV4Qs584DAlyGbO3PlmEhgBRmS5R+H+hufpWCyhts1Sqp8TIeEi1Ld8FQhC7oe8NPvSOB3AGsgHSOeN9V4QG57dlrmbG27Q/3PbBtRJ/HsZ2zX5YnBjfjqb0nO22277ejVA146Svs2MsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sf5bQUbh5eEFZga+1M+nElTrKfqhdkRszfzsQuNXB3c=; b=IpDmeFoRLdljOxMJEHFxQiAOOleZPs0Fq6UMAXW9nTs8psDUxm6Rvbsh6WwmkXOz4rfZhemXzfrp2IXP/rj3RuAfX/4kMJbysN2X2aTX+YYI+RGUuwJ+7NIuGbjHPWFX9DVKemw9U0W7Mq+kKXZVz2LZIKTJhanvb9FluPcqrKuvLImkPBH0NUIRTgmhPGfTcwe9cN3LtKrI6PTFPmHYzHsj75OQtZFYUO2E1kqG3LL13PCrIB7Fk1WrwanfnEw1VLiQ95iHTrU9kRidBm35QXMZKbrw0gXsL4p0EcI7/J6v9jd62GGEmFpX1IDQV8amMM5vJQILdqnBMd49ME+M4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sf5bQUbh5eEFZga+1M+nElTrKfqhdkRszfzsQuNXB3c=; b=Dpk+16n9tgxVR7TQnx49gC3CrLmzAFOyTcoPvkUVdj9TU0GOB3OlfpDXEE7abL6NGxFdRUV3KUProwo+Q9rms3ZmV2XNl6eU57MqCAY2FyI/cwySGxpj3idk3KiFtdkcDNae28EZtoNsN4CfKzhNpfckDZbBrcYs69DfLNEHjtTZvdIFn5IcEsCILpp/CUIhpGESJ5P5DVO9ikhYNN9//hnE/IjrNoa7NnZnUJURx4vDPlFCpLuxxWyAiEEfsG7bI9QgKWr3PL23FMYB71RXxnU21DILX7kK9nsapRWxQJupNCMPbUQbqepYKMA5/+OU0DuvKq4sDpW5NE9D0pcFFg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by PAXPR04MB9667.eurprd04.prod.outlook.com (2603:10a6:102:242::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.16; Tue, 21 Nov 2023 09:55:43 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:55:43 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 20/28] mptcp: flush userspace pm addrs list Date: Tue, 21 Nov 2023 17:52:43 +0800 Message-Id: X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: TYCP286CA0008.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:26c::15) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|PAXPR04MB9667:EE_ X-MS-Office365-Filtering-Correlation-Id: 5790789d-ba4b-4a68-9c29-08dbea78068b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NWn6BUOGZWFoqIH7odyHpp3btCSDUxchBi2zNAyUYEi5xBMT8jEHuiMCi9EaxkjMcmb6T3PZh+2mXMmlygK80+5FERd47TFP7u756pGJPLn1lWoi6eGgv8teuj9AX01sStayve4f9q5SzNbFfv17GuVO4S78CIc7nYzuEbaO2lMrnIyS7DaD87xRIBVvpiuEAWHNmzrvEOOIEnsimw8XYpSf5pXRJU6JzuuHis5F8zH+NcSKC/ktPYHBk+vKTDIYns7Ur1NcBNNT8G7hGTeYhv16EnZ6TlGyemkUFr1QV9w8DSXmeS7cOF+sIfGM02i5Cpo3QJlOV1yNFGPMX7f980yJgUwWJ/0/RPbOGNFsEVTYNd1K/BDnboMUm1aknDqYNomINw/5gpjLa9zYqZsm+O11ILBKbeJZzsL2P5LytYgfLrcDeLBHYWnUAxjazLabkaN6Rgmzygs7lMcd+2pbYiI9sM5edVTEl256uaYRbAj7VH9iomsiHD8mPMf7W5Zgpv8cN25Oyh2nr8L1OZTeyvufXOgwaOrMiLPbJvNDBFdzNEpSKYW7sRBDqijrfHHc X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(346002)(39860400002)(396003)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(83380400001)(478600001)(2616005)(6506007)(6486002)(26005)(6916009)(316002)(66946007)(66476007)(66556008)(107886003)(6512007)(38100700002)(8936002)(4326008)(8676002)(44832011)(5660300002)(2906002)(41300700001)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: k+j5o4MeQ/bwP5tojGKE1Fj6E4/9OlYvIu4lJObMM1eUggiqgRlgHKsDZ7QNKyfqAKxyfyv0IZ+lMiP3rVZBMKywiJJmLSzzDE49E8QxdZw5XjuDl//NQ98ninl5nCyRMbLmewaFe+P8KOrVSBa3bHcG8tjH+0+PeakaQ2xpvA5NW7W/Wj/x7lRTh2sFpQmLyOCDEc9x/JXZ42w90KR+QnEtgw0xzzkn/Lc4nFxvBs69TBTX8+4FWzMkAvTWRSW9LeF6e+2DWWU0csLhjRTtoQsOmbl0kRd7DxsNajShHYAce87overJnCyKIEPMgMgestY8Ft5UAR+0qrVCWnJibS0SAbbcQp5hL4jkVw89tqje1B2hXnn5/yNWZoEjPoN/xBa0BVTYzzLGtqM0pBBBOF9+F6dkQ2eilGnf2KE5WC4iifSMJ5ZgyHO5MEZt4fQJahlQwX0ucEvoqvgl83kX44F65Z4gGAOyVZxvj//arNdsVwazrpN+qFCh7XhGpRE65qXLW6QtlvgOuZ8UWhpTWyhuLKDmeKOjuHUQz+0i0VVQpqMbZVok3pMBoz9CeGRepvrPkbuhQ19yTxXNe9aorQAP4V4lsoH/KNe+s7dtxKMgRbW3Yui58qTSm/LIiU6r6dD5IgSVNaItp/MM9vK/8cq1S0wd+XOYWZLQBaefLLjJ7c9PR/wTIesbmCFFA+fny3xfAZqxg6hD0r7firajjjYMAi1YfuJ/mi5Xv8vLZ8EBbGYfb8rjH3hakge2OGMSLb/uhZlrykCJIPThgokViPepyFvpvRvB/45hrICiQ6dOrgYkMd6uyAhA/v7W65RtJALjA2gxQVWqjHBaO4cVxRX/lKe0zXY4Fa6Z02ByrLrBEPLRbIZDqp8wX9l7atkONU+wuqfFn3w38BcOByIjIJAkBUUakPp/lYA/4/tnxGxqggYq1HTKW7KhRBSWpnCn73Coul3JQ29jYAgCG4GNar7hk/+xKzPqHjZsI7Fp1GC+OWLjLA+uIPSQV0WRIyo2XeS8kFNMocqtHdYq8V+baIAHWLTfNPPao/carNCoF+twcZHX33PPB0gshVmy/E2ixPfONgMNeZDPOa1oIlvbB566IBx/FLRbkIfxbG5R4WV2r3ostlMi62jPAzVR8gDSpxLhMTr4vkRfzggKagYWc5J0jbpzzJGvgMJSp/5nTTPuFvyMuusQ2rZrxlorwZ2m0Hg59JTGjaWSy6JZvsLGDX2klPFtUIsbTCYhOADjLEzl1wZKm8GtjtEXURI6zSQubHnHrM1PzJ1GSGcnE5p6PhEHR8lcyGDQy9UsSij87yZWTkqzIprhgPUpKmdePoEKKCSCjo3WOR47z0hbeiFh0jleaK+XkbD0RMX+R7r/JMVYzK1Etd2EG9VvUvv3mgroEEQouTedUBRNB+vGqC20+fB/veqvqY/TI6863fRlyJWgcJu+c/+u7mdko98T2wKIRkypEs+1YFFe6SN+5KcJ9z67B3wA9CSJV6oTwjEWqDa5jmhoB6D1hyPEkjkEOAfBAdLqO17xznpK/Ob1FcDuHxK7W97uRDU/lnXsFsS5g6F7LnCwJ/WR37emlqi/gJoCp2670olBu4v3EVLNLAXDvg== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5790789d-ba4b-4a68-9c29-08dbea78068b X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:55:43.5147 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bI13iplwIHX6LBZYDDaepHIsjUzK0hL1efB3s8wn7Ef9wYPZhz6x5bpsBg7lAC3t8O6bD3JIrZa+OdrzEWebIw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9667 This patch adds a new function mptcp_userspace_pm_flush_addrs_list() to free the userspace local addresses list. Invoke it when flushing addresses from netlink commands. Signed-off-by: Geliang Tang --- net/mptcp/pm_netlink.c | 2 ++ net/mptcp/pm_userspace.c | 23 +++++++++++++++++++++++ net/mptcp/protocol.h | 1 + 3 files changed, 26 insertions(+) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index a4dc2bc8fb55..6bc1a6b5b4f0 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -1587,6 +1587,8 @@ int mptcp_pm_nl_flush_addrs_doit(struct sk_buff *skb, struct genl_info *info) mptcp_nl_remove_addrs_list(sock_net(skb->sk), &free_list); synchronize_rcu(); __flush_addrs(&free_list); + + mptcp_userspace_pm_flush_addrs_list(sock_net(skb->sk)); return 0; } diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 674262face65..8494d6df866a 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -597,3 +597,26 @@ __userspace_pm_lookup_addr_by_id(struct net *net, unsigned int id) return entry; } + +void mptcp_userspace_pm_flush_addrs_list(struct net *net) +{ + long s_slot = 0, s_num = 0; + struct mptcp_sock *msk; + + while ((msk = mptcp_token_iter_next(net, &s_slot, &s_num)) != NULL) { + struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); + struct sock *sk = (struct sock *)msk; + + if (mptcp_pm_is_userspace(msk)) { + lock_sock(sk); + spin_lock_bh(&pernet->lock); + bitmap_zero(pernet->id_bitmap, MPTCP_PM_MAX_ADDR_ID + 1); + spin_unlock_bh(&pernet->lock); + mptcp_userspace_pm_free_local_addr_list(msk); + release_sock(sk); + } + + sock_put(sk); + cond_resched(); + } +} diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index efb24c05a7e2..7441e3b9443d 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -944,6 +944,7 @@ void mptcp_pm_remove_addrs(struct mptcp_sock *msk, struct list_head *rm_list); void mptcp_pm_remove_subflows(struct mptcp_sock *msk, struct list_head *rm_list); void mptcp_userspace_pm_free_local_addr_list(struct mptcp_sock *msk); +void mptcp_userspace_pm_flush_addrs_list(struct net *net); void mptcp_event(enum mptcp_event_type type, const struct mptcp_sock *msk, const struct sock *ssk, gfp_t gfp); From patchwork Tue Nov 21 09:52:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462720 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2086.outbound.protection.outlook.com [40.107.104.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 080B13C094 for ; Tue, 21 Nov 2023 09:55:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="YlL2E06O" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DJUm2W1twA9navlL3a4F73eYF7XjykdMEcy10b1a928QFPT35Pz/7dg7sAw4+xoYwKScM6lblNLwT8KUIWhD2fyV+CLVxuCGmm1IYzPMu2MozYkAiQkAtAY7XmIumSpe1P/q4Mgp6vg499vWLRfC5oXHp0Vm8ZfA2Rq1l7vc4PbUtw4EdmgYTOL3FS/v8Oup1gX3gTnxwjZBI9rrw+mq9Ad83t3ay33Db6Fhuj6kaw9+Dzp5bXOEwq8bC5G497zLOzkqjM/Sz57mD1vgRKcnxxRMsk/esWkGGxwdFW6HQ5guqAtJXZcV5z5Lj38wXISwnBVtwXF2QNjacr8M6Tm25A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qN9PrKZSypFBQZEMwr8q1OvVi/SJ3683OBTM3nsBvIs=; b=SiWz5y61K8JITRfHMMPNOyFZOgzyZbyuXvLizvPpblp7Ey91MUhgerp3HZLAeVW1W6qIKvXLt6OEAJ66wrHlfCVG+YQOzAjj+n3g6WMLNRvjdeMrWX0Wxe8BRqF/p+vBajY0df0jvHbYGEXJHliBF/50WKBYHYxUqRJr6olojtrHa0o3P3FPMsvUtipi5spPZchPbSzrrLPMptqw2n6Lqj5AKUgPEpIPFde/AUKfMdvmW+nq5YC6kp3CGeRb37GDvf0Msg1+vBbP+jBpjDgELme5tsQDzifJvU9wHio7bfqzhro1UJfnbKU/kEd5SEn7CITw9zDSg5L/tJvFGcj2+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qN9PrKZSypFBQZEMwr8q1OvVi/SJ3683OBTM3nsBvIs=; b=YlL2E06O+nKh0AQv8C1NVy15Hejwjir0xzCBTuggcxySZFDdAxFJE91AVvsuHCO70cdiqOaAiPU19fvv5IYxuCYpr3VN5IjzsBp5NAQjPGNFTr72mDigEwnf15Jr9Lzpp2Rlp2GfoPYyZdTS0vEum+zBjroMAMjW/9jn71l2aNbctOoCXy0DmecZnbrDCi7VUCACFAKjPzLKww/se+z5nI8Uts/+6G1nLtzKy93XPvH32e47p8aBp52h+ZTShzrVCUnjJMTHB6/7WAWHHeOSMb4UqNAfGAHxE2l2RVo3UpQlrdV7Z1msD3V9uTHU1t6Mtn/PkkvJbicQRrm/jK/Rvw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by AM9PR04MB7620.eurprd04.prod.outlook.com (2603:10a6:20b:2d9::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.17; Tue, 21 Nov 2023 09:55:50 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:55:50 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 21/28] selftests: mptcp: flush userspace addrs list Date: Tue, 21 Nov 2023 17:52:44 +0800 Message-Id: <8844625ec057447cd97786a5dcdc9f1ddff1734d.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SI1PR02CA0014.apcprd02.prod.outlook.com (2603:1096:4:1f7::9) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|AM9PR04MB7620:EE_ X-MS-Office365-Filtering-Correlation-Id: a3803bb5-e307-4b4a-07f8-08dbea780a88 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n93yRGxOsdRtp4rZ+ix9/d820Z3zAvyM8HWhZdEL4cbuxMu/UgHYw0QjVbgNILUmTPALGBlZfrPhTNFTcNKdbxjfL2YCaDHhdqmd7nBHWhpZeMbXWWT+P4QKQJlUOpHaxpIxcg2Y2HxJXnlu/edBeVbTUMyHMgvWr8LDChGikMXORTiupIpM9MYvfWaBLpliHscvPj9OqeaMo8VBYouDm8XYm7qWbTmWaalwsfDvd9uglIc0WElTaQJFBuyg3mWDQcwxkxH1guCmtN1Q2IMLKYCwcLhmYsXHF5RUMnmnh3p4N2u0gUSOspD33i43+03K06WfZKX3agFaG069k3lWo38tAmySxVKEb4NqSfz9QugfEgkNUpSeOA57ExdCrVc4Q5QYl66ILxdrVBfQYUdL3IRNAhcTTtxI6cVDtE8hhuC9btwwpIpecJH9MqfkGo5FnFrVINkDn+I8EWXq8Rs+sFelGUucHIyAagCVuGED/r77Nv8qkfnmYZQFMLkSap3SySK1L9NbtBml3MSXeZiFsk6MGIc/YbIrIiO4JeZxYHJzKM4+MNA3jeNGtwhD0Exz X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(39860400002)(376002)(346002)(136003)(366004)(230922051799003)(1800799012)(186009)(451199024)(64100799003)(5660300002)(44832011)(2906002)(41300700001)(4326008)(8936002)(8676002)(66946007)(316002)(6916009)(66556008)(66476007)(86362001)(26005)(6486002)(107886003)(478600001)(6512007)(6666004)(6506007)(36756003)(2616005)(83380400001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: M6Hs4q339yaQh6V5EYqDYk+e97N63zUOXZ7U4ayzqGGaXGPyf2tiENqg7/I3k9MR1D56cxBBOD935s+qJSCf4gjXIj5bO7Q49wtvFXbQXrq4mYj0U5mks/C/XRMeZT/p3QdJ/y3g9EIxVqJrG2/UFdvuq7ooJVZjNtnjo/x9FF8sYV7yyT3QC8VmINIx7rizLeB8k6d+XmcQ0qLEZv2T4f2LK5sBdQ+Hw8Zj0wOE8Bws7yLvd+WItwu5KcttbKxlwTv9xuKZvqrkbVZ/HpzzvGbgsfHKwJ801+nhJdRn0C83sdLBRmUoMhLiT/UHa93JuK9IRdglXRXvPglXRRpyXybyFTH7PkzNTtRzDg4w3P8XkmZFu/Qb0Kcjb9nkzIw3/n+g2js/ueCEJ9sKTZCXBV6YDb0O8cfky8tEajfuyrCbeUCGt0MqFZ7YsNZyySDAMZ24tUHXvghf2pHEVn0rs98zVxxHGOAbTtSLetrJL4xoFQy1XZDIf141r49Yjs8+26/BB6u13RBtot0SqzEv5NsraYtB3teyvqxsM6O/8GvNntjINsJhglHrpzIbqGTMntNdQYZAcuuN5C/bO26HbKXWlY2JfElVGZ1hPNovBrFZQiBetWu76Z39vdt1BfTLFifO2jxzBNcLy2anTItZV27NNlzc53TCwbuRK7t72vSUamBQV9qotk3XVdULKCvlzWkBZywJD70PUAkdOCFXzk2DInY6fLXEKr1zl1aWjWqD0GursnAe2VPouIk8vbrQobNjJ183ffAISt7fx2XWW8znNVCvr6y80/RsKbUPkj98p+hSYgztyePRwtiak8fxm09VDEk7JvyhRNYM1dI5FVqGQMsEBSt5X4/TlXov5/eN2bqmhOihtIfWwzRWnU1WO60ZRtRQdpiL6um0uh47+N8MGRmQwJurK6n6BTLMB7HW5c8mjAB618YmzlQmzogaWgUFHKVZnR0JMp/i9p/6ckR6FDuLAA7UAoSGNUgsnSkD34RryDhNdD314J2QBBPUymNiYDOIhioj49GYmDZYBxmhpV18x0IJPepub9XVhA/ylypXdZiQjkgn9T6hd0SN6hW+l2K7VT++VMK8K/aD5MXoARQRr9aux9rDf0oXGa7D2LvNhBmmGSKJvNnwxfRpXN5rTLH3u5VFBgUyFOwXtKNzNydvJebkCGvAmRwOykLsLt4gKGIldMXgcn2oEvDzunuRrsVYvYI6AZLrEbKYqzg87PNe4f8viUDiLYBOHcZb9QGgISoRjCznbStHd7ouqxNjVyhTERDZt995mYrf6qBySjTF9i+pyyAqGB+OIof9bBn4WCsO2iUvCO7PFCP0JJXMR6ycNSREOEECCFgsr7gCYC4BdFKwffsWjmfStY7W1uQnB1LBsgdFE77XsPXv57uv56YVt06g5N2SxSeLYuSOP1CNlgN5q37ZwJ54v8NI0i+Bpgppqurhd5g6iuE70+q9cyxkPxVvuVfrzI1Xt121r0Q05ldUgCl5vAJ855ooNBAshR7J14j+sB7c2x3IA5O96CBa5sxa3e7N1xzQzKSwZsTxDqJM18zSuSupmcZtY0PDJXKnscsD/Ox8o/bGj3bs1g9Yw/HTzUEZ+B1Mzg== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: a3803bb5-e307-4b4a-07f8-08dbea780a88 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:55:50.1430 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1KWK0199gQSia4a/DVSQauiQPVw36CigohJ3k5KaHicqq/ftcdw+aP2RLcrRcVs0DtkIpTFndNZtswVowB80UQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB7620 This patch tests newly added flush command for the userspace PM. Add flush commands into userspace pm dump address and subflow tests. And use dump commands to check if the userspace pm local address list is empty after addresses flushing. Signed-off-by: Geliang Tang --- .../testing/selftests/net/mptcp/mptcp_join.sh | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index a269448bb61a..1145e5f98977 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3514,8 +3514,8 @@ userspace_tests() wait $tests_pid fi - # userspace pm dump address - if reset_with_events "userspace pm dump address" && + # userspace pm dump & flush address + if reset_with_events "userspace pm dump & flush address" && continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then set_userspace_pm $ns1 pm_nl_set_limits $ns2 1 1 @@ -3532,12 +3532,18 @@ userspace_tests() mptcp_lib_check "ip netns exec $ns1 ./pm_nl_ctl dump" \ "id 10 flags signal 10.0.2.1" \ " dump addrs signal" + ip netns exec $ns1 ./pm_nl_ctl flush + mptcp_lib_check "ip netns exec $ns1 ./pm_nl_ctl dump" \ + "" " dump addrs after flush" + chk_rm_nr 1 1 invert + chk_mptcp_info subflows 0 subflows 0 + chk_subflows_total 1 1 kill_events_pids wait $tests_pid fi - # userspace pm dump subflow - if reset_with_events "userspace pm dump subflow" && + # userspace pm dump & flush subflow + if reset_with_events "userspace pm dump & flush subflow" && continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then set_userspace_pm $ns2 pm_nl_set_limits $ns1 0 1 @@ -3554,6 +3560,12 @@ userspace_tests() mptcp_lib_check "ip netns exec $ns2 ./pm_nl_ctl dump" \ "id 20 flags subflow 10.0.3.2" \ " dump addrs subflow" + ip netns exec $ns2 ./pm_nl_ctl flush + mptcp_lib_check "ip netns exec $ns2 ./pm_nl_ctl dump" \ + "" " dump addrs after flush" + chk_rm_nr 1 1 + chk_mptcp_info subflows 0 subflows 0 + chk_subflows_total 1 1 kill_events_pids wait $tests_pid fi From patchwork Tue Nov 21 09:52:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462721 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2083.outbound.protection.outlook.com [40.107.7.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8DA3C8C0 for ; Tue, 21 Nov 2023 09:55:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="bsaES1Pn" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gzLIRGVDWNjiKh3BlOVRypzG6Payt8tts4StXmMJwdvFEy6JldEEepsWGsLNAFeOl8KFRdYQrmnVD5/YigEtRDp5eP/mmo7ObpWtJwX8WhL0Vc9DF30QRURyI5yqryG0KP/XYwoG4O0fyifVOoLYP7odUt1vl+JcBzsx9p8B39gwFTb/JPx7xf8z4dQvY5+0ZRi+ubsu40UUjo5SyTKRKgBbpMeJjeXMDxEy4cTo7IpAfYjoP4mGQCcRh2zPTcn6dIx/wDrVQZgldVzb0fH8ciEqhFAtImA8J/I8tx8v5f7NqFmBAcT5uGh7Euxx7BWBo1Y8LVH1TJT61dp6gHN/9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0pniVddLH6ts6xok3y2xfxjPsHWnK8WegizqVMsEvsI=; b=elv6m900NuXJkQIgOLLcG4NKx3LgfllsE31suovbAveTMZKwurVLd68mIllsTLfrMjZ/NSrqj0xyErFrW9JhITinN1XxFSxuTJfMQUI+1lqzcZp6vWv3IY6ynYjf1e3P11NL3s3Wm8EZe2Qpfv6Pzl3lqhJvkB+vAFqwWfNL1ArK77fHANjKMwQ5k9b1AAC06s62RPv5gYdKmhM67NmBOAchFiRWu3NkLtXmOdDcttwiVLGQQWcaL6udg8YtdQPxtncxttSGi2Xpnnoe0/D2TqVMAGsBB6W74xrQPBjfKC7dq7NsR0LjY0jUe/IeKoRBRf1iQYeQi9zSrqleUs1viw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0pniVddLH6ts6xok3y2xfxjPsHWnK8WegizqVMsEvsI=; b=bsaES1Pn7k+gIf8Rm7W0zheqOFM2ajjK7aSqOjJHIELplaWsE7oB8gfL1IV/54nYVTtbt/jHsGGJIl2QcyM8yftgbQm91vAILA9VeEIpIR8KAKH79pzHlIAPLghP7tKe4llroKIhFFXKITg4TwkfXpxDmHASVHHvlKdEGMisyzE9PphOTGH09B3KsQuzwfcs1n+128q89mtfqXzkdoIzMKRIPEjFKKrSeDBzi624vdcjGTdFpbAmqc6TD2vytOf52Ru6cj6xcSSrHdjlaUEydDC+Al+eWHlx3wtQLNPSBiD5FJ9sZ2qFOOyKtSxGjkqSbCLo3MAxrMh4T8TpVwrfLg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by PAXPR04MB9667.eurprd04.prod.outlook.com (2603:10a6:102:242::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.16; Tue, 21 Nov 2023 09:55:56 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:55:56 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 22/28] mptcp: add use_id parameter for addresses_equal Date: Tue, 21 Nov 2023 17:52:45 +0800 Message-Id: <1b88c444d9f914917aa2c37b0b5743024746fd0c.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SI1PR02CA0011.apcprd02.prod.outlook.com (2603:1096:4:1f7::19) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|PAXPR04MB9667:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e085be1-3489-4742-eb52-08dbea780e5b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4jIaessf5y7w/MCxTv7Bpnj6Diftxj5M6g6yldYzOqZYJc/y+7cqNMoDW6SvB4au73uH8G4RnU6lMM6tN/SpZyEo2YdK4RV9uBGivEeXI0s9YJmKZegc59Z+mU3QFkTRrD9UYGuRj1H4eWUBbx2i/BR3SE0RVaeSBPPlTyf7HmNGZpJV5hPM0OchIYyM+6XEI7f6G1+CkofUg3rSFTWsloRNb/rjG9nbc9/qs+uonWj00q2r+P0F3DbAle81MgF5BNtiMp7Vnnpd+uTgu6eJlkLc97riiUp3smGBO/SDkFfrEXI/0AHKrTYhblSL01hsAUTRzELeiZq5hQZyyFYeipyMdjcQYvxZHhXrv9vFxxxKOgDdBPeEbC7PJZKf6N/iYMD6Dx67UbiCQk+AbX+4W54J522yAk3mF3rvGKbvbrP1VxFhxNHJxhdpuoLkvnTNyB5bA/QrLtMSLLRmNNzy/zKrPk9KFrlPMDB5KSzgh9tV8WFqiK7bh8MQAj318Bd4Ma/8yR95IajQXPPJCthrMG781bamULGWSNY7vGMFIwH8eOXy/5Bnm1kChT3d9WzH X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(346002)(39860400002)(396003)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(83380400001)(6666004)(478600001)(2616005)(6506007)(6486002)(26005)(6916009)(316002)(66946007)(66476007)(66556008)(107886003)(6512007)(38100700002)(8936002)(4326008)(8676002)(44832011)(5660300002)(2906002)(41300700001)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1LaO/Jdk3MJtgTeSYM2nk/faw9xvqaLPWT+dXURx6k481TRGSlm94+zzCZrihEKtkN7tWjtj652QYV5giF7ZCEvD1GlAt8I529/BzQ5AupXsENONyN1TGuB2/EBklCZxonhoYSUSgRzwro5tR6apEZq2cijJBVm8WN6zO7zZGj+rG9E9MSHdsrZRZ79ISdIWk6TVYxAU7gvL3Qj7uaQXhPsXbwAoI7toXkWAwjwCY6Y55wqqu3079gGI3wtknZralqjdC97w6z4i1tYV9xciutQ1jS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5Q16yq4ehTB44FADXlhKkN6BQ5Sv7GDaSZ/+hMuqZSQ9ZZ+Kqr5eISpjUPCEsdpQB/OfDYfAFxpQJXF09Mvp4qNdKpGkAtLhaGaK/KI0xBPR5fFxOY8Q3sUTvVttuL1bDLUOmpmLM4hUaKS2dDruSvWXAWWJaE+5KYWaMGLlQOH+DWvFouG5seqVciGIAK3PddLBjTQK/fTuC8/a/TkEWhz7X7xLvXTz/6yd9xQicZ+C6TVKbqZcGoUpuGQ== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e085be1-3489-4742-eb52-08dbea780e5b X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:55:56.6777 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EonY/eIK5Wtq3bh0n4CF5uHCbGFbvhPFenVq2epz2g8G44WYqYGBYO/lR+f5xzHtfYBp5zXPA8v7eobXkK0MCQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9667 This patch adds a new parameter use_id for mptcp_addresses_equal() to test the address ids, as well as the address. This can be used to test if the two given addresses are identically equal, they have both the same address and the same address id. Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 2 +- net/mptcp/pm_netlink.c | 32 +++++++++++++++++++------------- net/mptcp/pm_userspace.c | 6 +++--- net/mptcp/protocol.h | 3 ++- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 48ff7ce20890..77a0e859076c 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -420,7 +420,7 @@ int mptcp_pm_get_local_id(struct mptcp_sock *msk, struct sock_common *skc) */ 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)) + if (mptcp_addresses_equal(&msk_local, &skc_local, false, false)) return 0; if (mptcp_pm_is_userspace(msk)) diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 6bc1a6b5b4f0..6ad8bb2f32e9 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -47,7 +47,8 @@ pm_nl_get_pernet_from_msk(const struct mptcp_sock *msk) EXPORT_SYMBOL_GPL(pm_nl_get_pernet_from_msk); bool mptcp_addresses_equal(const struct mptcp_addr_info *a, - const struct mptcp_addr_info *b, bool use_port) + const struct mptcp_addr_info *b, + bool use_port, bool use_id) { bool addr_equals = false; @@ -68,10 +69,14 @@ bool mptcp_addresses_equal(const struct mptcp_addr_info *a, if (!addr_equals) return false; - if (!use_port) + if (!use_port && !use_id) return true; - return a->port == b->port; + if (use_port && use_id) + return (a->port == b->port) && (a->id == b->id); + if (use_port) + return a->port == b->port; + return a->id == b->id; } void mptcp_local_address(const struct sock_common *skc, struct mptcp_addr_info *addr) @@ -110,7 +115,7 @@ static bool lookup_subflow_by_saddr(const struct list_head *list, skc = (struct sock_common *)mptcp_subflow_tcp_sock(subflow); mptcp_local_address(skc, &cur); - if (mptcp_addresses_equal(&cur, saddr, saddr->port)) + if (mptcp_addresses_equal(&cur, saddr, saddr->port, false)) return true; } @@ -128,7 +133,7 @@ static bool lookup_subflow_by_daddr(const struct list_head *list, skc = (struct sock_common *)mptcp_subflow_tcp_sock(subflow); remote_address(skc, &cur); - if (mptcp_addresses_equal(&cur, daddr, daddr->port)) + if (mptcp_addresses_equal(&cur, daddr, daddr->port, false)) return true; } @@ -205,7 +210,7 @@ mptcp_lookup_anno_list_by_saddr(const struct mptcp_sock *msk, lockdep_assert_held(&msk->pm.lock); list_for_each_entry(entry, &msk->pm.anno_list, list) { - if (mptcp_addresses_equal(&entry->addr, addr, true)) + if (mptcp_addresses_equal(&entry->addr, addr, true, false)) return entry; } @@ -222,7 +227,7 @@ bool mptcp_pm_sport_in_anno_list(struct mptcp_sock *msk, const struct sock *sk) spin_lock_bh(&msk->pm.lock); list_for_each_entry(entry, &msk->pm.anno_list, list) { - if (mptcp_addresses_equal(&entry->addr, &saddr, true)) { + if (mptcp_addresses_equal(&entry->addr, &saddr, true, false)) { ret = true; goto out; } @@ -463,7 +468,7 @@ __lookup_addr(struct pm_nl_pernet *pernet, const struct mptcp_addr_info *info) struct mptcp_pm_addr_entry *entry; list_for_each_entry(entry, &pernet->local_addr_list, list) { - if (mptcp_addresses_equal(&entry->addr, info, entry->addr.port)) + if (mptcp_addresses_equal(&entry->addr, info, entry->addr.port, false)) return entry; } return NULL; @@ -704,12 +709,12 @@ int mptcp_pm_nl_mp_prio_send_ack(struct mptcp_sock *msk, struct mptcp_addr_info local, remote; mptcp_local_address((struct sock_common *)ssk, &local); - if (!mptcp_addresses_equal(&local, addr, addr->port)) + if (!mptcp_addresses_equal(&local, addr, addr->port, false)) continue; if (rem && rem->family != AF_UNSPEC) { remote_address((struct sock_common *)ssk, &remote); - if (!mptcp_addresses_equal(&remote, rem, rem->port)) + if (!mptcp_addresses_equal(&remote, rem, rem->port, false)) continue; } @@ -884,7 +889,8 @@ static int mptcp_pm_nl_append_new_local_addr(struct pm_nl_pernet *pernet, entry->addr.port = 0; list_for_each_entry(cur, &pernet->local_addr_list, list) { if (mptcp_addresses_equal(&cur->addr, &entry->addr, - cur->addr.port || entry->addr.port)) { + cur->addr.port || entry->addr.port, + false)) { /* allow replacing the exiting endpoint only if such * endpoint is an implicit one and the user-space * did not provide an endpoint id @@ -1022,7 +1028,7 @@ int mptcp_pm_nl_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc rcu_read_lock(); list_for_each_entry_rcu(entry, &pernet->local_addr_list, list) { - if (mptcp_addresses_equal(&entry->addr, skc, entry->addr.port)) { + if (mptcp_addresses_equal(&entry->addr, skc, entry->addr.port, false)) { ret = entry->addr.id; break; } @@ -1404,7 +1410,7 @@ static int mptcp_nl_remove_id_zero_address(struct net *net, goto next; mptcp_local_address((struct sock_common *)msk, &msk_local); - if (!mptcp_addresses_equal(&msk_local, addr, addr->port)) + if (!mptcp_addresses_equal(&msk_local, addr, addr->port, false)) goto next; lock_sock(sk); diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 8494d6df866a..06fe6c65b4f9 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -54,7 +54,7 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, spin_lock_bh(&msk->pm.lock); list_for_each_entry(e, &msk->pm.userspace_pm_local_addr_list, list) { - addr_match = mptcp_addresses_equal(&e->addr, &entry->addr, true); + addr_match = mptcp_addresses_equal(&e->addr, &entry->addr, true, false); if (addr_match && entry->addr.id == 0 && !set_id) entry->addr.id = e->addr.id; id_match = (e->addr.id == entry->addr.id); @@ -105,7 +105,7 @@ static int mptcp_userspace_pm_delete_local_addr(struct mptcp_sock *msk, struct mptcp_pm_addr_entry *entry, *tmp; list_for_each_entry_safe(entry, tmp, &msk->pm.userspace_pm_local_addr_list, list) { - if (mptcp_addresses_equal(&entry->addr, &addr->addr, false)) { + if (mptcp_addresses_equal(&entry->addr, &addr->addr, false, false)) { /* TODO: a refcount is needed because the entry can * be used multiple times (e.g. fullmesh mode). */ @@ -145,7 +145,7 @@ int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, spin_lock_bh(&msk->pm.lock); list_for_each_entry(e, &msk->pm.userspace_pm_local_addr_list, list) { - if (mptcp_addresses_equal(&e->addr, skc, false)) { + if (mptcp_addresses_equal(&e->addr, skc, false, false)) { entry = e; break; } diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 7441e3b9443d..d132a8d91d10 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -645,7 +645,8 @@ void __mptcp_unaccepted_force_close(struct sock *sk); void mptcp_set_owner_r(struct sk_buff *skb, struct sock *sk); bool mptcp_addresses_equal(const struct mptcp_addr_info *a, - const struct mptcp_addr_info *b, bool use_port); + const struct mptcp_addr_info *b, + bool use_port, bool use_id); void mptcp_local_address(const struct sock_common *skc, struct mptcp_addr_info *addr); /* called with sk socket lock held */ From patchwork Tue Nov 21 09:52:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462722 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2049.outbound.protection.outlook.com [40.107.7.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4427DC8C0 for ; Tue, 21 Nov 2023 09:56:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="tmpsQ/qm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QDD1d6S/GaPcw81yNHNZ0pgfihWGoQ2iikfDa9FVobLtmbKzi1AJXz+Tv6VLaAab/mGbqkQMf51RGfxL+4OmRBbQUJ7Qbsi+HhXjRsUomVo9FJPVxNxnhbiqZFvtO4mOLi2TFhyAX3pj/p6TdK1B4BRYoQZJyUSgn+S3ijMUN8Uwba+X6Y1/k2dNQwnEAH90l9lekKl/MvxwfV5GmuUMGX1jZSJ7PiKbucVh1aAKq6ckEHmFZrD41f4vrwSjuYG7Xgd/MhS2YGTF7Tpj2cjKFANygHJpJyx6DPZEoqNk7qJy5bYZ4f/MhqC8cLmq4NT1mLe0G13l3y1648HfIsFC1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=1C+mGleUJvXIa3Wci6uvGa1nefJUd2Vo8WcldczX+lA=; b=jDfFlyLNg3PGM3ZXvt20gMQCXQJfRqzs/OjV2abI/j3f4WaPAT6GEH1ffm/2Us7jQN/vLsKaPnJK/Zz+Dvg5POtL0lsAF3zo/xiemn9rENn1B6wSrilUgbzrh1Xav2+LC1Ye37oJ2jfAreMQtxRFF4UAUv88csLahaknNhS7eGtG7y30pKk9SM/nOrfnPA9H2EH0VPctrDPDmpYj5UIiTTJU87FjxpexU/W/pnPUM9KpNhrBbo3T/J5RqsGNwqQ29Kl66EaToROvzl1pwU1xtdTdC9MBoRn2TZJDnvSMSjXvzINamn1zFr96ErOygGjNGyN2coi+TQTg+S/9l8Q/2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1C+mGleUJvXIa3Wci6uvGa1nefJUd2Vo8WcldczX+lA=; b=tmpsQ/qmlRD6d/KkNBjaeZrBPbqJGZgb6SHs0pcOjZe5pfZo4KA0rD4hSAnCLJDgc8IzBVzDbFKxATjl2ceV82gKhtm0kX6gVTKK6Ij4WqvHGBBS00o2ynDlydTnhrni7CD2UNyNvG7l6oDmFYaUW5I2R97Mj40OzLQhCwTTnXghrJOXOaxHVz+NuTAMTuz6b25kbaXTn6i2rQKQJgJvAdG7/twL+df1ODgDH6v+0kQaOeGF/PhZIWbZOkoa7DAFkvGDPkMyviK0J0BYHKa1q/eHyRphxDXyxqHSDTmNLIm66i1nCONI5pDilq+LYUbIDeQvkJY6EWkDT6FsVcHQ2g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by PAXPR04MB9667.eurprd04.prod.outlook.com (2603:10a6:102:242::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.16; Tue, 21 Nov 2023 09:56:02 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:56:02 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 23/28] mptcp: add check_id for lookup_anno_list_by_saddr Date: Tue, 21 Nov 2023 17:52:46 +0800 Message-Id: X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SI1PR02CA0009.apcprd02.prod.outlook.com (2603:1096:4:1f7::10) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|PAXPR04MB9667:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c32883d-5644-45d5-d1fc-08dbea7811f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CT3HebCLEcNMupO2jKr9d7a7meBV0ibEkDLBp/fygIa171xR6B9Ix5K3BrWCebKk1h3DVLsnqnEk57/XuUabDs7KacOYeCwK8r9tjE1x8ee6WbS7+tiumfLrjMAMNdI30iNXCEhGqyzAzQ2MQSjlAFPZL96Yvh0vD5VdQrG43GW+OY2WfRwKvINpVCKEOel4dHR5Ek4FIeG9QzNiOsm00s+gfDMEVrfd/xta/gxCSbomqVQJcBXX9l+90iMgxOzGp70oG+qwCuvEDAdsryedf/XJqvb9FUxJC6teXLu89QowYNw5EKm9BNVMI4Y/hDPrbxvQAfubF23wV2Q+Gkof057nWsXgQftNFNbvauskUZFlLAT60mUTe9lh/cFVbdgLgoS6B+PxkLTpXsLS6mm5mdIk2N3gWh6aK2xA30Ymwgshn+pKvIImvOOEvmvufFgKa3hqXmotTlF0ElB+NrFc4gxaFqbcYONbAWvJ7uAbFmKK3Aw0h8roFIQWr3VvTtoZ/SRmtfujaUOtjxV4EiGl7nm17aroPXoNASzibsrn1Wudf2EGuY4rKTIAd+fv7YdL X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(346002)(39860400002)(396003)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(83380400001)(6666004)(478600001)(2616005)(6506007)(6486002)(26005)(6916009)(316002)(66946007)(66476007)(66556008)(107886003)(6512007)(38100700002)(8936002)(4326008)(8676002)(44832011)(5660300002)(2906002)(41300700001)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HELW1jbaopuM7xxHnyc3uoxComw+lSJMbG6m0r2OUfLsScJ1aH+hQBdlaYJagB+Yos+AS00bLlMUFFDOczFEd9snujJSsBwZ52C92zMtP8IMIkeNag2nOWUMdJSwCmB87fjt87iUJSUuy7/EidbTaM3YjpBJuPuHptjk0NtLxTYEVuaJJU/MKWXkEcqWsCTUjYe1FRQBr010UpycemNeUYKV2GDt+N/sd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XoKd3bwHEgOKJ35u8KrkwCLlTej+2cSWXO2C1sCrI6lOhb2d8cuujkuqNdPgqLQrHWlpcX9HfR74522/RPUKX9JcxoPSJ88uCQcblCi6rtuG7++v1yKVMnU5tLaHsoiCdCbkl1JA3iOXcMQmEbdMGX2Pe/cpVRdM+ucdCqILFLn42vLoGIYt5iegejaZBl4JvbhUU+4ed5g7SWzXp2iNHz13K/BL66iSiyiTtU0MBsLZVsIhoX12gFlQwRq/rWl+/I/D7kIQPdgphkTC+ijeRjOLg2pc1yuQEPdCK7k7ncvdGdAhmy26jrjGTg7S6Q== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c32883d-5644-45d5-d1fc-08dbea7811f1 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:56:02.5847 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 53wa+6id9/NldIYb7KoLUXjxVdASL484eqJdeLWbOY6hodM8ED8OujKzitKHyTnchH86IFx1ZZf5BOWW24qfUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9667 Add a new parameter check_id for mptcp_lookup_anno_list_by_saddr(), and pass it to mptcp_addresses_equal(). Then in mptcp_pm_del_add_timer(), the input parameter check_id can be passed as the new parameter into mptcp_lookup_anno_list_by_saddr(). After this, this condition: (!check_id || entry->addr.id == addr->id) can be dropped, only test if 'entry' is NULL is enough. Signed-off-by: Geliang Tang --- net/mptcp/pm.c | 2 +- net/mptcp/pm_netlink.c | 13 +++++++------ net/mptcp/protocol.h | 3 ++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/net/mptcp/pm.c b/net/mptcp/pm.c index 77a0e859076c..d5ae2e775059 100644 --- a/net/mptcp/pm.c +++ b/net/mptcp/pm.c @@ -259,7 +259,7 @@ void mptcp_pm_add_addr_echoed(struct mptcp_sock *msk, spin_lock_bh(&pm->lock); - if (mptcp_lookup_anno_list_by_saddr(msk, addr) && READ_ONCE(pm->work_pending)) + if (mptcp_lookup_anno_list_by_saddr(msk, addr, false) && READ_ONCE(pm->work_pending)) mptcp_pm_schedule_work(msk, MPTCP_PM_SUBFLOW_ESTABLISHED); spin_unlock_bh(&pm->lock); diff --git a/net/mptcp/pm_netlink.c b/net/mptcp/pm_netlink.c index 6ad8bb2f32e9..c141ac8ba1ef 100644 --- a/net/mptcp/pm_netlink.c +++ b/net/mptcp/pm_netlink.c @@ -203,14 +203,15 @@ bool mptcp_pm_nl_check_work_pending(struct mptcp_sock *msk) struct mptcp_pm_add_entry * mptcp_lookup_anno_list_by_saddr(const struct mptcp_sock *msk, - const struct mptcp_addr_info *addr) + const struct mptcp_addr_info *addr, + bool check_id) { struct mptcp_pm_add_entry *entry; lockdep_assert_held(&msk->pm.lock); list_for_each_entry(entry, &msk->pm.anno_list, list) { - if (mptcp_addresses_equal(&entry->addr, addr, true, false)) + if (mptcp_addresses_equal(&entry->addr, addr, true, check_id)) return entry; } @@ -290,12 +291,12 @@ mptcp_pm_del_add_timer(struct mptcp_sock *msk, struct sock *sk = (struct sock *)msk; spin_lock_bh(&msk->pm.lock); - entry = mptcp_lookup_anno_list_by_saddr(msk, addr); - if (entry && (!check_id || entry->addr.id == addr->id)) + entry = mptcp_lookup_anno_list_by_saddr(msk, addr, check_id); + if (entry) entry->retrans_times = ADD_ADDR_RETRANS_MAX; spin_unlock_bh(&msk->pm.lock); - if (entry && (!check_id || entry->addr.id == addr->id)) + if (entry) sk_stop_timer_sync(sk, &entry->add_timer); return entry; @@ -310,7 +311,7 @@ bool mptcp_pm_alloc_anno_list(struct mptcp_sock *msk, lockdep_assert_held(&msk->pm.lock); - add_entry = mptcp_lookup_anno_list_by_saddr(msk, addr); + add_entry = mptcp_lookup_anno_list_by_saddr(msk, addr, false); if (add_entry) { if (mptcp_pm_is_kernel(msk)) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index d132a8d91d10..d40e29419c04 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -920,7 +920,8 @@ mptcp_pm_del_add_timer(struct mptcp_sock *msk, const struct mptcp_addr_info *addr, bool check_id); struct mptcp_pm_add_entry * mptcp_lookup_anno_list_by_saddr(const struct mptcp_sock *msk, - const struct mptcp_addr_info *addr); + const struct mptcp_addr_info *addr, + bool check_id); int mptcp_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, unsigned int id, u8 *flags, int *ifindex); From patchwork Tue Nov 21 09:52:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462723 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2055.outbound.protection.outlook.com [40.107.21.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96F56C8C0 for ; Tue, 21 Nov 2023 09:56:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="nLM5JXG1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nF4FKQvHbi0c6V5CH8xqKV4eA2LqT2v/JRJ3CquzuKgEHcTqElotCniOEVYCXCfl0eOePs3LF+oH0krv3KlgH97kfpdRJJR33q9JlcY+A5+DbeZV5eVX+DH13SNsm6y2/PrblcqOS7F+O+m3uFNIMoGgKe47RMtVdQKhV/LmemjBXV095UsbodgMApNvHtwns22sJXSBsi9KiSbvIMo1LuArDOuLDHDJ+dtwnOLrVfHQ0yabwo0M/GJLFgaFmoA0qSOEKZmgbLXcaHyMGSyYdgzvyfvBea91EuVc3JOz6aeYymfXt4ReEp75fR7eNvycI3Pa6lgaG6/OUAGgjeozQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XNtg0ENlx6XyP55fGgvTpB7mqIxaNS8NhC8buwqnLKM=; b=RqGP3JwQdp9RUwU4nWJKXbDtIfqRKA3CBOLbRplfrrvJLJvAHzs8+aDQ8i6n7WXsKpkbifdeAjIGQE6CZ9lBOgCaZ1H97fqST2l1Sj2rStT6RWhGcc36JCfH17lzm8PPYnRfD7fwkYPLt2yqfccDtj5cTaG90Ul7ooxxQO9CMUUzDkF91DjcTkn2eYPojuZqFBsmUhELlDLtIe88c71apWBHe9DU7IUZGR1jq5WppRfISdx0Gy+izk+1rbnPnJeibogR8YAIEty67ov09WS8UDFwBn0zdd+5DTbr35M6jHigra1QZfqaQk3l6EZFTACZ6Hbikce6cKuCpU82bk2i+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XNtg0ENlx6XyP55fGgvTpB7mqIxaNS8NhC8buwqnLKM=; b=nLM5JXG1hbTeP9TjJkEXAWNfPDpY/SgU3DwURc1HCLJBN6/iycu/5Uy74XodaTtqoI/Ch2dkGIC0TzCFYcufqLDJdrM3too2IIiojV7sPnLcTjxev55WqzhnZzHhszNCZdtB21y3ZcTc9Oeqjowzsl/zlC+L7MCn0QjrCGsRYFH6NvBrnJCFTlPsCC5qvYZHX2gjVPL4PKM1mjka5WoltwECctZsAiLSrlRMosuFEkOm71/ZuLXhtAqaV+EUd71R+ILTRgHqnX77iBoaLlBuwgBD5iVj1zDcPyDxBFyD9d8u0Bx8OPddKW1drJVZfQxj1cTrR3nOrwKlJKgpHEsQBw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by PAXPR04MB9667.eurprd04.prod.outlook.com (2603:10a6:102:242::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.16; Tue, 21 Nov 2023 09:56:07 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:56:07 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 24/28] mptcp: add userspace_pm_get_entry helper Date: Tue, 21 Nov 2023 17:52:47 +0800 Message-Id: <8c00174c4018d64fbd09d75a14c1b564c9c0bf7e.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SI2PR01CA0031.apcprd01.prod.exchangelabs.com (2603:1096:4:192::11) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|PAXPR04MB9667:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e686e5e-f7a4-4e65-0b22-08dbea781539 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: otA5dCSfmjFMcnu6d5VkTLakSfQPeMEX9gsMbdiaURi1QV2pZ8Scpt4HpQiZhzcVzMVJApYyQm2qChjpU7OkYz4Zr7XYj0/1igsrPUHzOftahb++Sahe702881CIMqC+HsL9eX3Yekcl2wYl0WkofKFzz5hBea8WVZuPzC1G4MbJMlrcTNKA5dqlMIOPW5UeZZVYz/TYBF+Fo+/eaiW/YNunNk3ulryq6xgX65uLAc93LkrBfpKDyjoHEn+8woG7DH2eYQJ9Ft2cDXRrSRe6RWnF7M4e7hsPprDwnuWHhoXP3+qfGPMVWwFQS2rO52LegA8gijr1Ng4KN9rqfcl9b+nqWbld1KebUhwvj0emF7Xo4XQLUvF7e2V4nkpR+LqnZeZE+4qK7iNbUR1HEDlAOipupqT9wWvPu1x54/MnTgYhRa7gyN2EDu7lwpEA9HCtES7laiRIh6ExZVjivhDHyv5pQcC3/2CHl6BkxaOjcANZoCo4ApiETztk+qw588u0xksHAMuPNU/OiFddVF64i61fkh/jflMDxvu+vmeI9Zx/DpD1rOZOPSBwgsx+m55a X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(346002)(39860400002)(396003)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(83380400001)(6666004)(478600001)(2616005)(6506007)(6486002)(26005)(6916009)(316002)(66946007)(66476007)(66556008)(107886003)(6512007)(38100700002)(8936002)(4326008)(8676002)(44832011)(5660300002)(2906002)(41300700001)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-Mess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OPO98RnG08jFH3L8Vl+S50QjebWzf0OZxYguo2Kc1PEaYtopc3o6q3Bz6kqn5Fvthnxwl39I3cftzUOTzfuN/UxU3vBoS4zb5MyjGm6U7dnXFdwDOLQbfx401fXgJjEbNWIyvbP2xYkVv8XrHtrqeSdB3fh31o50EsR2cvNiXWiy5z4OEGc5ZmBaftaugrT1li7MTkHrTzsXneExBH5wKpPM7wJzPYn9+jb8KFQWnrPKXqwM9dhl1kWcVEXXPzN1d9PPXmLyBNQ0PiLe6bCSElAvJ0rxV0nwFgJ+8WSaiBsRASRgskR3oxtykQioHX+WBS+0exhc9DsszZkXSjYCROQVmchUt4oDM2UN9awwSAt9+IHscshyT1r3qFCv5YwOUlsCqfq+e7C4qU0qpJMzdyxK1zMyPZ6eF2je1geCFnjYtKpava8hxedjwKD7Gy6eOO9ViAX6GeL4H5iCqeMOu5uN9wBI3exLdm44uKk2ieSuBJhEdWvlg16tbdKXvjyuxR6HcsYC/RVqpQN92OJCoyiRCBPE0k0mtXUqPA== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6e686e5e-f7a4-4e65-0b22-08dbea781539 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:56:07.8881 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Wv/SLyf4ypB96PtHyUJ2qGK5gtP7a+Q1qYcY//R3kTZxQl5j31sXyxPOU++NZU7mx6xgArqwJq00fim5b9WMRg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9667 This patch adds a new helper mptcp_userspace_pm_get_entry() to find out the address entry on the userspace_pm_local_addr_list through the given address. Use this helper in mptcp_userspace_pm_delete_local_addr(). Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 44 ++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 06fe6c65b4f9..8c7553d7ee65 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -40,6 +40,20 @@ mptcp_userspace_pm_lookup_addr_by_id(struct mptcp_sock *msk, unsigned int id) return NULL; } +static struct mptcp_pm_addr_entry *mptcp_userspace_pm_get_entry(struct mptcp_sock *msk, + struct mptcp_addr_info *addr, + bool use_port, bool use_id) +{ + struct mptcp_pm_addr_entry *entry; + + list_for_each_entry(entry, &msk->pm.userspace_pm_local_addr_list, list) { + if (mptcp_addresses_equal(&entry->addr, addr, use_port, use_id)) + return entry; + } + + return NULL; +} + static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, struct mptcp_pm_addr_entry *entry, bool set_id) @@ -102,18 +116,17 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, static int mptcp_userspace_pm_delete_local_addr(struct mptcp_sock *msk, struct mptcp_pm_addr_entry *addr) { - struct mptcp_pm_addr_entry *entry, *tmp; + struct mptcp_pm_addr_entry *entry; - list_for_each_entry_safe(entry, tmp, &msk->pm.userspace_pm_local_addr_list, list) { - if (mptcp_addresses_equal(&entry->addr, &addr->addr, false, false)) { - /* TODO: a refcount is needed because the entry can - * be used multiple times (e.g. fullmesh mode). - */ - list_del_rcu(&entry->list); - kfree(entry); - msk->pm.local_addr_used--; - return 0; - } + entry = mptcp_userspace_pm_get_entry(msk, &addr->addr, false, false); + if (entry) { + /* TODO: a refcount is needed because the entry can + * be used multiple times (e.g. fullmesh mode). + */ + list_del_rcu(&entry->list); + kfree(entry); + msk->pm.local_addr_used--; + return 0; } return -EINVAL; @@ -139,17 +152,12 @@ int mptcp_userspace_pm_get_flags_and_ifindex_by_id(struct mptcp_sock *msk, int mptcp_userspace_pm_get_local_id(struct mptcp_sock *msk, struct mptcp_addr_info *skc) { - struct mptcp_pm_addr_entry *entry = NULL, *e, new_entry; + struct mptcp_pm_addr_entry *entry, new_entry; __be16 msk_sport = ((struct inet_sock *) inet_sk((struct sock *)msk))->inet_sport; spin_lock_bh(&msk->pm.lock); - list_for_each_entry(e, &msk->pm.userspace_pm_local_addr_list, list) { - if (mptcp_addresses_equal(&e->addr, skc, false, false)) { - entry = e; - break; - } - } + entry = mptcp_userspace_pm_get_entry(msk, skc, false, false); spin_unlock_bh(&msk->pm.lock); if (entry) return entry->addr.id; From patchwork Tue Nov 21 09:52:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462724 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2059.outbound.protection.outlook.com [40.107.21.59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B20E93C081 for ; Tue, 21 Nov 2023 09:56:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="POmMDYQP" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LRAMSvoyDygIpr0FjsXOplCTCfEXrR7qmkVALNcmg2frHpE2IcSctTCl3tlp6Gepy3K0eW5M3o9zwofbp1NiwcZS2nQBz4J4/bknZDBnkSWureopwp0+sxbjw2W4YeA7+SwPhrM3P1eAzKnspYGEVeaBiDJ9/O6FKYjyntNMF1v43hlxFmqUZ3OQuS+wjbmOMVKpeVwy64iNOKdZlK9hFEIllvqftvqwVE9NbsbPzqqU6XYrIoowNRAbZ6m6VfyarPlCoddLDftxnbvM3fafdyh4UJLqmq4KtSu3Z5A7kfDclREkLg76EDRqcDkVzK6hGwU11Sdc49DxhQK9DZDR+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=X6MGksTFx+t4yzf6kvysgft7dLwKH1cppACIWDAADlc=; b=ZdBIcrdH/AdIe/vqhpeTj4My6Q9qMJ8z7UekfLu6owfz1paqVM0woTeZPnhZnBGORFVBYkvtA8WECLjYOr99l1LP5wUtSQQssN/kzLFv2Ds5tkSl5BB81KO8sAZJYEoJKIkgpGz+fxyestgpsdaFBWjYj8vVdT2WktcHn3hLy8N5SMegAchM9JuSuTr77zzaNioYMNiZ77LUy48AnIblVIPFfh0L61bDVAzQciv+0ib8jxniUxHvMORf33bPnwh/Zc0P2qjIWvFKsuSzvLkW+YTX8dnBYNsH8+mGk96tyUhfwu3gCc64AL4JstC3J7dcY4EBuvaCQD71NlOssu/hUw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=X6MGksTFx+t4yzf6kvysgft7dLwKH1cppACIWDAADlc=; b=POmMDYQPzgRfaoyyA1e7LyTie0K8Y4MR8hfGqupI9I7JNmygCbStSi7nozk/e4TRH4ZPjTu3DbFjH9KeFyQEnmyrqOe+ADxP03rTzu4r23cOHD4P+UoiB6jHmuriv01T/yC/cSlYm1hcnCPKg+HwJliu/VRPQhXePm+mx36N4Mru1aE/SRudT+pdwZR/zq5kP+3HAwLRvsko92HFErvb8fuBTj6wt3ye125D8qdweqU2P4KHbqCOl7rkfaU6p6ULhTue0i6WXIlGUvTOp5i+PiewLJSH13S8G3xODTGmLfCs7Sn7xlp0B3Zgpu60ZZlQVwgrTy1nG2/lSOyoTh30Ig== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by PAXPR04MB9667.eurprd04.prod.outlook.com (2603:10a6:102:242::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.16; Tue, 21 Nov 2023 09:56:12 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:56:12 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 25/28] mptcp: drop addr_match and id_match Date: Tue, 21 Nov 2023 17:52:48 +0800 Message-Id: X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SI2PR01CA0023.apcprd01.prod.exchangelabs.com (2603:1096:4:192::17) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|PAXPR04MB9667:EE_ X-MS-Office365-Filtering-Correlation-Id: 752f73ef-1105-434f-ab70-08dbea781825 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qkC6LUxLny079JCesZhLi7cP2c8Js2oiWmcBJGYyh2STLM4O1r4QBP6eeFQAE6FqHlLzfytvTFh4vHkebmidBAAj096FFKIM3YUHRlJ9Byshafp98oosLXMZX1kurnXJSIOPll4zo8i1mfFCtUe9w+Fv3tckv4WAd1GKBQAQGDE8JG2PocfnpBfJLE4QKLJIctYPvG0vbbKkmlNQFfaqdxOMnL3Fyv7x8RjfIDcPccRwSmJJqcLsKpqxn1oe5xM7U0BKr5Brwe73NnPi0OyGcJXDMtYD4MqOZL951as0rCM5KFHWbUuvzJ18tQaPIeYGOza0UcpMUhC/ghWCFBTj8zft2kMg8BS2odwRhXbA9ny85Xo43P0xJlzV59jaPUhxFg9kt1RmAF3H8mMKjaaPWWH42jwpnxDLxkh+AAHmBr0OL3Ofcnz4lgHmqwaDbXLcAfzeGk7pGkn7a33h5BRvATBDH1CaBglPkOcZFkHzZ4/ifam8qasf3Nsr23ZO3x5gRUOSnwxNFsiJC54EmNOeDCcY0AvAcNsF41DU0Bj73Cz5ByB3ocMSPw+Dwt38fZXm X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(346002)(39860400002)(396003)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(83380400001)(6666004)(478600001)(2616005)(6506007)(6486002)(26005)(6916009)(316002)(66946007)(66476007)(66556008)(107886003)(6512007)(38100700002)(8936002)(4326008)(8676002)(44832011)(5660300002)(2906002)(41300700001)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ndt7KERMciV8uE5vv0tOfae8771lyMnZqE7n3GWJV6FCkny05Hq99XHh8+DsFcnVUMURMpSKcUZVTrwqcfnSuabj5g3+JO+U+HbSKeN/9/p3X+DtvkzOooPdimRRz1qQ9y6AJm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w/34e4oblbud89HDa7B/3UxGhXLj9cDukfFrPmFNUXVv3A3CnB0CqRFS62VWSlQuZYpJVOW3F7Xs4yrYPcddwIn+69N3IZPfvIQ4Zhfebw3hi2j3VjawbFQ3DrRsR0tNhhhm9J/XKvXwuiIzpFqOC2BTcjtVUtHcuHQuIPor2L5mtNeOdA1dnSAk33F8BzcErIutUS8Bs/4mkEU/VTu0x6GN3vlBfcJv7HmZD95CANFZ7xZeMXrBf+WytPuL4PWh+LjCK3PehoI6Cwe8vVD0sr1Nd7VZQx5140VLXIWARkRktjyXZr/AVtlGvbpjF/U1IgRoHSiq6+2jEDS1gC/7PI0bwD0LL9YiJNLUeWBjZ7G+kYgMBvgQq9F648yyi1dvr/W7ZzTQ== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 752f73ef-1105-434f-ab70-08dbea781825 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:56:12.8188 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wXYtcwYeFzYfXhxta21E5UqbJ6EfHf69eUOcPKzV2jO6jrbM6yy8jJammceBanl51hxLvw2trvhtfe07JTBTDw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9667 This patch uses the newly defined helper mptcp_userspace_pm_get_entry() in mptcp_userspace_pm_append_new_local_addr(), and drop local variables addr_match and id_match to simplify the code. Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 8c7553d7ee65..a608166af121 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -61,26 +61,13 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, struct pm_nl_pernet *pernet = pm_nl_get_pernet_from_msk(msk); struct mptcp_pm_addr_entry *match = NULL; struct sock *sk = (struct sock *)msk; - struct mptcp_pm_addr_entry *e; - bool addr_match = false; - bool id_match = false; int ret = -EINVAL; spin_lock_bh(&msk->pm.lock); - list_for_each_entry(e, &msk->pm.userspace_pm_local_addr_list, list) { - addr_match = mptcp_addresses_equal(&e->addr, &entry->addr, true, false); - if (addr_match && entry->addr.id == 0 && !set_id) - entry->addr.id = e->addr.id; - id_match = (e->addr.id == entry->addr.id); - if (addr_match && id_match) { - match = e; - break; - } else if (addr_match || id_match) { - break; - } - } + match = mptcp_userspace_pm_get_entry(msk, &entry->addr, true, entry->addr.id); + if (!match) { + struct mptcp_pm_addr_entry *e; - if (!match && !addr_match && !id_match) { /* Memory for the entry is allocated from the * sock option buffer. */ @@ -99,10 +86,13 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, list_add_tail_rcu(&e->list, &msk->pm.userspace_pm_local_addr_list); msk->pm.local_addr_used++; ret = e->addr.id; - } else if (match) { - ret = entry->addr.id; + goto append_err; } + if (entry->addr.id == 0 && !set_id) + entry->addr.id = match->addr.id; + ret = entry->addr.id; + append_err: spin_unlock_bh(&msk->pm.lock); return ret; From patchwork Tue Nov 21 09:52:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462725 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2071.outbound.protection.outlook.com [40.107.21.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B3443C081 for ; Tue, 21 Nov 2023 09:56:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="A6TjaFV1" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hG3QysMnMc7P1z6mqS/UWsBOARvLvxP/FbFPAeIuj+CJBfZoYQu8OIU8SIsb87lX0QyjhPjxvow1ThvPc+o7aGYECzG/OZaZk2QxYZD1IN7ItUHh3aSUFjTDas3JeBsstC4cUqcxOnNTNZfmWvUxpNOeg5qGMAeRQgQFHExzfFBdPbNmctk39/KKJ2t+CuEbNmkRtPOcnNU/5dcun5wWTlBJlm6bSReswZhwhRHCEGOA9Z9JPL8S0vZWeRofmh4ap7F7iwHXH/7p6kCW34yk5qiACf8DTDxrNsgOgc8KDfrxxkMzb1YO3IXeY/Gahl1WHHjHcBn4r5jqmPlya4Q9Qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cxjjzLZ6kHF8UAV+cJ6wZQea+75Dlq7CfTcoZPopX/I=; b=JJrb8Yr+DXCoKpBPKhXho99CJRyGIvXZHOQuSqUITXKG1kv/dvF9gvxHLJK537HCKrfhHVIHxEi0zlaXdhLBKBqI5M20vZQ80r2lkjloejhY1TbNWcBEB7TKISrKbGc7HR9n4p06GJKC4D29ZjJAXqrCmcTIr4ZZ0eSXkR4IbMC5m50P+WC6YvBBTRX61OMmY9I2JYkG5T8/vZ1B1nxKUxREijHy6fPBfNf2ecGTWBZpzNyQIt3NvPsWzPNGsHJidaAsU0vUheKlLt0EwDNS08zMwipnjJRXGdvSKjTir17VI1g+Dee/WmnO3ubjPvB2nc6qlTlWEG19zzO9DuhLyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cxjjzLZ6kHF8UAV+cJ6wZQea+75Dlq7CfTcoZPopX/I=; b=A6TjaFV1wpZk2f4d75VwzIQ65HjHj3aNjyc7mOEM1xF64TsKyWTTjS/NDX3JlbUkAUnm4ZihBLfkzc6vTMgPGNsDLlRxaGlCH0Q3uf9yKwkOVlzzi4oX4ogYbUQOmI+CKTdTaQ2el4SIcSwwn2Na/yfiYHY0vyZVGWlNDgNyNxIIkJH1ESRlzkcH682ZTZbRQJaKxeEYR9XFmmVROQ3CuHbYUtYlIXC4NNu/DSdfcDSIuQcLnbul9iCNaHlP9JV5FG0WL0ryNi2HhDSZO1CMEV+t4wWB5a6EhTN34Z6NHsSP7hRIdBqW30Q5G9WfIx4vxc+tAEEs7SVRROeIpheq8Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by PAXPR04MB9667.eurprd04.prod.outlook.com (2603:10a6:102:242::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.16; Tue, 21 Nov 2023 09:56:17 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:56:17 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 26/28] mptcp: dup an entry when removing it Date: Tue, 21 Nov 2023 17:52:49 +0800 Message-Id: <674773de0b087c8a49f7dd32289be9a3c3680c26.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SI2PR01CA0023.apcprd01.prod.exchangelabs.com (2603:1096:4:192::17) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|PAXPR04MB9667:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c16fab4-9e24-45de-49ef-08dbea781b31 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NHSE/GkyfQ3jKR52GygsLivYw6UFhwm2gnF7LMzXdAQQHGna4e8D3gziqlgP7QAUJ02Q20nyUc6kx8DB2lbc/U940GvxZb33CsLNUPO0d+8AgaoYkL5JXMM0FsqvwfcNXI1bVxlqAFCi0Zy1pxi6Xgf2gdPoHjBt2YZY1Kas1+BP8rp2clUCj+6WJICFMjZ5sD3uosXuSlNE8B2uv0J/BPEXm2Glri7RSs0gjT/61sjuyxWaApMfmUfSbYBT0Q9UrVh2ID70ynByI2PxM9o0qG5hPkgh6XqKKzLVRh7KnygYNxSi/S5NLymPaszHvYPm3CZ1b7+RaXx5hBiVx1tRyIkA2VPlFzZ0uor11iUwGXUJx3wcf88ZRoU5v0k3dHFiWWMNcQ4eXt6l9d0QIH+ZNzSl41gePN8G/EHa6KDn18t4PuCS7hsLqmh2ahpTluxjuZfaTBlhyQFavwlIJK6npvetxOE3zh240/iF7E2svwoGZ0k79rinCiz9sT8IOX6PUjUOLL90pyuaEL33/TJT95kUge1StNse0T5+XkWsu1JdwzL/v+eTFwo1E6HpxTm9 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(346002)(39860400002)(396003)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(83380400001)(6666004)(478600001)(2616005)(6506007)(6486002)(26005)(6916009)(316002)(66946007)(66476007)(66556008)(107886003)(6512007)(38100700002)(8936002)(4326008)(8676002)(44832011)(5660300002)(4744005)(2906002)(41300700001)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hJXzCk9kThHSlTuMS7hV6G/whwU/7QyIyMbKR8xv/OGtrVy8BwWYkYWn7sbZ6HyFrjYGW6OBqDj3ptiKqAVNLEqNWV2/UBDs1cMcTkzm/FomuWaHH48FzZb4meQTIbudHlDQ8YqcYynX/uBboJr7I3SYl4CiftyyCZ3IqYxBUuuIDYv9FpXJKeQcC4RX9aYovXGrNHlcFLP/DJBQyAGQJ/c83pBWeJt8G/4snpZwHlP82lSW7R6FKmShLFDsCT9PoWNel9lg9LKX67iqKHC3tuNuQlZTzlr6Z5xTh/6iVT4x6PyfNBl2orqhWPoHV8rTmc/rnJ0aWxmf2Gaw0KtZZS48Gvpj2Piix9KpaUx2NUJvzQYRUhA+2yjeyJuJzr/GrC4VtPj8F0nw+oPak3wMj2TU7vMqMdE8MM2vouWbtnFFzO7UnEhNQNkMiK29v/1tcn5UuCjakld1oJ98xzvcFe5o09NBH29N7Tjap3fXlcG0tWvE8TKMzn2zvMWhI++5gX4zLRzzHp9IV4oxFGDbEpOcQVP+X7i7a1PyPeltuG/+0wEW/fJAFhhBQ1svI+mAo4fxHzGySd9nWV5erCYxKDS2FotJnDQ51/UJqUsFWK1WRmtSHDb9jStRfNiptQsG3qDWiHv2u8nF5hKcymrtuosmhLPIFy2Ds505zSercHU8GNYaGGq9/BQR2GxGxbIx+y0eXFSXyN3cNI+DaD56G8YxCRCVs8VYNXxdBSwryJpS03chPgZsJA/eNsBSryAbwDmGZ4c+kcUeEQQQdloky13gEIkGpS3TCBa6JosB3XHWjE9AtlmJKbCllHQRr7uVA27IEo0IpZS0Uifb91IFSH4z8FrSXN3dTCxpYkKc5b8rO9s+FFecXEiI1h2piI4t6aqnu8vxjXcoma+WFcfWE4WKxiUPRhYjEFw2pOZiw7F9sb5HNnjZSWDeVYfmiLXkE5SyY+xB2jJSlklWwLMbsJYCYw/GDAamqWAy5ulj54VFsHNm8O2yNMrvO7xBwsMZEuEbXG+lcWj4eYdzU1l2vOZ1n6o9KOMbQXl+XjvRyk34jltKScJ8o7v2Z+pdLhqqYg7v/vkNVpZNwY/1EFKYZt+f6n4SULfxP3FDy/koV4Fm87aORePW4s1tiE3nIbYyUBgm0nua2UecEp1WunVOP6UpSn1tujZcOJt5Ps6PrN5bK433+7PrxiUKN2lCHj+knpk0ek1vMUMM5eCgHHWuPi2HedoI0l8CVEbxCf1zGW3qMtD4R7aj8zdWtDKS5KXCUM78LdWpzJPjpeLj0iTY0VuYUgpGsYpOPpnqnqWpGkUcsgHdDh5Ro5d16ZaRXPHWvFmGWsKvpn5xogQE1GD9Ijfi5W65IqHZSnxgr8wiroxUS/BNqL51fw1WtmZKmwWZFg0MXh/VvKHsf0zf8TlImbjNzkjrSDcgB3pOmUt5vEZg7AtOcWVJFnordGRbNiYWLj9TCgFp0YSnFkc04ApLdwg4dU6mOUoFmo+nBkkCz6ARkMdoqot9dh4YVFPujJeUxBIbC/eAYpYgjLk9fadeCWtUCRU6r6vH2wFOVUObHbggkzwWGizHLN28UKsRgeWgqltzfGPQfxYNDEeQie1opA== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c16fab4-9e24-45de-49ef-08dbea781b31 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:56:17.8171 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ak3ZIarHhfMHVFCkGLxQixDEX937EwjV8FTGxllCW0S2qt+iGGS3/V1kmO2N0cRq4fzVa3VYX2L84IzF451rKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9667 In some cases, the address entry doesn't need to be freed. This patch dups an entry into the free_list to separate removing an address from freeing an entry, so that the refcount of address entry can be added later. Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index a608166af121..99ade938eef5 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -312,10 +312,18 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) goto out; } - list_move(&match->list, &free_list); + entry = kmemdup(match, sizeof(*match), GFP_ATOMIC); + if (!entry) { + err = -ENOMEM; + goto out; + } + list_add(&entry->list, &free_list); mptcp_pm_remove_addrs(msk, &free_list); + list_del_rcu(&match->list); + kfree(match); + release_sock(sk); list_for_each_entry_safe(match, entry, &free_list, list) { From patchwork Tue Nov 21 09:52:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462726 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2088.outbound.protection.outlook.com [40.107.21.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 651F43C081 for ; Tue, 21 Nov 2023 09:56:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="uaJgyx0X" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iWE41ukBYmu2WJoF0ERHqLowsgnjSWZNZi1V4RTxJTWzF7mmCplVj5+LF7zzjHB55LdOW9Nc6FYklAMGx4Xrbr2nbftbTlwQymsS1Q/GKO8AMlMwkHguXDiHt7uLR81rEhF3863JRRRHj+K4LEqBdOm1Z7fXEsKf/Zi1xZJBY+N5mIdzcOGIkVSyjBP0PqN2WlI+g/HWNaNe1Lxz9cw3/aG6FvrBzXkg+FPi42o0c1hkj9C5poPLW7Ddqr8JJtKp5bsfFhkoDY6DU4aEO2UI6GTVtbXnYhjaoCEJ6y5CDXqyBXfD/8knl8qQQdNutaZYyxdXC3Qzkc7KQZXwLnbfxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ETTaZDMPn8hsI404iQqYPKTi3rlDeB9A11y9pe2W5Wg=; b=lxuVrWMeVY3f811V+LyBHDJa8IeFFuW/5j+JzmMEt5tt0BNNn5JdMQe3K3Kddg4Rs3LyCzczwyCaXICqtfxjVpEUAlo68FlvtBkEdM/rMC/ArPVu6dO3dHqHYioMyBXxx+FOiDjnvg8jAucmeif2/c2YJYz+9gYZsMNs8J/Z7ZEJZfZPo5t6KRwaNQG3kAw9dUvzDxRwYloSnqDUIcaXTzi/TZNjTAWGEMDHXkxO0Se78tA5DW4iGCSz9TpuCFPSryJhnWJJ7mSpg9pW5nTD+7RjvmCf/l6NBIcN27HVEkiEkeQxxUwDOxlKRzoYFcO4GsLUGmZNm5WPzNGucdfS+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ETTaZDMPn8hsI404iQqYPKTi3rlDeB9A11y9pe2W5Wg=; b=uaJgyx0X7k6/ljNi2Gz2THxW48PyRO0UH6pDJJT9uEerZmXvk4c9TSnI+jVHnB9ykuzaaQEAKnApxy2dww87h1SYnx6VaN2mYj7hJq72DX/4Sfj03B0fgA5ceKcccDRkuy0xgcKO5QxHZrgODIaJZAcmlzWHTNaPy6Y6menWRlRCufyLgpdBYEWckncxnV09hozym7C4cwYpsacTBvNshdByxIHjoz78UDblEsqWryQQ/ZixcEMCxyNRpffyOffBMT7xIb7fMvPt/a2nKinU6+ZlEloIfcEXOKIS98ob/BniHJLdGgwiaffrM8mPuGEa2MgbqunXwD1JCpAflOtwjw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by PAXPR04MB9667.eurprd04.prod.outlook.com (2603:10a6:102:242::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.16; Tue, 21 Nov 2023 09:56:24 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:56:24 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 27/28] mptcp: add userspace pm addr entry refcount Date: Tue, 21 Nov 2023 17:52:50 +0800 Message-Id: <8dfc9059a1399626bba86005d236c618939fa320.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SG2PR02CA0087.apcprd02.prod.outlook.com (2603:1096:4:90::27) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|PAXPR04MB9667:EE_ X-MS-Office365-Filtering-Correlation-Id: 168491fa-40c8-46aa-0382-08dbea781f3c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 56v4HnR3z5usn1VuDNiNx5+pMMdPm0t+YrbK9dbVUErwnbYL6vgRq2PSmiFGqyzTdmFDJTiOB9jVoKHW5/ma3UvXH9tey/T1bNuCAumcLhsHJszvWKp7cdT7fNvFJOzdMkCZpQJ+tzvA49MuX28cvhsWZ6VD36UZ1aWNJVGQ+QWc9Y4vSoXkgveVwdtQdnI+GxYxEOoCVstdYDQvQKGJCOrmmTS9vWCQ9oqHGobIQSQNmPEihHNXWQ9ieG00psSgxiaV/i/plXGgDHF9S3gl6we+fAbp68qAqhJBCTR+sXw3SoovbXJpuVb4dQ8sN073dBaizsV9/ZJQsVxNKX4z+8xtzD5VkKjaM9u5EMHO5wvJrjM4gWv8ebxZvQxMNyoedqfPAb2RmdFSggJEDnnrfK8O3598Gqa+2UthhpwUQkrtbWTIBK9BRfWE3cpChU/XXSDMmEhJZ08i8FukskHkwtSfHpXFFu/NOnuSfrIfzNySXGnsVcNxWbqrMNAu7R2Y7cvjXMxV8QdHdpoZqoebDBdRuokcCM6HuJccJG+A5as= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(346002)(39860400002)(396003)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(83380400001)(6666004)(478600001)(2616005)(6506007)(966005)(6486002)(26005)(6916009)(316002)(66946007)(66476007)(66556008)(107886003)(6512007)(38100700002)(8936002)(4326008)(8676002)(44832011)(5660300002)(2906002)(41300700001)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GmA6BaYytRQl+DW98nwlTW7vlwQy7RAHo4lC8N2t+GQU2GP4fLZAbbfD2Sumf5tloGnGxyXyJvPjrXJEijpYqAHumxMU3LAHIiQdssMfu44O255jMmwE8oyFYuek12m3jxW0BEHBUarQY4qh2kyJUxGfvCe8FCJriSorUyeF6lwCWqOtJcHfxvDEFbIVo7kMNYyBlwMf8XT1ozs8LWbZBKnVkmUpg8j6g7VAv+jcWz8XctWsCY/giT/3hIddM401QA4i8c0mpTYthMm5G5e/bbcsqCure/yGk4ALiWPCjoZ2DhC0DI66tfP1LzUZycq8xX9saVUQ1W5SCVD3nAfG0ojTgT723b0o783uRB9OulUXoChnfbaSvmTXQ4dP0pS6cGMNKHa2Aus8zkTwSa7bKnuX5NZkZqbSFuZ/G32Fy3rwrV/kL1BrMK0WW7NJJ7ecNWRI6Jed5YBcBzm8I96SzCs8fuBzyj0nBRG8fuPiNUfm+YBTLJ35+euVyF5yFEVANHWDLpgEEt8glK9yFY3FAFAlTcwyFaGXpZqbd8a4EjKw1AeBbVTuMSMjohm5IIxDBEJimqJLxZwRZk4QkvOESXkp5uyCZXI+H70cIObZinw/I59BcHz2njoAQJEPHsmMuU3BzuMCl2mj66Vn/eEHOAa/XX2Bk48OgPJntTkpBpyCFzbcJ1iYesy0qV0EkCpcgMx7aoCWMEWCA2G8TOY47bqFOo8nAg+VEXrcLZGbe6ENmtZTILpdmzO/nxn2XU2PHxdUQXlVDl6L+HMbfxbIW7oWIbsUpVpY34vQT6IwvlXNmvp9Wc5lD7DH4YCBLNk0D3v0If/KrBvcEXu3ieYKsWDHhY771Ix+dKj6tcw5hvCXrCrGTvNLkfVIobKLtwvfxEs2Sk8Lf6mA1zwJXnOFBYO4xiOUNWTDNi8B0aUjW0FSGdgpuHVIGeeL20WOhF5L6azk2S985Uvj4JMbw46D20Z4loc6G5p7JEnyP7YriPdCwary782XNMMacyfAnaOmIx7XMbsxJQ7vJGHbCkcNIMsr+mKzPUOb1dLgD4YWugujfYY3f4UUzbSK3WvpAFYi7u4XpZAUFE/8W4gbLgZzfizbyiS84Ei1w4IHB8/tJG0+JzkWVOh9yiOWrWIaBTtlBfyAdbQT8pWT7GO0o9GcA43ZHXe59Kr3ZhETHhxFGhi4NHcGsipyF4StO0JfodLwXWRXVfVfjOT8hZnaWeTY70DFoChQq+gqxGO3Wx0m8yBvtxlPq6mH5aHa8Eqc/NrLqFiTNDgQVtGUR5izfX2cjhHVQa00xYkowlW+9CTxu5Hu5XXm7sQ3H4cqL+qA0ww2YlUh8f8gBZmIZNXj5xEl197T6KQY9NPE3WACutMR5bqb4954B1LXN13Zloljn9Jns1pnayqWs2892zC10LeeVp8BnOrly1DCx3CX2SbO9WKznB4phzwKiBHFwfbp/9eJpvmE7JC9+pSiSZvbK1AnVrm30DSdydf9GAMGaRKRsq+lkkDkY1jsXbmGLArt9vfv4GhU46TFQskrTDPaD0JcR+MXx294RSZfpSIsQZVp1SML6b6mzLpjPIro0jMf+TncDB91KZBN+8nqI6p6BjRFJA== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 168491fa-40c8-46aa-0382-08dbea781f3c X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:56:24.6555 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FY6G0bobFMrdQK7Rx2bHqnG0iwC5hvpBZmv73zBQvAwznb3ZHE3liuktNa8OE/97HyuoUyJR+8/hB3I7yD/a4A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9667 This patch adds the refcount of addree entry in userspace PM. Add a new counter 'refcnt' in struct mptcp_pm_addr_entry, initiated to 1. Increase this counter when an address is announced or a subflow is created in mptcp_pm_nl_announce_doit() and mptcp_pm_nl_subflow_create_doit(). And decrease it when an address is removed or a subflow is closed in mptcp_pm_nl_remove_doit() and mptcp_userspace_pm_delete_local_addr(). If the counter reaches to 1, free this entry. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/403 Fixes: 24430f8bf516 ("mptcp: add address into userspace pm list") Signed-off-by: Geliang Tang --- net/mptcp/pm_userspace.c | 33 +++++++++++++++++++++++---------- net/mptcp/protocol.h | 2 ++ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/net/mptcp/pm_userspace.c b/net/mptcp/pm_userspace.c index 99ade938eef5..43a1217503ea 100644 --- a/net/mptcp/pm_userspace.c +++ b/net/mptcp/pm_userspace.c @@ -85,6 +85,7 @@ static int mptcp_userspace_pm_append_new_local_addr(struct mptcp_sock *msk, __set_bit(e->addr.id, pernet->id_bitmap); list_add_tail_rcu(&e->list, &msk->pm.userspace_pm_local_addr_list); msk->pm.local_addr_used++; + refcount_set(&e->refcnt, 1); ret = e->addr.id; goto append_err; } @@ -110,12 +111,11 @@ static int mptcp_userspace_pm_delete_local_addr(struct mptcp_sock *msk, entry = mptcp_userspace_pm_get_entry(msk, &addr->addr, false, false); if (entry) { - /* TODO: a refcount is needed because the entry can - * be used multiple times (e.g. fullmesh mode). - */ - list_del_rcu(&entry->list); - kfree(entry); - msk->pm.local_addr_used--; + if (!refcount_dec_not_one(&entry->refcnt)) { + list_del_rcu(&entry->list); + kfree(entry); + msk->pm.local_addr_used--; + } return 0; } @@ -216,6 +216,11 @@ int mptcp_pm_nl_announce_doit(struct sk_buff *skb, struct genl_info *info) spin_lock_bh(&msk->pm.lock); if (mptcp_pm_alloc_anno_list(msk, &addr_val.addr)) { + struct mptcp_pm_addr_entry *entry; + + entry = mptcp_userspace_pm_get_entry(msk, &addr_val.addr, false, false); + if (entry && !refcount_inc_not_zero(&entry->refcnt)) + pr_debug("userspace pm uninitialized entry"); msk->pm.add_addr_signaled++; mptcp_pm_announce_addr(msk, &addr_val.addr, false); mptcp_pm_nl_addr_send_ack(msk); @@ -321,8 +326,10 @@ int mptcp_pm_nl_remove_doit(struct sk_buff *skb, struct genl_info *info) mptcp_pm_remove_addrs(msk, &free_list); - list_del_rcu(&match->list); - kfree(match); + if (!refcount_dec_not_one(&match->refcnt)) { + list_del_rcu(&match->list); + kfree(match); + } release_sock(sk); @@ -408,10 +415,16 @@ int mptcp_pm_nl_subflow_create_doit(struct sk_buff *skb, struct genl_info *info) release_sock(sk); spin_lock_bh(&msk->pm.lock); - if (err) + if (err) { mptcp_userspace_pm_delete_local_addr(msk, &local); - else + } else { + struct mptcp_pm_addr_entry *entry; + + entry = mptcp_userspace_pm_get_entry(msk, &addr_l, false, false); + if (entry && !refcount_inc_not_zero(&entry->refcnt)) + pr_debug("userspace pm uninitialized entry"); msk->pm.subflows++; + } spin_unlock_bh(&msk->pm.lock); create_err: diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index d40e29419c04..3fccee77b739 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -8,6 +8,7 @@ #define __MPTCP_PROTOCOL_H #include +#include #include #include #include @@ -244,6 +245,7 @@ struct mptcp_pm_addr_entry { u8 flags; int ifindex; struct socket *lsk; + refcount_t refcnt; }; struct mptcp_data_frag { From patchwork Tue Nov 21 09:52:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13462738 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2045.outbound.protection.outlook.com [40.107.21.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9178AC8C0 for ; Tue, 21 Nov 2023 09:56:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="QrOVVWDM" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xg/hCvfAh1mjkxHsD7XtqMaWM1FISsLGRaGUV0TE4STAmtnDVZgRk1y9lU0bL9fwzke4J45SV12yq3degiZ3lqvp7sMG5qG6U5Zyb6pO2cGBBEoD3UsI60InmkZNhFohp7lMdToLX8j0rmufoCTmHTHjgLf0zm9lSPWh7AfXprAI8/8c8YdMeRg1zMR9cshA+jIfYxhLSZzxZiKMdkNxz6nA9wubkY3SQkrMju9f5wKR0UIJ3jUNM6bYr2IA6IRGG67wjtOdm7pEi1PvmN2FGQyUa2p2rZ9zz3iKP6eWREwbp7pm7msaGDVjKmxNxl3pqSepFLnLdesOnL5UnM2H1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ty/FXllXKtTuaHGU2kYiI+FuaBwPLjU6GvuTeCv9M3Q=; b=PyNF94mTFlMK2QCLu1/dPRUMkfyLN/ALIK99vyr1FykMr9zZ90d5IlyILutpw8iw2EMoJzxCbZXSKat7jccI5ergrF413L88fdjM1tISm9hVWUfAPmQkpsNYu6KlVsNJPM/cXjNIkSGz3iqEBgp1tn6RM4AnGkXSXomDhHrKxgdmhVshUoTBLBWyLqcqnoWQhG1xrG7Ttv78fNQAuy2SbE/WpxvLqj92xRLqBDuPw3zklW3SX2Lyq6d3sK+MG5s+ONycAVE6E58H/NfWBQoUIO34zCjtpauT1hdX4xaqxjIEU9T3dPXybo1hdgLY0JMoMGwEQHjLkGpzy6sjtGdTQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ty/FXllXKtTuaHGU2kYiI+FuaBwPLjU6GvuTeCv9M3Q=; b=QrOVVWDM8zDY9gxyXKsCj22wScosJL0PD7iUEgspRBV7zD2L7iZBGzA7+heJvIwmJwpUr8t2iqHt8Hp1qUea0gCmoqdf9brD/lBadNcWMm2jjsmjzQm6boj7p/fYn1pFN3OlQ4xGXOVGnxdlTpBiFa32iKX0BL31pESxJV7sQqBzBhzmQDUuC2S+/n9+1QGflnWJts70fRltHHqaLxwSZHaGKWRk73hQ0lZnkbwqexE/y1SKekpfXMKAwy5mYrXTOUyCA53OcikN7x8ojj4ZYbOI63FT+dUNzNH5dnLmqdVKu7yA85CSym9lGcc19cjw4b9TDldGV8NM3LOSgRudNg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) by PAXPR04MB9667.eurprd04.prod.outlook.com (2603:10a6:102:242::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.16; Tue, 21 Nov 2023 09:56:30 +0000 Received: from HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321]) by HE1PR0402MB3497.eurprd04.prod.outlook.com ([fe80::7102:259:f268:5321%7]) with mapi id 15.20.7025.015; Tue, 21 Nov 2023 09:56:30 +0000 From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v12 28/28] selftests: mptcp: rm userspace addr with random order Date: Tue, 21 Nov 2023 17:52:51 +0800 Message-Id: <52ad9a426bb36948608535adbcd6b1074bf5c94d.1700560046.git.geliang.tang@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: X-ClientProxiedBy: SG2PR02CA0096.apcprd02.prod.outlook.com (2603:1096:4:90::36) To HE1PR0402MB3497.eurprd04.prod.outlook.com (2603:10a6:7:83::14) Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: HE1PR0402MB3497:EE_|PAXPR04MB9667:EE_ X-MS-Office365-Filtering-Correlation-Id: 98f22e7b-0be2-4435-60d7-08dbea7822c8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6yWh1bflmqmj4GwumbS5aa0HQmzEJZTQ2bqmT7pUaShTlXgdxaBn8uyf0JWbB4CpzTSr97Jjf6BQDshkuEgMfUdPvCPaELz9IJb0AskA7KcR6prQ+zUiDd0sKTCFbMHRhmjoxdCp32H/pmXigI84Ah7SUfomT+HNJ4Hba6sDNH8BZzSwfq/TYbEJs/VGDIPjzka8TrlgamRF2bDYMfBowBPqEo+uYL88YG6VY7pqKybXPknNlRDIAwiO506KVkutMdgz1xZzSb4+3pJNgDg52TXv0DBu2UDNIz8WqpLPghZ4PEAkzW0MZ77la61O/6s1o9Tt1CYfBshLH7ihlkhiiLHYik6Pezd2gmUf3f0NJdLaKoOBVdNmnqfekFkikzjyicVCH91Q4eY2Y1B9DyQiveMrMWqw1ZqWkwBSYZkbQykxyy5Au8cXtGk5ajKA1SrvnMHcjh2yFwdre/JSJPs723NOvDgmGbNXU/jAIT8Q3lRQ2jTwg8D/eHZN6nmYE2JYwH7CqojfEzYmTkAUeo4O3pxUFODjVlMeTTYVW1l0p/d86al5aQ5gbEXwfX0uwEvO X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HE1PR0402MB3497.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366004)(136003)(376002)(346002)(39860400002)(396003)(230922051799003)(1800799012)(451199024)(186009)(64100799003)(83380400001)(6666004)(478600001)(2616005)(6506007)(6486002)(26005)(6916009)(316002)(66946007)(66476007)(66556008)(107886003)(6512007)(38100700002)(8936002)(4326008)(8676002)(44832011)(5660300002)(2906002)(41300700001)(86362001)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xQ8jO+a/JCEh8oGLd48EY/6n0PrfiloWJUGXyLVZpggyESXjoulK8mwFAV3E5dFrAx8VvyQhhw8qDhmYg4Kz2gxp/iWZvPn6fqlVEzM3fgDMg4yCgsphUPS2P8Qix8/gZ9olxVwsL505Y1VHnK4ubP1o0c3NyWAZaMNuZMMSKAuzBGAtCmM7JZCs4HbMso0qkhhmRuiK3jatYWGCn6T6jU3nj/tI6mqp289gPb3thERgTf+zU4yfBVKgkGhUWQUEqa691m5fvo8EsTdb0lGp3zWchVH6rTUBtDFDKXWycc8btVobFJjU9S8yMfC9tC6CePDjxa8TxAwR2uIlF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e64MvPprKGxCBUKWvYOQKMP2yRY0bedImgbnPRDcL5/wjugnMqgtV1K8o7+Q4HSTKP1qumct8cwRE/QCg/kmo0HntMR//Fx2q6diG8mcBUUxXc4RjmNPYTZyjmI8g/1yUGrR0WIrGzV29n6uBL7z4E7tUoWdPWHCk+fjCk/UYcdEOgxzd3br62q80IJEziz7LvoZwl3zACGdQ== X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 98f22e7b-0be2-4435-60d7-08dbea7822c8 X-MS-Exchange-CrossTenant-AuthSource: HE1PR0402MB3497.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 09:56:30.5585 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +degy4NuvaEgrma/qN01XJBxCHvSXrfKisUz2yfzmmqmt8OWXixSJP5rqZd+0dvNuf8/Qqm6BfUtEYFU6yTVDg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB9667 Previously, when deleting a userspace address and subflow, it was necessary to follow the current order of deleting the address and then deleting the subflow. With this series of changes, addresses and subflows can be deleted in any order. This patch uses random numbers to add this type of tests. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh index 1145e5f98977..68cf11ad75e4 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3412,8 +3412,13 @@ userspace_tests() chk_mptcp_info subflows 1 subflows 1 chk_subflows_total 2 2 chk_mptcp_info add_addr_signal 1 add_addr_accepted 1 - userspace_pm_rm_addr $ns1 10 - userspace_pm_rm_sf $ns1 "::ffff:10.0.2.1" $SUB_ESTABLISHED + local rm_addr="userspace_pm_rm_addr $ns1 10" + local rm_sf="userspace_pm_rm_sf $ns1 ::ffff:10.0.2.1 $SUB_ESTABLISHED" + if [ $((RANDOM%2)) -eq 0 ]; then + $($rm_addr); $($rm_sf) + else + $($rm_sf); $($rm_addr) + fi chk_rm_nr 1 1 invert chk_mptcp_info subflows 0 subflows 0 chk_subflows_total 1 1