DPDK patches and discussions
 help / color / mirror / Atom feed
From: Reshma Pattan <reshma.pattan@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v3 0/5] add dpdk packet capture support for tcpdump
Date: Wed,  2 Mar 2016 12:16:05 +0000	[thread overview]
Message-ID: <1456920970-2047-1-git-send-email-reshma.pattan@intel.com> (raw)
In-Reply-To: <1455289045-25915-1-git-send-email-reshma.pattan@intel.com>

This patch set include the design to capture packets from dpdk ports for tcpdump.

This patch set include test-pmd changes to verify below patch set.
http://dpdk.org/dev/patchwork/patch/9750/
http://dpdk.org/dev/patchwork/patch/9751/
http://dpdk.org/dev/patchwork/patch/9752/

Dependencies 1:
Patches 2/5 and 3/5 of current patch set contains pcap based design.
So to compile and run these patches, libpcap must be installed and pcap
config option should be set to yes i.e. CONFIG_RTE_LIBRTE_PMD_PCAP=y.

packet capture flow for tcpdump:
================================
Part of the design is implemented in secondary process (proc_info.c) and other part
in primary process (eal_interrupt.c).

Communication between primary and secondary processes is provided using socket and rte_ring.

[Secondary process: proc_info application]
*Changes are included in the patch 3/5

*User should request packet capture via proc_info application command line by passing newly
added tcpdump command line options i.e. [--tcpdump (port,queue)] [ --src-ip-filter \"A.B.C.D\"]
[--single-tcpdump-file].

Note: As basic support, a src ip filter option is provided for filtering the packets.
This is optional. If user dont provide any src ip filter option all packets will be captured
for tcpdump.

*proc_info application sends port, queue and src ip filter information to primary process
along with register rx tx callbacks message.

*proc_info application either writes ingress, egress packets to seperate RX and TX pcap files,
or writes both ingress and egress packets to single RX_TX pcap file.
This behaviour can be controlled by passing command line option "--sicgle-tcpdump-file".

*proc_info application runs in a while loop, dequeues packets sent by primary process over
shared rte_ring and write the packets to pcap file.

[Primary Process]:
*Changes are included in the patch 4/5.

*Creates rte_rings and mempool used for communicating the packets with the secondary process.

*Creates socket, waits on socket for message from secondary process.

*Upon receiving the register rx tx callbacks message, registers ''rte_eth_rxtx_callbacks''
for receiving ingress and egress packets of given port and queue.

*RX callback:
    Get the packets, apply src ip filter, for the matched packets duplicate packets will be
    created from new mempool and the new duplicated packets will be enqueued to
    rte_ring for the secondary process to dequeue and write to pcap.

    Note: If user dont provide any src ip filter option, all the packets are captured.

*TX callback:
    Gets the packets, apply src ip filter, for the matched packets increments reference
    counter of the packet, enqueue to other rte_ring for the secondary process to dequeue and
    write to pcap.

    Note: If user dont provide any src ip filter option, all the packets are captured.

[Secondary Process]:
*When the secondary process is terminated with ''ctrl+c'', secondary process sends remove
rx tx callbacks message to the primary process.

*[Primary Process]:
*When the primary process receives remove rx tx callbacks message, it removes registered rxtx callbacks.

Users who wish to view packets can run "tcpdump -r RX_pcap.pcap/TX_pcap.pcap/RX_TX_pcap.pcap"
to view packets of interest.

Running the changes:
===================
1)Start any primary sample application.
ex:sudo ./examples/rxtx_callbacks/build/rxtx_callbacks -c 0x2 -n 2

2)Start traffic from traffic generator.

3)Start proc_info(runs as secondary process by default)application with new parameters for tcpdump.
these parameters can be mix and matched to acheive different usability experience
ex1:

sudo ./build/app/proc_info/dpdk_proc_info -c 0x4 -n 2 -- -p 0x3 --tcpdump '(0,0)(1,0)' --src-ip-filter="2.2.2.2"

packets from queue 0 of each port matching with src ip filter are captured to /tmp/RX_pcap.pcap, /tmp/TX_pcap.pcap.

ex2:

sudo ./build/app/proc_info/dpdk_proc_info -c 0x4 -n 2 -- -p 0x3 --tcpdump '(0,*)(1,*)' --src-ip-filter="2.2.2.2" --single-tcpdump-file

packets from all queues of each port matching with src ip filter are captured to single pcap file i.e. /tmp/RX_TX_pcap.pcap.

ex3:

sudo ./build/app/proc_info/dpdk_proc_info -c 0x4 -n 2 -- -p 0x3 --tcpdump '(0,*)(1,0)'

packets from all queues of port 0 and packets from queue 0 of port 1 are captured to /tmp/RX_pcap.pcap, /tmp/TX_pcap.pcap.

4)Stop the secondary process using "ctrl+c" and rerun it, packet capturing should start again.

Note 1: For every start of proc_info application existing pacp files from /tmp/ folder will be removed and
new ones will be created.
Note 2: Secondary process must use cores different from the primary process cores.

