DPDK patches and discussions
 help / color / mirror / Atom feed
From: Isaac Boukris <iboukris@gmail.com>
To: "Morten Brørup" <mb@smartsharesystems.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	dev@dpdk.org,  Reshma Pattan <reshma.pattan@intel.com>
Subject: Re: [PATCH 2/4] dumpcap: allow multiple invocations
Date: Thu, 21 Sep 2023 10:10:48 +0300	[thread overview]
Message-ID: <CAC-fF8T8eo4eEWjddCRFPO3a1fRdCpHisyvVLLQC8am0Hfsh5w@mail.gmail.com> (raw)
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35D87BE2@smartserver.smartshare.dk>

On Thu, Sep 21, 2023 at 9:22 AM Morten Brørup <mb@smartsharesystems.com> 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 <iboukris@gmail.com>
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> > ---
> >  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 <pcap/pcap.h>
> >  #include <pcap/bpf.h>
> >
> > -#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());
>
> 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 <processthreadsapi.h> // With the headers, not here.
> "dumpcap-%lu", GetCurrentProcessId());
> #else
> "dumpcap-%u", getpid());
> #endif
>
> > +
> > +     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());
>
> 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
>

  reply	other threads:[~2023-09-21  7:11 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-21  4:23 [PATCH 0/4] pcapng fixes Stephen Hemminger
2023-09-21  4:23 ` [PATCH 1/4] pdump: fix setting rte_errno on mp error Stephen Hemminger
2023-09-21  4:23 ` [PATCH 2/4] dumpcap: allow multiple invocations Stephen Hemminger
2023-09-21  6:22   ` Morten Brørup
2023-09-21  7:10     ` Isaac Boukris [this message]
2023-11-07  2:34     ` Stephen Hemminger
2023-09-21  4:23 ` [PATCH 3/4] pcapng: change timestamp argument to write_stats Stephen Hemminger
2023-09-21  4:23 ` [PATCH 4/4] pcapng: move timestamp calculation into pdump Stephen Hemminger
2023-10-02  8:15   ` David Marchand
2023-10-04 17:13     ` Stephen Hemminger
2023-10-06  9:10       ` David Marchand
2023-10-06 14:59         ` Kevin Traynor
2023-10-05 23:06 ` [PATCH v2 0/4] dumpcap and pcapng fixes Stephen Hemminger
2023-10-05 23:06   ` [PATCH v2 1/4] pdump: fix setting rte_errno on mp error Stephen Hemminger
2023-10-05 23:06   ` [PATCH v2 2/4] dumpcap: allow multiple invocations Stephen Hemminger
2023-10-05 23:06   ` [PATCH v2 3/4] pcapng: modify timestamp calculation Stephen Hemminger
2023-10-05 23:06   ` [PATCH v2 4/4] test: cleanups to pcapng test Stephen Hemminger
2023-11-08 18:35 ` [PATCH v3 0/5] dumpcap and pcapng fixes Stephen Hemminger
2023-11-08 18:35   ` [PATCH v3 1/5] pdump: fix setting rte_errno on mp error Stephen Hemminger
2023-11-09  7:34     ` Morten Brørup
2023-11-08 18:35   ` [PATCH v3 2/5] dumpcap: allow multiple invocations Stephen Hemminger
2023-11-09  7:50     ` Morten Brørup
2023-11-09 15:40       ` Stephen Hemminger
2023-11-09 16:00         ` Morten Brørup
2023-11-09 17:16       ` Stephen Hemminger
2023-11-09 18:22         ` Morten Brørup
2023-11-08 18:35   ` [PATCH v3 3/5] pcapng: modify timestamp calculation Stephen Hemminger
2023-11-09  7:57     ` Morten Brørup
2023-11-08 18:35   ` [PATCH v3 4/5] pcapng: avoid using alloca() Stephen Hemminger
2023-11-09  8:21     ` Morten Brørup
2023-11-09 15:44       ` Stephen Hemminger
2023-11-09 16:25         ` Morten Brørup
2023-11-08 18:35   ` [PATCH v3 5/5] test: cleanups to pcapng test Stephen Hemminger
2023-11-09 17:34 ` [PATCH v4 0/5] dumpcap and pcapng fixes Stephen Hemminger
2023-11-09 17:34   ` [PATCH v4 1/5] pdump: fix setting rte_errno on mp error Stephen Hemminger
2023-11-09 17:34   ` [PATCH v4 2/5] dumpcap: allow multiple invocations Stephen Hemminger
2023-11-09 18:30     ` Morten Brørup
2023-11-09 17:34   ` [PATCH v4 3/5] pcapng: modify timestamp calculation Stephen Hemminger
2023-11-09 17:34   ` [PATCH v4 4/5] pcapng: avoid using alloca() Stephen Hemminger
2023-11-09 17:34   ` [PATCH v4 5/5] test: cleanups to pcapng test Stephen Hemminger
2023-11-09 19:45 ` [PATCH v5 0/5] dumpcap and pcapng fixes Stephen Hemminger
2023-11-09 19:45   ` [PATCH v5 1/5] pdump: fix setting rte_errno on mp error Stephen Hemminger
2023-11-09 19:45   ` [PATCH v5 2/5] dumpcap: allow multiple invocations Stephen Hemminger
2023-11-09 20:09     ` Morten Brørup
2023-11-09 19:45   ` [PATCH v5 3/5] pcapng: modify timestamp calculation Stephen Hemminger
2023-11-12 14:22     ` Thomas Monjalon
2023-11-09 19:45   ` [PATCH v5 4/5] pcapng: avoid using alloca() Stephen Hemminger
2023-11-09 19:45   ` [PATCH v5 5/5] test: cleanups to pcapng test Stephen Hemminger
2023-11-13 16:15 ` [PATCH v6 0/5] dumpcap and pcapng fixes Stephen Hemminger
2023-11-13 16:15   ` [PATCH v6 1/5] pdump: fix setting rte_errno on mp error Stephen Hemminger
2023-11-13 16:15   ` [PATCH v6 2/5] dumpcap: allow multiple invocations Stephen Hemminger
2023-11-13 16:15   ` [PATCH v6 3/5] pcapng: modify timestamp calculation Stephen Hemminger
2023-11-13 16:15   ` [PATCH v6 4/5] pcapng: avoid using alloca() Stephen Hemminger
2023-11-13 16:15   ` [PATCH v6 5/5] test: cleanups to pcapng test Stephen Hemminger
2023-11-17 16:35 ` [PATCH v7 0/5] dumpcap and pcapng fixes Stephen Hemminger
2023-11-17 16:35   ` [PATCH v7 1/5] pdump: fix setting rte_errno on mp error Stephen Hemminger
2023-11-17 16:35   ` [PATCH v7 2/5] dumpcap: allow multiple invocations Stephen Hemminger
2023-11-17 16:35   ` [PATCH v7 3/5] pcapng: modify timestamp calculation Stephen Hemminger
2023-11-17 16:35   ` [PATCH v7 4/5] pcapng: avoid using alloca() Stephen Hemminger
2023-11-17 16:35   ` [PATCH v7 5/5] test: cleanups to pcapng test Stephen Hemminger
2023-11-22 22:42   ` [PATCH v7 0/5] dumpcap and pcapng fixes Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAC-fF8T8eo4eEWjddCRFPO3a1fRdCpHisyvVLLQC8am0Hfsh5w@mail.gmail.com \
    --to=iboukris@gmail.com \
    --cc=dev@dpdk.org \
    --cc=mb@smartsharesystems.com \
    --cc=reshma.pattan@intel.com \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).