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 69403432EA; Thu, 9 Nov 2023 20:46:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 95BBD40F1A; Thu, 9 Nov 2023 20:46:11 +0100 (CET) Received: from mail-oi1-f174.google.com (mail-oi1-f174.google.com [209.85.167.174]) by mails.dpdk.org (Postfix) with ESMTP id 1015240DC9 for ; Thu, 9 Nov 2023 20:46:10 +0100 (CET) Received: by mail-oi1-f174.google.com with SMTP id 5614622812f47-3b3e13fc1f7so742284b6e.0 for ; Thu, 09 Nov 2023 11:46:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1699559169; x=1700163969; 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=U85fl2qShxBl2MNBjIkUZNLb6jkMS5sOCrwRRpEWPsg=; b=ZTMKCIcwy5/CQJjHzASpoLbAxn5MZJ73afNhUHcvV7EUxOGK7ACbrHRrLpRsDDk3Rr 6AaCnrTwLnRnI4zBnY82NGfFUjYdX962H2obK65AMJH5FE8vg07aE+Me5FLmJOxQn7yD p1YoA0b8u9KjaTb7/ETuSXdyrFZ6AsGPBba0N49aA+pvWnKpGeeMrp7NgXgsWWDRJ3nu IIW4+SN3/xW0AnQyXJTGgFRI97O4CLKO0D94OFh8Pa8JfQiKQ55tpyY5W1FOqy6m0CiP 1Yt0uOdLniQ7o+3fqqkhIWfldOYAMLAoJfI6r8h01D4oZ1W1il9cy4WPz2F9zlDDv6+r r17g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699559169; x=1700163969; 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=U85fl2qShxBl2MNBjIkUZNLb6jkMS5sOCrwRRpEWPsg=; b=PLD6wP3aPZkwZBRnQkZ/lfm9AO+kKXTwvg+1d0J/4LGUnMgA/S8gczF5YVsxLXRu6T R0E+pnnlS0w1CK1SdXV05QP7SeTB4aWUfJsIFMJeUX1XNlUONVLeiDaiRvS4coMxJEep 8scTQKQNlZllD+JiFL4qKG1GTge12c3AY0u5/1/bjalQHlHQFOSEJoDlrfWZdYUWKnX9 0xSRDnBPYVGXpAXXGO7ctPXgXU93QPK91Lz+VbuaTcytEMDA9et76nig8uF6fUZUdQxJ TQiaioocEn7BxsLWYAejvf1XEvIG9rXNW0a3zAoVVfpH26F8qtxGG+GS0NHsZtMDxrsq z1uQ== X-Gm-Message-State: AOJu0Yyr6X6gLxTheSgOw25oiQoJY12BTnA1Ey5wiwxUUOS4UdMFyNBl VT8K30ao5nAF5PwG6SKrWxQ4mR25EGaMa7gh1Ms= X-Google-Smtp-Source: AGHT+IF2D/KKUNQxApKaACSCsklsZlFIhOBtdae9tWXJwjpDzFjFXrhNZ2T83YSPlE9GZ4E57HxjxQ== X-Received: by 2002:a05:6808:1183:b0:3ae:16aa:8ba9 with SMTP id j3-20020a056808118300b003ae16aa8ba9mr3033139oil.30.1699559169077; Thu, 09 Nov 2023 11:46:09 -0800 (PST) Received: from hermes.local (204-195-123-141.wavecable.com. [204.195.123.141]) by smtp.gmail.com with ESMTPSA id j191-20020a6380c8000000b0059b782e8541sm5176101pgd.28.2023.11.09.11.46.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Nov 2023 11:46:08 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Isaac Boukris , Reshma Pattan Subject: [PATCH v5 2/5] dumpcap: allow multiple invocations Date: Thu, 9 Nov 2023 11:45:54 -0800 Message-Id: <20231109194557.111350-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231109194557.111350-1-stephen@networkplumber.org> References: <20230921042349.104150-1-stephen@networkplumber.org> <20231109194557.111350-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 64294bbfb3e6..efc60372d718 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.39.2