Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/91545/?format=api
https://patches.dpdk.org/api/patches/91545/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/patch/1618470594-64612-1-git-send-email-humin29@huawei.com/", "project": { "id": 1, "url": "https://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<1618470594-64612-1-git-send-email-humin29@huawei.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1618470594-64612-1-git-send-email-humin29@huawei.com", "date": "2021-04-15T07:09:54", "name": "net/bonding: fix add bonded device itself as its slave", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": true, "hash": "61aaf986dd6740dd98933163e385f27b8f3e5e34", "submitter": { "id": 1944, "url": "https://patches.dpdk.org/api/people/1944/?format=api", "name": "humin (Q)", "email": "humin29@huawei.com" }, "delegate": { "id": 319, "url": "https://patches.dpdk.org/api/users/319/?format=api", "username": "fyigit", "first_name": "Ferruh", "last_name": "Yigit", "email": "ferruh.yigit@amd.com" }, "mbox": "https://patches.dpdk.org/project/dpdk/patch/1618470594-64612-1-git-send-email-humin29@huawei.com/mbox/", "series": [ { "id": 16397, "url": "https://patches.dpdk.org/api/series/16397/?format=api", "web_url": "https://patches.dpdk.org/project/dpdk/list/?series=16397", "date": "2021-04-15T07:09:54", "name": "net/bonding: fix add bonded device itself as its slave", "version": 1, "mbox": "https://patches.dpdk.org/series/16397/mbox/" } ], "comments": "https://patches.dpdk.org/api/patches/91545/comments/", "check": "warning", "checks": "https://patches.dpdk.org/api/patches/91545/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from mails.dpdk.org (mails.dpdk.org [217.70.189.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id BE157A0A0C;\n\tThu, 15 Apr 2021 09:09:49 +0200 (CEST)", "from [217.70.189.124] (localhost [127.0.0.1])\n\tby mails.dpdk.org (Postfix) with ESMTP id A67B9162079;\n\tThu, 15 Apr 2021 09:09:49 +0200 (CEST)", "from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35])\n by mails.dpdk.org (Postfix) with ESMTP id A047416206F\n for <dev@dpdk.org>; Thu, 15 Apr 2021 09:09:48 +0200 (CEST)", "from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59])\n by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4FLVlj1KXQz9y40;\n Thu, 15 Apr 2021 15:07:29 +0800 (CST)", "from localhost.localdomain (10.69.192.56) by\n DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id\n 14.3.498.0; Thu, 15 Apr 2021 15:09:39 +0800" ], "From": "\"Min Hu (Connor)\" <humin29@huawei.com>", "To": "<dev@dpdk.org>", "CC": "<ferruh.yigit@intel.com>, <chas3@att.com>, <humin29@huawei.com>", "Date": "Thu, 15 Apr 2021 15:09:54 +0800", "Message-ID": "<1618470594-64612-1-git-send-email-humin29@huawei.com>", "X-Mailer": "git-send-email 2.7.4", "MIME-Version": "1.0", "Content-Type": "text/plain", "X-Originating-IP": "[10.69.192.56]", "X-CFilter-Loop": "Reflected", "Subject": "[dpdk-dev] [PATCH] net/bonding: fix add bonded device itself as its\n slave", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "From: Chengchang Tang <tangchengchang@huawei.com>\n\nAdding the bond device as its own slave should be forbidden. This\nwill cause a recursive endless loop in many subsequent operations,\nand eventually lead to coredump.\n\nThis problem was found in testpmd, the related logs are as follows:\ntestpmd> create bonded device 1 0\nCreated new bonded device net_bonding_testpmd_0 on (port 4).\ntestpmd> add bonding slave 4 4\nSegmentation fault (core dumped)\n\nThe call stack is as follows:\n0x000000000064eb90 in rte_eth_dev_info_get ()\n0x00000000006df4b4 in bond_ethdev_info ()\n0x000000000064eb90 in rte_eth_dev_info_get ()\n0x00000000006df4b4 in bond_ethdev_info ()\n0x000000000064eb90 in rte_eth_dev_info_get ()\n0x0000000000564e58 in eth_dev_info_get_print_err ()\n0x000000000055e8a4 in init_port_config ()\n0x000000000052730c in cmd_add_bonding_slave_parsed ()\n0x0000000000646f60 in cmdline_parse ()\n0x0000000000645e08 in cmdline_valid_buffer ()\n0x000000000064956c in rdline_char_in ()\n0x0000000000645ee0 in cmdline_in ()\n0x00000000006460a4 in cmdline_interact ()\n0x0000000000531904 in prompt ()\n0x000000000051cca8 in main ()\n\nFixes: 2efb58cbab6e (\"bond: new link bonding library\")\nCc: stable@dpdk.org\n\nSigned-off-by: Chengchang Tang <tangchengchang@huawei.com>\nSigned-off-by: Min Hu (Connor) <humin29@huawei.com>\n---\n drivers/net/bonding/eth_bond_private.h | 2 +-\n drivers/net/bonding/rte_eth_bond_api.c | 26 +++++++++++++++++---------\n 2 files changed, 18 insertions(+), 10 deletions(-)", "diff": "diff --git a/drivers/net/bonding/eth_bond_private.h b/drivers/net/bonding/eth_bond_private.h\nindex 75fb8dc..fc179a2 100644\n--- a/drivers/net/bonding/eth_bond_private.h\n+++ b/drivers/net/bonding/eth_bond_private.h\n@@ -212,7 +212,7 @@ int\n valid_bonded_port_id(uint16_t port_id);\n \n int\n-valid_slave_port_id(uint16_t port_id, uint8_t mode);\n+valid_slave_port_id(struct bond_dev_private *internals, uint16_t port_id);\n \n void\n deactivate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id);\ndiff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c\nindex 17e6ff8..eb8d15d 100644\n--- a/drivers/net/bonding/rte_eth_bond_api.c\n+++ b/drivers/net/bonding/rte_eth_bond_api.c\n@@ -56,19 +56,25 @@ check_for_master_bonded_ethdev(const struct rte_eth_dev *eth_dev)\n }\n \n int\n-valid_slave_port_id(uint16_t port_id, uint8_t mode)\n+valid_slave_port_id(struct bond_dev_private *internals, uint16_t slave_port_id)\n {\n-\tRTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -1);\n+\tRTE_ETH_VALID_PORTID_OR_ERR_RET(slave_port_id, -1);\n \n-\t/* Verify that port_id refers to a non bonded port */\n-\tif (check_for_bonded_ethdev(&rte_eth_devices[port_id]) == 0 &&\n-\t\t\tmode == BONDING_MODE_8023AD) {\n+\t/* Verify that slave_port_id refers to a non bonded port */\n+\tif (check_for_bonded_ethdev(&rte_eth_devices[slave_port_id]) == 0 &&\n+\t\t\tinternals->mode == BONDING_MODE_8023AD) {\n \t\tRTE_BOND_LOG(ERR, \"Cannot add slave to bonded device in 802.3ad\"\n \t\t\t\t\" mode as slave is also a bonded device, only \"\n \t\t\t\t\"physical devices can be support in this mode.\");\n \t\treturn -1;\n \t}\n \n+\tif (internals->port_id == slave_port_id) {\n+\t\tRTE_BOND_LOG(ERR,\n+\t\t\t\"Cannot add the bonded device itself as its slave.\");\n+\t\treturn -1;\n+\t}\n+\n \treturn 0;\n }\n \n@@ -456,7 +462,7 @@ __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id)\n \tbonded_eth_dev = &rte_eth_devices[bonded_port_id];\n \tinternals = bonded_eth_dev->data->dev_private;\n \n-\tif (valid_slave_port_id(slave_port_id, internals->mode) != 0)\n+\tif (valid_slave_port_id(internals, slave_port_id) != 0)\n \t\treturn -1;\n \n \tslave_eth_dev = &rte_eth_devices[slave_port_id];\n@@ -605,13 +611,15 @@ rte_eth_bond_slave_add(uint16_t bonded_port_id, uint16_t slave_port_id)\n \n \tint retval;\n \n-\t/* Verify that port id's are valid bonded and slave ports */\n \tif (valid_bonded_port_id(bonded_port_id) != 0)\n \t\treturn -1;\n \n \tbonded_eth_dev = &rte_eth_devices[bonded_port_id];\n \tinternals = bonded_eth_dev->data->dev_private;\n \n+\tif (valid_slave_port_id(internals, slave_port_id) != 0)\n+\t\treturn -1;\n+\n \trte_spinlock_lock(&internals->lock);\n \n \tretval = __eth_bond_slave_add_lock_free(bonded_port_id, slave_port_id);\n@@ -635,7 +643,7 @@ __eth_bond_slave_remove_lock_free(uint16_t bonded_port_id,\n \tbonded_eth_dev = &rte_eth_devices[bonded_port_id];\n \tinternals = bonded_eth_dev->data->dev_private;\n \n-\tif (valid_slave_port_id(slave_port_id, internals->mode) < 0)\n+\tif (valid_slave_port_id(internals, slave_port_id) < 0)\n \t\treturn -1;\n \n \t/* first remove from active slave list */\n@@ -783,7 +791,7 @@ rte_eth_bond_primary_set(uint16_t bonded_port_id, uint16_t slave_port_id)\n \n \tinternals = rte_eth_devices[bonded_port_id].data->dev_private;\n \n-\tif (valid_slave_port_id(slave_port_id, internals->mode) != 0)\n+\tif (valid_slave_port_id(internals, slave_port_id) != 0)\n \t\treturn -1;\n \n \tinternals->user_defined_primary_port = 1;\n", "prefixes": [] }{ "id": 91545, "url": "