From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5702843355; Fri, 17 Nov 2023 17:37:56 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 12BAD427E6; Fri, 17 Nov 2023 17:37:45 +0100 (CET) Received: from mail-il1-f176.google.com (mail-il1-f176.google.com [209.85.166.176]) by mails.dpdk.org (Postfix) with ESMTP id A2B38411F3 for ; Fri, 17 Nov 2023 17:37:42 +0100 (CET) Received: by mail-il1-f176.google.com with SMTP id e9e14a558f8ab-359343e399fso7186065ab.0 for ; Fri, 17 Nov 2023 08:37:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1700239062; x=1700843862; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FG4uvSUBDITeHxIlCSAt5isKVOrazsLOUShZ5sWpXiY=; b=EDeJi4mRTD/siU5xmmLUq7wXsOeSc/pLW01rjAZ04cLfMpM8KOAEwzlpYiEv5WUY0W CqKxY2JfWvQ2plhmBHUHW9CxyB7itgjgHfHLqofGhKYkQZpWh+mbhvq2lGBwJfeeOcwR O4fol33v2KrqtNHrySRN1n7O2BQZnwnyWsP8EzPIf6fu0mTkv6dAn/smxlUdhbXi/FsZ 77COpoR9eE8C1MX6mIdkItIhl9cisz8emE75SF872EmQifKMOB41Ez3fFDWsA52434Cp Fx5bwCGx0HhT//A4NtE6yXLCL2uvGme6QPc36xySnkeD9UxShPptwCr+r/k/oyCD7Lwi j+/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700239062; x=1700843862; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FG4uvSUBDITeHxIlCSAt5isKVOrazsLOUShZ5sWpXiY=; b=t7sTbb3v5GfFW70Gjhvn7dzUKM7J/wSNI5sd9a5EQdfTH3ELKEGEUmxdsDuNbK61pU b9RxmUXdVhGEMPqGNRy6Sywm2YBbz4tuBX1X6STsMyLMkE3nLK2+NB+aJ9zxf8tE+vMN 1N75uCOiAFHP4GyBkqAlzaTq2+NVMpTgHDDDJcpF4kNjHhMLeMCgXxrAT/Fittn/e7Ri 8Ad6BtJkAEoF+coh4GdNPn/LK9WzpNG07noGV2IL8EIlR9Yc9N1IQYLXLiPmhu3ua8RE imbYnt0VL5DVWP82ub8Td50oGY18+AgSQA+/hnddASfUu+Ryxbfu93EeDb8a4EM1fh9t Kv1w== X-Gm-Message-State: AOJu0YxyGy0xZ5ilvWkZy1A1Jcb+rz2Rd2XnV5ha/aXPJGpLsLc1Ptzh nh1+QmIDl817GpQlNp3ca9bNHKzQ/UzV6YsT6yPDMA== X-Google-Smtp-Source: AGHT+IHhzMpniq33ad/bXZF6jQam9wnBX0YyBXoR/xKuLddXtfpv0CxyFHbyPRIeyVwlwSV/Hco/Cg== X-Received: by 2002:a92:cdab:0:b0:359:ca5f:5103 with SMTP id g11-20020a92cdab000000b00359ca5f5103mr27568477ild.6.1700239061819; Fri, 17 Nov 2023 08:37:41 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id f22-20020a631016000000b005bd3f34b10dsm1595541pgl.24.2023.11.17.08.37.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Nov 2023 08:37:41 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Isaac Boukris , Reshma Pattan Subject: [PATCH v7 2/5] dumpcap: allow multiple invocations Date: Fri, 17 Nov 2023 08:35:56 -0800 Message-ID: <20231117163729.243188-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231117163729.243188-1-stephen@networkplumber.org> References: <20230921042349.104150-1-stephen@networkplumber.org> <20231117163729.243188-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org If dumpcap is run twice with each instance pointing a different interface, it would fail because of overlap in ring a pool names. Fix by putting process id in the name. It is still not allowed to do multiple invocations on the same interface because only one callback is allowed and only one copy of mbuf is done. Dumpcap will fail with error in this case: pdump_prepare_client_request(): client request for pdump enable/disable failed EAL: Error - exiting with code: 1 Cause: Packet dump enable on 0:net_null0 failed File exists Fixes: cbb44143be74 ("app/dumpcap: add new packet capture application") Reported-by: Isaac Boukris Signed-off-by: Stephen Hemminger --- app/dumpcap/main.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c index 4f581bd341d8..d05dddac0071 100644 --- a/app/dumpcap/main.c +++ b/app/dumpcap/main.c @@ -44,7 +44,6 @@ #include #include -#define RING_NAME "capture-ring" #define MONITOR_INTERVAL (500 * 1000) #define MBUF_POOL_CACHE_SIZE 32 #define BURST_SIZE 32 @@ -647,6 +646,7 @@ static void dpdk_init(void) static struct rte_ring *create_ring(void) { struct rte_ring *ring; + char ring_name[RTE_RING_NAMESIZE]; size_t size, log2; /* Find next power of 2 >= size. */ @@ -660,28 +660,28 @@ static struct rte_ring *create_ring(void) ring_size = size; } - ring = rte_ring_lookup(RING_NAME); - if (ring == NULL) { - ring = rte_ring_create(RING_NAME, ring_size, - rte_socket_id(), 0); - if (ring == NULL) - rte_exit(EXIT_FAILURE, "Could not create ring :%s\n", - rte_strerror(rte_errno)); - } + /* Want one ring per invocation of program */ + snprintf(ring_name, sizeof(ring_name), + "dumpcap-%d", getpid()); + + ring = rte_ring_create(ring_name, ring_size, + rte_socket_id(), 0); + if (ring == NULL) + rte_exit(EXIT_FAILURE, "Could not create ring :%s\n", + rte_strerror(rte_errno)); + return ring; } static struct rte_mempool *create_mempool(void) { const struct interface *intf; - static const char pool_name[] = "capture_mbufs"; + char pool_name[RTE_MEMPOOL_NAMESIZE]; size_t num_mbufs = 2 * ring_size; struct rte_mempool *mp; uint32_t data_size = 128; - mp = rte_mempool_lookup(pool_name); - if (mp) - return mp; + snprintf(pool_name, sizeof(pool_name), "capture_%d", getpid()); /* Common pool so size mbuf for biggest snap length */ TAILQ_FOREACH(intf, &interfaces, next) { @@ -826,7 +826,7 @@ static void enable_pdump(struct rte_ring *r, struct rte_mempool *mp) rte_exit(EXIT_FAILURE, "Packet dump enable on %u:%s failed %s\n", intf->port, intf->name, - rte_strerror(-ret)); + rte_strerror(rte_errno)); } if (intf->opts.promisc_mode) { -- 2.42.0