From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A4AC0A0A0E for ; Mon, 10 May 2021 18:25:19 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9BABF40140; Mon, 10 May 2021 18:25:19 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2045.outbound.protection.outlook.com [40.107.236.45]) by mails.dpdk.org (Postfix) with ESMTP id 2C9FE4003E for ; Mon, 10 May 2021 18:25:18 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=apq0wBNWCuYi98nGCjyqwY885cnf7roL9u1jwt4xRyApbVxkKi1SPvPEjgKV2az+CD9YMmyM+BTvKpih6qmD7ISsM9t4p11MgJF5JA+u1JnR4XsTK/K2aIplTv4pJAF1D9bL43Zbd6D/C8HoQLqz4XPTiofStfvxVRAMPm0JJMGCvgdPxAwEE/0MSmYlx/43//0RF5/E9Y9GzRpdmDo8umiAIG36JxwXWOErqisUyaHs9yzyvbE8LbzCsY2iLb857EBDhAPLlOCnLlAFLp4lYerqO1jFdt6ZCLHu0cB8YLK8Dj9sNkNtxROokR/8uH9g18fF7SrzZ7qv7jcBM6fx2Q== 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-SenderADCheck; bh=cM+uPT5aTAQkcYuS8M7MsXsRQU9mg9EDGO6MUuSJr7k=; b=NA/FoCyNCUCDKG706/9Ik4xFAhenuIxefSo/FmBoWrWZwwD0YqK2jyXkjlN3dhm52F4+2CDqlypPb5ik9JhAtHv2K1HgPhlKU8JzGmEBb/TM3HpO/3zM5ZvolDYhX/3f3etLP77BNz7J6cCHB0LbN8YrdM8/wqkKVDIXjmhESGMj/mgvtZnYKmzeYXxk9XZLp1ttX5WGtqPccrxI7x0/sF7YHAgY9Vo46BTw5M8K00dce3TH+M1+NOXAQbw2MBYJk5wSEkSQfVmTjT77YjD2GNDq/LNWpqL/2dZGpegQzQn01qN4G0kyC8ZJkXhVtrOYpS4oGr2v6KMAZp4aK79Wsw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=huawei.com smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cM+uPT5aTAQkcYuS8M7MsXsRQU9mg9EDGO6MUuSJr7k=; b=iC1A7o5mOnL8toR9XSmx+LQ6OPLzG08nOY1ve9VdZABshYPgwUGLRf4d6+/BBKw/Moy2QHCoKabQoFpTGD5LVMdRW8pParReDzXWSgAt8pOkDYn3S0/jEHLTDZeRpcvw5qChIR+S7XoIzakDZUcK7K5+UmvHbUxD5FjL5f7/oKbn9foiLlW2vE82T7bkR4w/FJsfHOvrYONscuFVtgU+qzns0igDfHgBgux//+UTTHyk14gw4KMPbHPH3JTOoghtOeJSJmq3/IXZDHcgigIXv7WnMxWWuYiJx/9PjaZ43n3NO9CtknewZGT1g9z2MnWxzuA1EXy5pRltypbaOIt4Wg== Received: from BN0PR02CA0011.namprd02.prod.outlook.com (2603:10b6:408:e4::16) by DM6PR12MB5520.namprd12.prod.outlook.com (2603:10b6:5:208::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.31; Mon, 10 May 2021 16:25:17 +0000 Received: from BN8NAM11FT056.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e4:cafe::f5) by BN0PR02CA0011.outlook.office365.com (2603:10b6:408:e4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.25 via Frontend Transport; Mon, 10 May 2021 16:25:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; huawei.com; dkim=none (message not signed) header.d=none;huawei.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by BN8NAM11FT056.mail.protection.outlook.com (10.13.177.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4108.25 via Frontend Transport; Mon, 10 May 2021 16:25:16 +0000 Received: from nvidia.com (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 10 May 2021 16:25:14 +0000 From: Xueming Li To: Chengchang Tang CC: Luca Boccassi , Min Hu , dpdk stable Date: Tue, 11 May 2021 00:02:50 +0800 Message-ID: <20210510160258.30982-221-xuemingl@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210510160258.30982-1-xuemingl@nvidia.com> References: <20210510160258.30982-1-xuemingl@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4abb82be-9436-47f2-f37c-08d913d03228 X-MS-TrafficTypeDiagnostic: DM6PR12MB5520: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: f874a11GSjAl5/W5HdKHJD7jv4JA7SPaLLJiy07kLh6eqvs8ZMBoi76Z5Fqg7chOKMHds0x7tn28/svTsWOvvZBPfTT9v13HSVTFkN7GoiJuJMFuU2ERbYUV+BVqMu5JLCXAgLgx6toN5YBKFcthcY8h13HhLijBIxoyvZmR3Ro9zJSYnDutwjnqha9lnk816W1HUim4Xh2i5MajWUMtW+L/zABawv8U6qemlTV9ZiZUSzW/hp3wTeuRa5NeIN+qW7Hw9UEhnkFCC3/AFR96lXIRG0SlGjDlnW6+NUWYPszX5kJ8AmdPZgMCxwTwaN/CUIqDbvtDy7gzpCRm4RoYz5ZXitOt8Uxd4VW8OYVWKmP31pfGhiPwnMafZhD1fpkza+R0LLFzd6MgHorS0klbILbcizRiYI0X2BjQCYUDgh+8WN8EdcIMKi70tO9Hfws7CmScDtuV0MdHDvGIJYT/l6nhYjCOb5qyyJBAZUwb3I0ZletAXJIOov8hwOxrEHjGm7L+z1//p9fhNWQRPPgVR2wpiTEuAlznDO8ox/zFN10PbqaAa7IYiQm5GJVW3TdgVqtrOGjp5/0eZyE73/rJDIwjc2v4Vi7LJm0hSiN2MY3iiIm/R+LlRy9vz3bJGt6qkKGcjfU3SjunlzqP8y+F/JkKQPllIXtRtgA+W2EBtYBfP5In663dcouCV2NkHA2yHtCGeKkXvtm3KtDyCNJ+rqvIxynSVu8R6VhBpVEu6CyCZWyMfTjEVeiD8jj5y0CwH6oDUjuDo6/gz7brzJJoQg== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(376002)(396003)(346002)(39860400002)(136003)(46966006)(36840700001)(336012)(47076005)(82310400003)(6286002)(478600001)(8936002)(8676002)(26005)(83380400001)(55016002)(36906005)(53546011)(36756003)(86362001)(7696005)(70586007)(186003)(4326008)(70206006)(316002)(1076003)(36860700001)(2616005)(6916009)(426003)(6666004)(356005)(82740400003)(7636003)(2906002)(5660300002)(16526019)(54906003)(966005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2021 16:25:16.3466 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4abb82be-9436-47f2-f37c-08d913d03228 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT056.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB5520 Subject: [dpdk-stable] patch 'net/bonding: fix adding itself as its slave' has been queued to stable release 20.11.2 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to stable release 20.11.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/12/21. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/steevenlee/dpdk This queued commit can be viewed at: https://github.com/steevenlee/dpdk/commit/9231460d33ce386ad19d965a60b05630191af337 Thanks. Xueming Li --- >From 9231460d33ce386ad19d965a60b05630191af337 Mon Sep 17 00:00:00 2001 From: Chengchang Tang Date: Thu, 15 Apr 2021 15:09:54 +0800 Subject: [PATCH] net/bonding: fix adding itself as its slave Cc: Luca Boccassi [ upstream commit 324d6577ba678c00673427df681bf2debec1db8d ] Adding the bond device as its own slave should be forbidden. This will cause a recursive endless loop in many subsequent operations, and eventually lead to coredump. This problem was found in testpmd, the related logs are as follows: testpmd> create bonded device 1 0 Created new bonded device net_bonding_testpmd_0 on (port 4). testpmd> add bonding slave 4 4 Segmentation fault (core dumped) The call stack is as follows: 0x000000000064eb90 in rte_eth_dev_info_get () 0x00000000006df4b4 in bond_ethdev_info () 0x000000000064eb90 in rte_eth_dev_info_get () 0x00000000006df4b4 in bond_ethdev_info () 0x000000000064eb90 in rte_eth_dev_info_get () 0x0000000000564e58 in eth_dev_info_get_print_err () 0x000000000055e8a4 in init_port_config () 0x000000000052730c in cmd_add_bonding_slave_parsed () 0x0000000000646f60 in cmdline_parse () 0x0000000000645e08 in cmdline_valid_buffer () 0x000000000064956c in rdline_char_in () 0x0000000000645ee0 in cmdline_in () 0x00000000006460a4 in cmdline_interact () 0x0000000000531904 in prompt () 0x000000000051cca8 in main () Fixes: 2efb58cbab6e ("bond: new link bonding library") Signed-off-by: Chengchang Tang Signed-off-by: Min Hu (Connor) --- drivers/net/bonding/eth_bond_private.h | 2 +- drivers/net/bonding/rte_eth_bond_api.c | 26 +++++++++++++++++--------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/net/bonding/eth_bond_private.h b/drivers/net/bonding/eth_bond_private.h index 8f198bd50e..5c7a55291c 100644 --- a/drivers/net/bonding/eth_bond_private.h +++ b/drivers/net/bonding/eth_bond_private.h @@ -212,7 +212,7 @@ int valid_bonded_port_id(uint16_t port_id); int -valid_slave_port_id(uint16_t port_id, uint8_t mode); +valid_slave_port_id(struct bond_dev_private *internals, uint16_t port_id); void deactivate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id); diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c index 55c8e3167c..44775f61e5 100644 --- a/drivers/net/bonding/rte_eth_bond_api.c +++ b/drivers/net/bonding/rte_eth_bond_api.c @@ -56,19 +56,25 @@ check_for_master_bonded_ethdev(const struct rte_eth_dev *eth_dev) } int -valid_slave_port_id(uint16_t port_id, uint8_t mode) +valid_slave_port_id(struct bond_dev_private *internals, uint16_t slave_port_id) { - RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -1); + RTE_ETH_VALID_PORTID_OR_ERR_RET(slave_port_id, -1); - /* Verify that port_id refers to a non bonded port */ - if (check_for_bonded_ethdev(&rte_eth_devices[port_id]) == 0 && - mode == BONDING_MODE_8023AD) { + /* Verify that slave_port_id refers to a non bonded port */ + if (check_for_bonded_ethdev(&rte_eth_devices[slave_port_id]) == 0 && + internals->mode == BONDING_MODE_8023AD) { RTE_BOND_LOG(ERR, "Cannot add slave to bonded device in 802.3ad" " mode as slave is also a bonded device, only " "physical devices can be support in this mode."); return -1; } + if (internals->port_id == slave_port_id) { + RTE_BOND_LOG(ERR, + "Cannot add the bonded device itself as its slave."); + return -1; + } + return 0; } @@ -456,7 +462,7 @@ __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id) bonded_eth_dev = &rte_eth_devices[bonded_port_id]; internals = bonded_eth_dev->data->dev_private; - if (valid_slave_port_id(slave_port_id, internals->mode) != 0) + if (valid_slave_port_id(internals, slave_port_id) != 0) return -1; slave_eth_dev = &rte_eth_devices[slave_port_id]; @@ -605,13 +611,15 @@ rte_eth_bond_slave_add(uint16_t bonded_port_id, uint16_t slave_port_id) int retval; - /* Verify that port id's are valid bonded and slave ports */ if (valid_bonded_port_id(bonded_port_id) != 0) return -1; bonded_eth_dev = &rte_eth_devices[bonded_port_id]; internals = bonded_eth_dev->data->dev_private; + if (valid_slave_port_id(internals, slave_port_id) != 0) + return -1; + rte_spinlock_lock(&internals->lock); retval = __eth_bond_slave_add_lock_free(bonded_port_id, slave_port_id); @@ -635,7 +643,7 @@ __eth_bond_slave_remove_lock_free(uint16_t bonded_port_id, bonded_eth_dev = &rte_eth_devices[bonded_port_id]; internals = bonded_eth_dev->data->dev_private; - if (valid_slave_port_id(slave_port_id, internals->mode) < 0) + if (valid_slave_port_id(internals, slave_port_id) < 0) return -1; /* first remove from active slave list */ @@ -783,7 +791,7 @@ rte_eth_bond_primary_set(uint16_t bonded_port_id, uint16_t slave_port_id) internals = rte_eth_devices[bonded_port_id].data->dev_private; - if (valid_slave_port_id(slave_port_id, internals->mode) != 0) + if (valid_slave_port_id(internals, slave_port_id) != 0) return -1; internals->user_defined_primary_port = 1; -- 2.25.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2021-05-10 23:59:32.280854700 +0800 +++ 0222-net-bonding-fix-adding-itself-as-its-slave.patch 2021-05-10 23:59:26.700000000 +0800 @@ -1 +1 @@ -From 324d6577ba678c00673427df681bf2debec1db8d Mon Sep 17 00:00:00 2001 +From 9231460d33ce386ad19d965a60b05630191af337 Mon Sep 17 00:00:00 2001 @@ -4,0 +5,3 @@ +Cc: Luca Boccassi + +[ upstream commit 324d6577ba678c00673427df681bf2debec1db8d ] @@ -34 +36,0 @@ -Cc: stable@dpdk.org @@ -44 +46 @@ -index 75fb8dc02e..fc179a2732 100644 +index 8f198bd50e..5c7a55291c 100644 @@ -57 +59 @@ -index 17e6ff8b90..eb8d15d160 100644 +index 55c8e3167c..44775f61e5 100644