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 F253642604; Thu, 21 Sep 2023 09:11:04 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 75CBC4026D; Thu, 21 Sep 2023 09:11:04 +0200 (CEST) Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) by mails.dpdk.org (Postfix) with ESMTP id F168E4014F for ; Thu, 21 Sep 2023 09:11:02 +0200 (CEST) Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2b974031aeaso9606601fa.0 for ; Thu, 21 Sep 2023 00:11:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695280262; x=1695885062; darn=dpdk.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=99L0Ok16YPwVM7Nchln0PXtd95uHIAX3TflyxxpU16A=; b=D1T4I5Fmq73hfyAAKVQUX8WIs0YIUYQ6SpOWAHUpOHBN9JJGpqIKfzn8yfwTrZmCGw ZY3yvRgEvtKgHBoh9K1go1prSP3f7l/pxqLMHDEikTzvwHyyFpHWqhKyjhVOUiOCxbFZ Vv3MgLm1M+YTJsi2afV5uXMlRYqcrNERitv4+tm30sblTzvw/Te/c/m5A/ArFeAwWoT+ /c0LvBvco+beyaNC7EtYDt6ryfDZWeNOMyYB3E9Ynp3STqq12fS71M1y3a16LvTNRVul jiyvOrbZZPnlDZ2nSsQz38RI/dxPDf/R9QfDcy36tK0tdKNyDQZHWIrPbXQy4tTmXLd3 YNTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695280262; x=1695885062; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=99L0Ok16YPwVM7Nchln0PXtd95uHIAX3TflyxxpU16A=; b=sgVP6k8mUi0Cd0LZfJXKV88EI+815txeGxsja7v4/dXk6bcgIemRsCwHU9UuH7iktj kyZaoothGElBPK+JbEjcfjaG+TjSfT3w10FfnjRk3BHNe7g9/SbehIs9+y6RQFUJCA9M NDz0E8MqiQc3ehNZfJCL7kvdJxvCEXgHRxBTMr23V/XTmvYjKE1HH6moMDwsvan8aR19 UsYGe/HRwqhenjkKKRyOjzbQNA9f8HulpYFAxzitZda3U+q8pp5g9d05NK6cjcyAxv7n ql1zFDDvIqbDcfBZ++2DkHt7N9s2iK6QYJveiwDdGRH8/pIsiG/sABdbrrTWpyC8XQWm tOag== X-Gm-Message-State: AOJu0YzW/3YkiVo8+ebp+8oMwDSWpDM1VLYFus8qZ+tI9hAra+8NL+oh Z4xPDFnaOddzEH6wXy51TJdFXer5aygOYhzYqkY= X-Google-Smtp-Source: AGHT+IEwb3kh0S4B46u4Sx35IdaAQYJHEOvmaNx4/hFV/AqC5H9ZATA1IEtLc5LyL8JpPSLZDV6ZBjjV/BJtSwG+zzc= X-Received: by 2002:a2e:8558:0:b0:2bc:d0f8:fb4f with SMTP id u24-20020a2e8558000000b002bcd0f8fb4fmr4266612ljj.7.1695280262000; Thu, 21 Sep 2023 00:11:02 -0700 (PDT) MIME-Version: 1.0 References: <20230921042349.104150-1-stephen@networkplumber.org> <20230921042349.104150-3-stephen@networkplumber.org> <98CBD80474FA8B44BF855DF32C47DC35D87BE2@smartserver.smartshare.dk> In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35D87BE2@smartserver.smartshare.dk> From: Isaac Boukris Date: Thu, 21 Sep 2023 10:10:48 +0300 Message-ID: Subject: Re: [PATCH 2/4] dumpcap: allow multiple invocations To: =?UTF-8?Q?Morten_Br=C3=B8rup?= Cc: Stephen Hemminger , dev@dpdk.org, Reshma Pattan Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On Thu, Sep 21, 2023 at 9:22=E2=80=AFAM Morten Br=C3=B8rup wrote: > > > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > > Sent: Thursday, 21 September 2023 06.24 > > > > 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 >=3D size. */ > > @@ -660,28 +660,28 @@ static struct rte_ring *create_ring(void) > > ring_size =3D size; > > } > > > > - ring =3D rte_ring_lookup(RING_NAME); > > - if (ring =3D=3D NULL) { > > - ring =3D rte_ring_create(RING_NAME, ring_size, > > - rte_socket_id(), 0); > > - if (ring =3D=3D 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()); > > I'm not sure getpid() is available on Windows. How about: I think the 'app/dumpcap/meson.build' file indicates no support for Windows= . Regards > #ifdef _WIN32 > #include // With the headers, not here. > "dumpcap-%lu", GetCurrentProcessId()); > #else > "dumpcap-%u", getpid()); > #endif > > > + > > + ring =3D rte_ring_create(ring_name, ring_size, > > + rte_socket_id(), 0); > > + if (ring =3D=3D 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[] =3D "capture_mbufs"; > > + char pool_name[RTE_MEMPOOL_NAMESIZE]; > > size_t num_mbufs =3D 2 * ring_size; > > struct rte_mempool *mp; > > uint32_t data_size =3D 128; > > > > - mp =3D rte_mempool_lookup(pool_name); > > - if (mp) > > - return mp; > > + snprintf(pool_name, sizeof(pool_name), "capture_%u", getpid()); > > Same regarding 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 >