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 E78F8426C7; Fri, 6 Oct 2023 01:07:14 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B0E7D402EA; Fri, 6 Oct 2023 01:07:03 +0200 (CEST) Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) by mails.dpdk.org (Postfix) with ESMTP id 10A80402CF for ; Fri, 6 Oct 2023 01:07:01 +0200 (CEST) Received: by mail-oo1-f52.google.com with SMTP id 006d021491bc7-57e3c2adbf0so841357eaf.2 for ; Thu, 05 Oct 2023 16:07:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1696547221; x=1697152021; 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=KtzjHrk7GmTWUJlq0JnEV6VwqiS54li8D4hysIQMVZs/oF4MjLpAujXK8C/NoJ3+tR N0XXLm4RXmXLcCIuUzHbHeac2kbAbHRZK2kFJFm7707zZbUsSl3dAlo7+RSHMRsyrYb2 NPTHyz457HpuwnzE27ZOMZqfec3rErR6+ZROYwHcKHL5sZxN2Ha9STLv6jl+JUuvtlta gMB+ZZ2DdkLItdx9ZW1HxoyxaYBx1WfO5hByZAMlurDEvD8D5QQ1grp+tpBHWPyJhi+e qSOisQi1p8Y21U6CjVZQZWg6qkBE42/bGta2tMqE/K6tj5QIYIdl5afBVvWkDMfg/dDV w6dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696547221; x=1697152021; 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=lTUpurjFGZYMVvf/ahTkP87mgtzEvyL6y1Ix5cLz9+01Adu7EmgWEPI/93kcksAXRw vWsyO/2PiCvSPfIR7rQi8fbS1QFDwvkMxW95NSqB/yUg44IYvN0MMBktmnuBODzU95F9 SYbgsedlZPCrCNVfp6QiGCyQixVynwSK5b73OYCo+aqJT/wHeAptvoxR6DZx756Ysub6 Yg3ctJaQUArawDUQ5jquWUJgCuWi4JIytloBuluoNONuBaFyIwHcmEozbqGh3lFYO6CH dhP8y8SM9+vYgCMIbRxFjqqg86lDWhWKkYZcW83w8pvKfbfyFORi/g46d6sJ8xsMQNsY UvYQ== X-Gm-Message-State: AOJu0YyTY4DzxQFVVXddk+Bk0Y1EyGOnJGH119TL7GrDt08bNNkKrvQA /M0ikHCFvLdmq+i/LXVWcaapJ5odPEqNIfaFu80= X-Google-Smtp-Source: AGHT+IGTZ5ltmKK6YJEbwNt2ovZwgA4bCCFy9TnuuYCuC1KWq76O74VZ8UM729+ogJIItp3j39lDwQ== X-Received: by 2002:a05:6358:921:b0:143:8f7f:9150 with SMTP id r33-20020a056358092100b001438f7f9150mr7438403rwi.13.1696547220845; Thu, 05 Oct 2023 16:07:00 -0700 (PDT) Received: from hermes.local (204-195-126-68.wavecable.com. [204.195.126.68]) by smtp.gmail.com with ESMTPSA id d13-20020aa7814d000000b00690cd981652sm112665pfn.61.2023.10.05.16.06.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 16:07:00 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Isaac Boukris , Reshma Pattan Subject: [PATCH v2 2/4] dumpcap: allow multiple invocations Date: Thu, 5 Oct 2023 16:06:46 -0700 Message-Id: <20231005230648.68244-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231005230648.68244-1-stephen@networkplumber.org> References: <20230921042349.104150-1-stephen@networkplumber.org> <20231005230648.68244-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