Known limitations:
1: Writing to PCAP files will be stopped once the folder size where pcap files exists reaches its max value.
2: Because of the underlying pcap writing overhead packets can only be captured at slow rates.

v3:
* added tcpdump design changes to programmers guide and proc_info sample
  application guide.

* updated packet capture logic in eal_interrupts.c and proc_info/main.c
  to capture packets from all queues of given port when queue is specified as '*'.
  in --tcpdump '(port,queue)' command line option.

* updated packet capture logic in eal_interrupts.c, to capture all packets when
  "--src-ip-filter" option is not specified.

* added new "--single-tcpdump-file" command line option to the proc_info application to
  enable packet capturing to single pcap file. If option not specified ingress and
  egress packets will be captured to seperate RX & TX pcap files.

* removed blank line from EOF of rte_pmd_pcap_version.map.

v2:
* extended nb_rxq/nb_txq check to other fwd modes along with rx_only and tx_only.
* changed some of the global variables to static in proc_info/main.c and eal_interrupts.c.
* release notes updated.

Reshma Pattan (5):
  app/test-pmd: fix nb_rxq and nb_txq checks
  drivers/net/pcap: add public api to create pcap device
  app/proc_info: add tcpdump support in secondary process
  lib/librte_eal: add tcpdump support in primary process
  doc: update doc for tcpdump feature

 app/proc_info/main.c                            |  472 ++++++++++++++++++++++-
 app/test-pmd/cmdline.c                          |   11 +-
 app/test-pmd/parameters.c                       |   14 +-
 app/test-pmd/testpmd.c                          |   28 ++-
 doc/guides/prog_guide/env_abstraction_layer.rst |   43 ++-
 doc/guides/rel_notes/release_16_04.rst          |    6 +
 doc/guides/sample_app_ug/proc_info.rst          |   57 +++-
 drivers/net/pcap/Makefile                       |    4 +-
 drivers/net/pcap/rte_eth_pcap.c                 |  156 +++++++-
 drivers/net/pcap/rte_eth_pcap.h                 |   87 +++++
 drivers/net/pcap/rte_pmd_pcap_version.map       |    7 +
 lib/librte_eal/linuxapp/eal/Makefile            |    5 +-
 lib/librte_eal/linuxapp/eal/eal_interrupts.c    |  422 ++++++++++++++++++++-
 13 files changed, 1261 insertions(+), 51 deletions(-)
 create mode 100644 drivers/net/pcap/rte_eth_pcap.h

-- 
1.7.4.1

  parent reply	other threads:[~2016-03-02 12:16 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-12 14:57 [dpdk-dev] [PATCH v2 " Reshma Pattan
2016-02-12 14:57 ` [dpdk-dev] [PATCH v2 1/5] app/test-pmd: fix nb_rxq and nb_txq checks Reshma Pattan
2016-02-12 14:57 ` [dpdk-dev] [PATCH v2 2/5] drivers/net/pcap: add public api to create pcap device Reshma Pattan
2016-02-17  9:03   ` Pavel Fedin
2016-02-12 14:57 ` [dpdk-dev] [PATCH v2 3/5] app/proc_info: add tcpdump support in secondary process Reshma Pattan
2016-02-12 14:57 ` [dpdk-dev] [PATCH v2 4/5] lib/librte_eal: add tcpdump support in primary process Reshma Pattan
2016-02-17  9:57   ` Pavel Fedin
2016-02-12 14:57 ` [dpdk-dev] [PATCH v2 5/5] doc: update doc for tcpdump feature Reshma Pattan
2016-02-22 10:01   ` Mcnamara, John
2016-02-18 14:08 ` [dpdk-dev] [PATCH v2 0/5] add dpdk packet capture support for tcpdump Pavel Fedin
2016-02-23 13:16   ` Pattan, Reshma
2016-02-24 15:04     ` Pavel Fedin
2016-02-29 16:11       ` Pattan, Reshma
2016-03-02 12:16 ` Reshma Pattan [this message]
2016-03-02 12:16   ` [dpdk-dev] [PATCH v3 1/5] app/test-pmd: fix nb_rxq and nb_txq checks Reshma Pattan
2016-03-02 12:16   ` [dpdk-dev] [PATCH v3 2/5] drivers/net/pcap: add public api to create pcap device Reshma Pattan
2016-03-02 12:16   ` [dpdk-dev] [PATCH v3 3/5] app/proc_info: add tcpdump support in secondary process Reshma Pattan
2016-03-02 12:16   ` [dpdk-dev] [PATCH v3 4/5] lib/librte_eal: add tcpdump support in primary process Reshma Pattan
2016-03-02 12:16   ` [dpdk-dev] [PATCH v3 5/5] doc: update doc for tcpdump feature Reshma Pattan
2016-03-09  0:33   ` [dpdk-dev] [PATCH v3 0/5] add dpdk packet capture support for tcpdump Thomas Monjalon
2016-03-11 14:18     ` Pattan, Reshma

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=1456920970-2047-1-git-send-email-reshma.pattan@intel.com \
    --to=reshma.pattan@intel.com \
    --cc=dev@dpdk.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).