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 9280F432D9; Wed, 8 Nov 2023 19:36:26 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 225D3427DB; Wed, 8 Nov 2023 19:36:14 +0100 (CET) Received: from mail-oo1-f49.google.com (mail-oo1-f49.google.com [209.85.161.49]) by mails.dpdk.org (Postfix) with ESMTP id 6380941133 for ; Wed, 8 Nov 2023 19:36:11 +0100 (CET) Received: by mail-oo1-f49.google.com with SMTP id 006d021491bc7-586ba7cdb6bso3903631eaf.2 for ; Wed, 08 Nov 2023 10:36:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1699468570; x=1700073370; 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=omUtTH7y7VOw30b39TLXxrqp0tKrYGDXycHE1fkYinQ=; b=MwZXWJ1SPo8Oxd0YfMOpYOdcpcqVwsOQnJJwqXOXl2ITA+XD8D22RGphhb+z9C3IsX 0y9Ahp9REP2qjfrfCxP+MHFMxBIM35Y4aRYMrkRRMNzCqu5KMIitWzGxrezu5s7MDTOR ghRV3qnP8F81CRFUtsdlDfW2By2jNB4PACkOjW4y9Cl6fDyBbAlWy24UBxzz1YdAK13s DUaqnKqYD4NdqemU2RSqAtQ4M9CZgjVp5/7OQ8OQN9Bd3DXMoiB4gjJDRMwq3RFI3J84 5hZh/zISN6LtNOYMfQPQ1HzqscQP/+rsw8DBGgnF/HJwhNPfhgOOW1j0rAQxjvE6YpKk Ugsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699468570; x=1700073370; 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=omUtTH7y7VOw30b39TLXxrqp0tKrYGDXycHE1fkYinQ=; b=KvlL06njj0V4wZdyoC0Bzn3M3alyy1twESDITNFWI6EjKre/GZT4V7p4bfSWJKKyB8 YPuctvvC7AswOe2sfhql9fRbsxWJNNcnOd8uQCj+UaRxGs3vrwhZcJB2u4q+IQnoXIQd qre/yu7nRl505Wg2+G7t0p7bfOZF2WZw3qvZBpRPEzW/AeQpYuwUCcEplpNfsQIHL8xv R2OJ8FxKBgbuvEGidAulmKf15yxWG9Et4/LCjd2IUjWmqxW1Q+YEUp1soEqaJyOWXrd2 OsYlPJzey4CB4+kZ0IGbujCiisGYSPJk1ow5NBwKxi+50duJpNtIwH4hil1BsvwBa6xt ULLA== X-Gm-Message-State: AOJu0Yxttf+FLhGqIRxlCegJh2CWmzMUSDDO0UpSlPinTivbMelYbxKj SF35VajlmNvMR0Az9V/FMD7Sf3VhYaVR3ILW3ok= X-Google-Smtp-Source: AGHT+IGNFcqWmts0rv5nxqbzpR6TJ51U0GqJZPVW36tl0GPKgpquwSBEYmlrUPj1fGffuOnJIppHzA== X-Received: by 2002:a05:6358:3a1b:b0:168:e69c:66f5 with SMTP id g27-20020a0563583a1b00b00168e69c66f5mr2201069rwe.15.1699468570241; Wed, 08 Nov 2023 10:36:10 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id p25-20020a635b19000000b005b944b20f34sm3402522pgb.85.2023.11.08.10.36.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Nov 2023 10:36:09 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Isaac Boukris Subject: [PATCH v3 2/5] dumpcap: allow multiple invocations Date: Wed, 8 Nov 2023 10:35:54 -0800 Message-Id: <20231108183557.381955-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231108183557.381955-1-stephen@networkplumber.org> References: <20230921042349.104150-1-stephen@networkplumber.org> <20231108183557.381955-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. 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 64294bbfb3e6..37754fd06f4f 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-%u", 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_%u", 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.39.2