From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f67.google.com (mail-wm0-f67.google.com [74.125.82.67]) by dpdk.org (Postfix) with ESMTP id 6BCE21B873 for ; Tue, 15 May 2018 15:49:32 +0200 (CEST) Received: by mail-wm0-f67.google.com with SMTP id j4-v6so1193692wme.1 for ; Tue, 15 May 2018 06:49:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/tjpKchLN8AD5e8+t2RtkdbM5WWaKR/nTkyWZD97qsU=; b=qNdXTpK59jBNe19p1ALsOBO+3BRuePTXnQXkGsbP4XI4cy5h7nwyGc35jr1L01h1dN X7G1KssC58XJHBYd4b0mIM5rt9xlSEMxH14+QRk0EhNUVjS37FBFPqRc82o3/Au6ZZ+B 3k7uPgjV5uajdLb+jp0elW/LESGSw/W6oQhvzu3jY3WbefxkrFUf5EcK2WgQsK0ZUmla cyMlTcxNyPKmy/igbNyzjiC+x+aiZi1zY0iRcdg/jaGVvIripia07pHBityMWQRjBpqm JlJdQzltIBYNojKeLCHtvYR5VUUFZy+PO+DAyn0B2ObC21A4YfvjbEuzRXqXLsOGHCiY Y80g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/tjpKchLN8AD5e8+t2RtkdbM5WWaKR/nTkyWZD97qsU=; b=gyotmZl3tzxNQZvkE2PqxJJze3i2fgSRBLznGHoBDW+u6foSZjnrSsb/Np7wvn1cM/ F3TQpcEbWVQZ1Kjdw716H+4a6FM9Pav9W9OQCt9fHbE/8epbeJewlumQJbCGUpBWSt2K przHbICkg1Bk46Z6SQx5R0Y+x9RRKkzhfNvCGpjbTjwPLBmOT39xE4tbcTtz4K6PNaw+ EnHwAf1Y+mropcDhqn059a8SBNN0j9FZ7cY0I9zPHGftdtFAJNcPb27c1guWivexzl/Q P1NlX6sO2kVr9zCywp3aWxdFRNjL+nmEHkJcqoW0Oja8ZqtA6myVE6O4m5b9Qbtx9t1E lhvw== X-Gm-Message-State: ALKqPweI3ztOJCtf9KXudVScE/+8ss3pcy6bDnXOgFWCTumTkmkStnDh vOd6jB6fdfKtZH1/MXHebFE= X-Google-Smtp-Source: AB8JxZqNyeRbotC5jFPuYC4YmUtp9zqD23yGBRhWri4FeqbLVblQQDIxjfMJOL6gbqh6puzwXTUJxg== X-Received: by 2002:a1c:4584:: with SMTP id l4-v6mr7910044wmi.142.1526392172156; Tue, 15 May 2018 06:49:32 -0700 (PDT) Received: from localhost (slip139-92-244-193.lon.uk.prserv.net. [139.92.244.193]) by smtp.gmail.com with ESMTPSA id u89-v6sm682148wma.4.2018.05.15.06.49.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 15 May 2018 06:49:31 -0700 (PDT) From: luca.boccassi@gmail.com To: Matan Azrad Cc: Thomas Monjalon , Andrew Rybchenko , Stephen Hemminger , dpdk stable Date: Tue, 15 May 2018 14:47:17 +0100 Message-Id: <20180515134731.9337-66-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180515134731.9337-1-luca.boccassi@gmail.com> References: <20180503110612.12146-2-luca.boccassi@gmail.com> <20180515134731.9337-1-luca.boccassi@gmail.com> Subject: [dpdk-stable] patch 'ethdev: add lock to port allocation check' has been queued to stable release 18.02.2 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 May 2018 13:49:32 -0000 Hi, FYI, your patch has been queued to stable release 18.02.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/16/18. So please shout if anyone has objections. Thanks. Luca Boccassi --- >>From e765733c1aa7a1da7ecc46c0223323965e8e437f Mon Sep 17 00:00:00 2001 From: Matan Azrad Date: Fri, 11 May 2018 01:58:32 +0200 Subject: [PATCH] ethdev: add lock to port allocation check [ upstream commit ac7d3b6ddf87e1e0435de6d40cfe2749dc0ff9a4 ] When comparing the port name, there can be a race condition with a thread allocating a new port and writing the name at the same time. It can lead to match with a partial name by error. The check of the port is now considered as a critical section protected with locks. This fix will be even more required for multi-process when the port availability will rely only on the name, in a following patch. Fixes: 84934303a17c ("ethdev: synchronize port allocation") Signed-off-by: Matan Azrad Acked-by: Thomas Monjalon Reviewed-by: Andrew Rybchenko Reviewed-by: Stephen Hemminger --- lib/librte_ether/rte_ethdev.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 30a0ba7da..e7f2b809c 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -222,8 +222,8 @@ rte_eth_dev_shared_data_prepare(void) rte_spinlock_unlock(&rte_eth_shared_data_lock); } -struct rte_eth_dev * -rte_eth_dev_allocated(const char *name) +static struct rte_eth_dev * +_rte_eth_dev_allocated(const char *name) { unsigned i; @@ -235,6 +235,22 @@ rte_eth_dev_allocated(const char *name) return NULL; } +struct rte_eth_dev * +rte_eth_dev_allocated(const char *name) +{ + struct rte_eth_dev *ethdev; + + rte_eth_dev_shared_data_prepare(); + + rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock); + + ethdev = _rte_eth_dev_allocated(name); + + rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock); + + return ethdev; +} + static uint16_t rte_eth_dev_find_free_port(void) { @@ -281,7 +297,7 @@ rte_eth_dev_allocate(const char *name) goto unlock; } - if (rte_eth_dev_allocated(name) != NULL) { + if (_rte_eth_dev_allocated(name) != NULL) { RTE_LOG(ERR, EAL, "Ethernet Device with name %s already allocated!\n", name); goto unlock; -- 2.14.2