Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67428C10F0E for ; Fri, 12 Apr 2019 04:40:16 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 15B672086D for ; Fri, 12 Apr 2019 04:40:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 15B672086D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 636952BD8; Fri, 12 Apr 2019 06:40:14 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 2B8DE2B95; Fri, 12 Apr 2019 06:40:11 +0200 (CEST) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Apr 2019 21:40:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,340,1549958400"; d="scan'208";a="135124702" Received: from dpdk-tbie.sh.intel.com ([10.67.104.173]) by orsmga006.jf.intel.com with ESMTP; 11 Apr 2019 21:40:05 -0700 Date: Fri, 12 Apr 2019 12:39:38 +0800 From: Tiwei Bie To: Ilya Maximets Cc: dev@dpdk.org, Maxime Coquelin , Jens Freimann , Dariusz Stojaczyk , David Marchand , stable@dpdk.org Message-ID: <20190412043938.GB15935@dpdk-tbie.sh.intel.com> References: <20190409133622.14729-1-i.maximets@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190409133622.14729-1-i.maximets@samsung.com> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH] vhost: fix passing destroyed device to destroy callback 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" On Tue, Apr 09, 2019 at 04:36:22PM +0300, Ilya Maximets wrote: > Application should be able to obtain information like 'ifname' from > the 'vid' passed to 'destroy_connection' callback. Currently, all the > API calls with passed 'vid' fails with 'device not found'. > > Fixes: efba12a78ddf ("vhost: add user callbacks for socket open/close") > Cc: stable@dpdk.org > > Signed-off-by: Ilya Maximets > --- > lib/librte_vhost/socket.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_vhost/socket.c b/lib/librte_vhost/socket.c > index 3da9de62c..43f091d10 100644 > --- a/lib/librte_vhost/socket.c > +++ b/lib/librte_vhost/socket.c > @@ -297,11 +297,12 @@ vhost_user_read_cb(int connfd, void *dat, int *remove) > if (ret < 0) { > close(connfd); > *remove = 1; > - vhost_destroy_device(conn->vid); > > if (vsocket->notify_ops->destroy_connection) > vsocket->notify_ops->destroy_connection(conn->vid); > > + vhost_destroy_device(conn->vid); By design, notify_ops->destroy_device() should be called before notify_ops->destroy_connection(). I.e. something like: vhost_destroy_device_notify(...); // device stop if (vsocket->notify_ops->destroy_connection) // socket close vsocket->notify_ops->destroy_connection(conn->vid); vhost_destroy_device(conn->vid); // free As destroy_device() callback means device stop (which also happens in e.g. GET_VRING_BASE). > + > pthread_mutex_lock(&vsocket->conn_mutex); > TAILQ_REMOVE(&vsocket->conn_list, conn, next); > pthread_mutex_unlock(&vsocket->conn_mutex); > -- > 2.17.1 >