From patchwork Thu Jun 28 22:52:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Gora X-Patchwork-Id: 41892 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 9DE331B059; Fri, 29 Jun 2018 00:52:45 +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 077871B006 for ; Fri, 29 Jun 2018 00:52:43 +0200 (CEST) Received: by mail-oi0-f65.google.com with SMTP id 8-v6so2131163oin.10 for ; Thu, 28 Jun 2018 15:52:43 -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; bh=S1g3e3n/4fwp3C2kckm+nJ4Q8ogPllXouqe+NAUrqAU=; b=MY2zqu/r9lnJIInFwc4C19VLpY0jYv1MaM7ifsw0XyuBqL20eASIPO0SX/tWSJ0UmG 7QxC3UgjzM2v83vTrk1jp66KiomupmeGKVwgp5dGQufsS/4gwwRqad5oIcNuv5N2V4wF +CGsOhc1INtZxmtyQVA5VjAoitf0LQalQM8XEHhgjri00h4Qs4RkRMCBhG1Lhsc90klh TCXwWV1pq3b8NAsY5NhdfuMcmsupjR5mbxcIgud73auRA1QCxq4FOzYpuYFmynZy+1o2 lhYjRBLcTWrivbuOOcuh222DT7EyoC0YFkWV953BoGRqATLSxAPgQiXkGaS5hid199qy tUqA== 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; bh=S1g3e3n/4fwp3C2kckm+nJ4Q8ogPllXouqe+NAUrqAU=; b=MqhNlAFL6WFV1VM98GYUznYqjRDaJkQM39ch15lJeGrAff5ePkgRbDPPfu+mg8qYBp cASynDQiRbsZUokAkb2aAxvpqXg7T7p8qf5e3cvnozO63FahE/g7MDnBLT9FaJU8KIf0 qxgeeDp8bWByvlykxsQfefQSWklAnHVS5MDkTBY1eIH2jK5ddEYyBrwDrmOP+BjcPqmL 8ArB3ij/UMycqvlGAtpbwACSMnpkykE8Zn/PlNUo2+6q0VV+ODis/bc+wLbYb4J0T9jG GEAImOh9VMePeSfUKMhTLFJAKZbNtY2XajldYX3lZWRbMPzvfke12n1RhcZhbpZF/1tO 38vw== X-Gm-Message-State: APt69E023ujeAzaaLK07Y8d77zOf6zRwqaq119h7FtWZIvGOV27XuaNA Myk5Cqid1P4vk6gfIaM7IBs= X-Google-Smtp-Source: AAOMgpdOasPNKhs80vFDS1sqe6RtQIhc36optvgH/sDHoSvHRNkg2HcEi5dMmDtFoFnNF7/j75DG9w== X-Received: by 2002:aca:bf82:: with SMTP id p124-v6mr6394203oif.344.1530226363162; Thu, 28 Jun 2018 15:52:43 -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 w5-v6sm218020ote.66.2018.06.28.15.52.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 28 Jun 2018 15:52:42 -0700 (PDT) From: Dan Gora To: Ferruh Yigit Cc: dev@dpdk.org, Dan Gora Date: Thu, 28 Jun 2018 15:52:35 -0700 Message-Id: <20180628225235.20684-1-dg@adax.com> X-Mailer: git-send-email 2.18.0.rc1.1.g6f333ff2f Subject: [dpdk-dev] [PATCH 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. *