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 B8F3FA0588; Thu, 16 Apr 2020 15:51:05 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7DBE11DCC8; Thu, 16 Apr 2020 15:51:05 +0200 (CEST) Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by dpdk.org (Postfix) with ESMTP id 7357A1C1DD; Thu, 16 Apr 2020 15:51:03 +0200 (CEST) Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id B633EFAE0D2EE2F9FEDE; Thu, 16 Apr 2020 21:51:01 +0800 (CST) Received: from localhost (10.173.251.152) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.487.0; Thu, 16 Apr 2020 21:50:54 +0800 From: wangyunjian To: , CC: , , , Yunjian Wang , Date: Thu, 16 Apr 2020 21:50:52 +0800 Message-ID: <1587045052-16708-1-git-send-email-wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.173.251.152] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH] net/tap: fix unexpected link handler 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" From: Yunjian Wang The nic's interrupt source has some active handler, which maybe call tap_dev_intr_handler() to set link handler. We should cancel the link handler before close fd to prevent executing the link handler. It triggers segfault. Call Trace: 0x00007f15e08dad99 in __rte_panic (Error adding fd %d epoll_ctl, %s\n") 0x00007f15e08e9b87 in eal_intr_thread_main () 0x00007f15e249be15 in start_thread () 0x00007f15d5322f9d in clone () Fixes: c0bddd3a057f ("net/tap: add link status notification") CC: stable@dpdk.org Signed-off-by: Yunjian Wang --- drivers/net/tap/rte_eth_tap.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 05470a211..6aa3d5cd3 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -1563,13 +1564,12 @@ static int tap_lsc_intr_handle_set(struct rte_eth_dev *dev, int set) { struct pmd_internals *pmd = dev->data->dev_private; + int ret; /* In any case, disable interrupt if the conf is no longer there. */ if (!dev->data->dev_conf.intr_conf.lsc) { if (pmd->intr_handle.fd != -1) { - tap_nl_final(pmd->intr_handle.fd); - rte_intr_callback_unregister(&pmd->intr_handle, - tap_dev_intr_handler, dev); + goto clean; } return 0; } @@ -1580,9 +1580,26 @@ tap_lsc_intr_handle_set(struct rte_eth_dev *dev, int set) return rte_intr_callback_register( &pmd->intr_handle, tap_dev_intr_handler, dev); } + +clean: + do { + ret = rte_intr_callback_unregister(&pmd->intr_handle, + tap_dev_intr_handler, dev); + if (ret >= 0) { + break; + } else if (ret == -EAGAIN) { + rte_delay_ms(100); + } else { + TAP_LOG(ERR, "intr callback unregister failed: %d", + ret); + break; + } + } while (true); + tap_nl_final(pmd->intr_handle.fd); - return rte_intr_callback_unregister(&pmd->intr_handle, - tap_dev_intr_handler, dev); + pmd->intr_handle.fd = -1; + + return 0; } static int -- 2.19.1