From patchwork Fri Jun 29 01:55:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Gora X-Patchwork-Id: 41905 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6E1631B55D; Fri, 29 Jun 2018 03:56:03 +0200 (CEST) Received: from mail-oi0-f65.google.com (mail-oi0-f65.google.com [209.85.218.65]) by dpdk.org (Postfix) with ESMTP id 440771B54A for ; Fri, 29 Jun 2018 03:55:55 +0200 (CEST) Received: by mail-oi0-f65.google.com with SMTP id f79-v6so7028272oib.7 for ; Thu, 28 Jun 2018 18:55:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=S1g3e3n/4fwp3C2kckm+nJ4Q8ogPllXouqe+NAUrqAU=; b=skh5/T/Z5cMGI7GHI9kbmSYOqYZnYtJxP6CQL22jH1usUUOdk5Qyn8XZAPC1ZpkESt DZu+9k6BIY3NVFUWSZxshiE8Nq/Gjp99WFqXz7hK8jmTiFlIJNUT3HQ6LWtfXaZLgiSr 2qA9KvGW+20GSfq0NnzL5fIeemvfc/ECd8+qiHmV8wqIgfRq6rkIOJwR4EKVhSEefMTz QF4aEKDDhV1Y6lmUbVkGn4TiZpGfub0pNAPundQEPJq1ovVaHi1gx3W3bnSO7MitHhbR T1mTd4Pyp8DCHu8uKuxS1d1jTcpwfaJJspxvvAybv8KpxmXtOr6TypgsTWVY/WpH0EPM p1Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=S1g3e3n/4fwp3C2kckm+nJ4Q8ogPllXouqe+NAUrqAU=; b=f50W7PdjFm6Z8pXcqjvKXy0M3Vhi9eSv2fRy9gBSPsrHm/AKApdems4DlQjchOfzt6 ysk9AGq3ctFO4Vk64Mpfyt+rVhQXUWBUqRSd9rTmzLADHczsQv1a8+XpgU3r0eNOXUZd 6SBe4SPWquLSN5G1IAeRSjOnJJZNA4maHvNaLzgPZNah8Eo7YZxqv962016EZVXk2ePV cZCah0AaLmfh6Q7DYzGN6cFaAuyPO09SWS094BYd529Ue0ay484eqzya37YcNPxRtGhF 6AfZnj2zWxVaX0jIr/PQFEWp/WO/CIIQ3Jp989O3L/lwluIrwjYpkKcSupere3zjIJI0 vvVQ== X-Gm-Message-State: APt69E1ngng/4iG5Cs3MrGg3Jji3ULIUfbEg1iHXNoC5OvHJSMgCauMg DCa+97fGmqANHJhFeoxXV1c= X-Google-Smtp-Source: AAOMgpfqKTrBzaJc1gjXnO8Oc3gwqAvG4HbICe47Yg+ubkJFVAH2vLNQC/8O3cX7stIXx0SLdzTecA== X-Received: by 2002:aca:3357:: with SMTP id z84-v6mr22438oiz.49.1530237354471; Thu, 28 Jun 2018 18:55:54 -0700 (PDT) Received: from linux.adax.com (172-11-198-60.lightspeed.sntcca.sbcglobal.net. [172.11.198.60]) by smtp.gmail.com with ESMTPSA id n3-v6sm3941288otk.38.2018.06.28.18.55.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Jun 2018 18:55:53 -0700 (PDT) From: Dan Gora To: ferruh.yigit@intel.com Cc: dev@dpdk.org, Dan Gora Date: Thu, 28 Jun 2018 18:55:03 -0700 Message-Id: <20180629015508.26599-6-dg@adax.com> X-Mailer: git-send-email 2.18.0.rc1.1.g6f333ff2f In-Reply-To: <20180629015508.26599-1-dg@adax.com> References: <20180628224513.18391-1-dg@adax.com> <20180629015508.26599-1-dg@adax.com> Subject: [dpdk-dev] [PATCH v2 05/10] kni: don't run rte_kni_handle_request after interface release 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" Check to ensure that the KNI interface is still in use before accessing the KNI interface FIFOs to kernel space. This will help to ensure that the user does not access the KNI interface after rte_kni_release() has been called. Signed-off-by: Dan Gora --- lib/librte_kni/rte_kni.c | 6 +++++- lib/librte_kni/rte_kni.h | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c index 1d84c0b70..6ef0859bf 100644 --- a/lib/librte_kni/rte_kni.c +++ b/lib/librte_kni/rte_kni.c @@ -578,7 +578,11 @@ rte_kni_handle_request(struct rte_kni *kni) unsigned ret; struct rte_kni_request *req; - if (kni == NULL) + /* + * Don't touch the req/resp fifos after + * we've been released, we can be freed at any instant! + */ + if (kni == NULL || !kni->in_use) return -1; /* Get request mbuf */ diff --git a/lib/librte_kni/rte_kni.h b/lib/librte_kni/rte_kni.h index d1a95f898..94516c38f 100644 --- a/lib/librte_kni/rte_kni.h +++ b/lib/librte_kni/rte_kni.h @@ -155,6 +155,10 @@ rte_kni_free(struct rte_kni *kni); * Then analyzes it and calls the specific actions for the specific requests. * Finally constructs the response mbuf and puts it back to the resp_q. * + * Thread Safety: This function should be called in a separate thread from the + * thread which calls rte_kni_release() for this KNI. This function must not + * be called simultaneously with rte_kni_free(). + * * @param kni * The pointer to the context of an existent KNI interface. *