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 7A178A04F9; Fri, 10 Jan 2020 09:40:11 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 81DFA1E8FF; Fri, 10 Jan 2020 09:39:37 +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 2D2071D570; Thu, 9 Jan 2020 03:36:18 +0100 (CET) Received: from localhost.localdomain (unknown [113.87.162.54]) by m176115.mail.qiye.163.com (Hmail) with ESMTPA id A0C14660CDB; Thu, 9 Jan 2020 10:36:14 +0800 (CST) From: Fang TongHao To: dev@dpdk.org Cc: Fang TongHao , stable@dpdk.org Date: Thu, 9 Jan 2020 10:35:29 +0800 Message-Id: <20200109023529.1285-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: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZT1VIQ0pLS0tLT0pCTUpNTFlXWShZQU hPN1dZLVlBSVdZCQ4XHghZQVk1NCk2OjckKS43PlkG X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Nj46Pyo5ITgzSB8MF0wuEgoW FD8KCihVSlVKTkxDTkhMSExPQklNVTMWGhIXVR0aFRwPFBUcExoUOwgaFRwdFAlVGBQWVRgVRVlX WRILWUFZSkpIVUNMVUpNSVVOT1lXWQgBWUFJQ0lJNwY+ X-HM-Tid: 0a6f8828d4249373kuwsa0c14660cdb 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. Cc: stable@dpdk.org 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