From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id EA7A5A04F9; Fri, 10 Jan 2020 09:40:20 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 188E51E913; Fri, 10 Jan 2020 09:39:39 +0100 (CET) Received: from m176115.mail.qiye.163.com (m176115.mail.qiye.163.com [59.111.176.115]) by dpdk.org (Postfix) with ESMTP id 346211DA9F; Thu, 9 Jan 2020 04:15:01 +0100 (CET) Received: from localhost.localdomain (unknown [113.87.163.18]) by m176115.mail.qiye.163.com (Hmail) with ESMTPA id 7465866117D; Thu, 9 Jan 2020 11:14:58 +0800 (CST) From: Fang TongHao To: thomas@monjalon.net, ferruh.yigit@intel.com, arybchenko@solarflare.com Cc: dev@dpdk.org, stable@dpdk.org, cunming.liang@intel.com, jia.guo@intel.com, Fang TongHao Date: Thu, 9 Jan 2020 11:14:25 +0800 Message-Id: <20200109031425.1338-1-fangtonghao@sangfor.com.cn> X-Mailer: git-send-email 2.24.1.windows.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZT1VOQkJCQkJCS09NSElOTFlXWShZQU hPN1dZLVlBSVdZCQ4XHghZQVk1NCk2OjckKS43PlkG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Nj46CQw6GjgxAx8sLEw8FgMa HhMKCQFVSlVKTkxDTkhCTUJDQkpLVTMWGhIXVR0aFRwPFBUcExoUOwgaFRwdFAlVGBQWVRgVRVlX WRILWUFZSkpIVUNMVUpNSFVKQ1lXWQgBWUFIS09INwY+ X-HM-Tid: 0a6f884c4a309373kuws7465866117d X-Mailman-Approved-At: Fri, 10 Jan 2020 09:39:37 +0100 Subject: [dpdk-dev] [PATCH] ethdev: fix secondary process change share memory X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi all,I am from Sangfor Tech.I found a bug when using DPDK in multiprocess scenario.The secondary process enters "rte_eth_dev_pci_copy_info" function when initializing.Then it sets the value of struct "rte_eth_dev_data.dev_flags" to zero, but this struct is shared by primary process and secondary process, and the value change is unexpected by primary process. This may cause very serious damage.I think the secondary process should not enter "rte_eth_dev_pci_copy_info" function or changes the value of struct "rte_eth_dev_data.dev_flags" in shared memory. I fixed this bug by adding an if-statement to forbid the secondary process changing the above-mentioned value. Thansk, All. Signed-off-by: Fang TongHao --- lib/librte_ethdev/rte_ethdev_pci.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev_pci.h b/lib/librte_ethdev/rte_ethdev_pci.h index ccdbb46ec..916de8a14 100644 --- a/lib/librte_ethdev/rte_ethdev_pci.h +++ b/lib/librte_ethdev/rte_ethdev_pci.h @@ -59,15 +59,16 @@ rte_eth_copy_pci_info(struct rte_eth_dev *eth_dev, } eth_dev->intr_handle = &pci_dev->intr_handle; - - eth_dev->data->dev_flags = 0; - if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC) - eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC; - if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_RMV) - eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_RMV; - - eth_dev->data->kdrv = pci_dev->kdrv; - eth_dev->data->numa_node = pci_dev->device.numa_node; + if (rte_eal_process_type() == RTE_PROC_PRIMARY) { + eth_dev->data->dev_flags = 0; + if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_LSC) + eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC; + if (pci_dev->driver->drv_flags & RTE_PCI_DRV_INTR_RMV) + eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_RMV; + + eth_dev->data->kdrv = pci_dev->kdrv; + eth_dev->data->numa_node = pci_dev->device.numa_node; + } } static inline int -- 2.24.1.windows.2