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 2B717A046B; Thu, 9 Jan 2020 13:27:58 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 470351DD3B; Thu, 9 Jan 2020 13:27:57 +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 AF45F1DD37; Thu, 9 Jan 2020 13:27:55 +0100 (CET) Received: from localhost.localdomain (unknown [113.87.162.54]) by m176115.mail.qiye.163.com (Hmail) with ESMTPA id 69A2E6639FF; Thu, 9 Jan 2020 20:27:51 +0800 (CST) From: Fang TongHao To: thomas@monjalon.net, ferruh.yigit@intel.com, arybchenko@solarflare.com Cc: cunming.liang@intel.com, jia.guo@intel.com, dev@dpdk.org, stable@dpdk.org, Fang TongHao Date: Thu, 9 Jan 2020 20:27:10 +0800 Message-Id: <20200109122710.1362-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: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZT1VKQkxLS0tLSU1MS0lDQ1lXWShZQU hPN1dZLVlBSVdZCQ4XHghZQVk1NCk2OjckKS43PlkG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6PRA6Sww6DDgxNR5RODcvEEI0 FAEKCz1VSlVKTkxDTkxJQ0xKQ0tLVTMWGhIXVR0aFRwPFBUcExoUOwgaFRwdFAlVGBQWVRgVRVlX WRILWUFZSkpIVUNMVUpNSVVOT1lXWQgBWUFIS09INwY+ X-HM-Tid: 0a6f8a4678069373kuws69a2e6639ff 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