Skip to content

Port mirroring for packet capture

Stephen Hemminger dpdk-dev 11 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v11 Latest14 patches 7 repliesIn review
  2. v1014 patches 0 repliesSuperseded
  3. v913 patches 0 repliesSuperseded
Earlier versions · 8
VersionPostedPatchesRepliesStatus
v813 patches0 repliesSuperseded
v712 patches0 repliesSuperseded
v613 patches13 repliesSuperseded
v513 patches0 repliesSuperseded
v413 patches0 repliesSuperseded
v313 patches0 repliesSuperseded
v2 RFC12 patches2 repliesSuperseded
v1 RFC13 patches12 repliesSuperseded

Patches in v11 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/14ethdev: allow start/stop from secondary processlib/ethdev/ethdev_driver.c lib/ethdev/ethdev_private.c lib/ethdev/ethdev_private.h +1 more+176 -362 replies
2/14ethdev: make sure all necessary headers includedlib/ethdev/ethdev_private.c+9 -01 reply
3/14ethdev: reorder bpf and ethdev dependencyapp/test/meson.build lib/bpf/meson.build lib/ethdev/ethdev_bpf.c +3 more+33 -271 reply
4/14bpf: add ability to load bpf into a bufferapp/test/test_bpf.c lib/bpf/bpf_load.c lib/bpf/rte_bpf.h+163 -140 replies
5/14test: add test for hotplug and secondary process operationsapp/test/meson.build app/test/test_mp_secondary.c+48 -40 replies
6/14net/ring: allow lockfree transmit if ring supports itdrivers/net/ring/rte_eth_ring.c+17 -00 replies
7/14net/ring: add new devarg to create vdev from existing ringdrivers/net/ring/rte_eth_ring.c+32 -00 replies
8/14mbuf: add dynamic flag for use by port mirroringlib/mbuf/rte_mbuf_dyn.h+9 -00 replies
9/14ethdev: add port mirroring featureapp/test/meson.build app/test/test_ethdev_mirror.c config/rte_config.h +11 more+1108 -182 replies
10/14app/testpmd: support for port mirroringapp/test-pmd/cmdline.c app/test-pmd/cmdline_mirror.c app/test-pmd/cmdline_mirror.h +2 more+236 -00 replies
11/14pcapng: split packet copy from header insertionlib/pcapng/rte_pcapng.c lib/pcapng/rte_pcapng.h+120 -850 replies
12/14pcapng: make queue optionallib/pcapng/rte_pcapng.c lib/pcapng/rte_pcapng.h+6 -50 replies
13/14app/dumpcap: use port mirror instead of pdumpapp/dumpcap/main.c app/dumpcap/meson.build+318 -770 replies
14/14doc: add documentation for port mirroringdoc/guides/prog_guide/bpf_lib.rst doc/guides/prog_guide/ethdev/index.rst doc/guides/prog_guide/ethdev/port_mirror.rst +2 more+81 -00 replies

Reviews trailers per patch

3 of 14 patches have a Reviewed-by or Acked-by.

PatchKhadem UllahAndrew Rybchenko
1/14A-b R-b
2/14A-b
3/14A-b
4/14
5/14
6/14
7/14
8/14
9/14
10/14
11/14
12/14
13/14
14/14

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v11 thread

Cover letter [PATCH v11 00/14] Port mirroring for packet capture

This is a rework of how packet capture is done in DPDK.
The existing mechanism using callbacks has a number of problems:
- can't work when packets are sent and received in secondary process because callbacks only function in the primary process
- requires "opt-in" from application

The new mechanism builds on the concept of port mirroring used in Linux/FreeBSD and also router vendors (SPAN ports).
See: https://en.wikipedia.org/wiki/Port_mirroring for a general description.

The implementation uses two new ethdev API's:
one to add a port mirror, and one to remove it.

The internals of dumpcap are redone but the program command syntax is unchanged (no doc change needed). Using the new mirror mechanism, the dumpcap program creates a port using ring PMD and then directs a port mirror to that new ring PMD instance. Then the packets are extracted from the ring. If capturing on multiple devices, they all get mirrored to the same ring PMD.

The dumpcap program needs to be able to start the ring PMD it created but the existing ethdev API is broken when used from secondary process. One of the patches fixes that, it was also reported previously in Bugzilla.

The mirror API is optimized to use lockless transmit if possible. Fix the ring and null PMD to allow lockless transmit for use by capture.

Added tests for the mirror features.
The performance has not been measured but the overhead of checking for mirror port is no more that the overhead of looking at the callback list.

v11 - fix build if BPF is disabled
- allow mirroring to device that is not lockfree

Stephen Hemminger (14):
ethdev: allow start/stop from secondary process
ethdev: make sure all necessary headers included
ethdev: reorder bpf and ethdev dependency
bpf: add ability to load bpf into a buffer
test: add test for hotplug and secondary process operations net/ring: allow lockfree transmit if ring supports it net/ring: add new devarg to create vdev from existing ring
mbuf: add dynamic flag for use by port mirroring
ethdev: add port mirroring feature
app/testpmd: support for port mirroring
pcapng: split packet copy from header insertion
pcapng: make queue optional
app/dumpcap: use port mirror instead of pdump
doc: add documentation for port mirroring

 app/dumpcap/main.c                           | 392 +++++++++++---
 app/dumpcap/meson.build                      |   3 +-
 app/test-pmd/cmdline.c                       |  13 +
 app/test-pmd/cmdline_mirror.c                | 194 +++++++
 app/test-pmd/cmdline_mirror.h                |  13 +
 app/test-pmd/meson.build                     |   1 +
 app/test/meson.build                         |   9 +-
 app/test/test_bpf.c                          |  28 +
 app/test/test_ethdev_mirror.c                | 325 ++++++++++++
 app/test/test_mp_secondary.c                 |  50 +-
 config/rte_config.h                          |   1 +
 doc/guides/prog_guide/bpf_lib.rst            |   2 +
 doc/guides/prog_guide/ethdev/index.rst       |   1 +
 doc/guides/prog_guide/ethdev/port_mirror.rst |  68 +++
 doc/guides/rel_notes/deprecation.rst         |   5 +
 doc/guides/rel_notes/release_25_11.rst       |   5 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst  |  15 +
 drivers/net/ring/rte_eth_ring.c              |  49 ++
 lib/bpf/bpf_load.c                           | 111 +++-
 lib/bpf/meson.build                          |   9 +-
 lib/bpf/rte_bpf.h                            |  38 ++
 lib/{bpf/bpf_pkt.c => ethdev/ethdev_bpf.c}   |  35 +-
 lib/ethdev/ethdev_driver.c                   |  12 +-
 lib/ethdev/ethdev_driver.h                   |   6 +
 lib/ethdev/ethdev_private.c                  | 141 +++++
 lib/ethdev/ethdev_private.h                  |  29 ++
 lib/ethdev/ethdev_trace.h                    |  17 +
 lib/ethdev/ethdev_trace_points.c             |   6 +
 lib/ethdev/meson.build                       |   8 +
 lib/{bpf => ethdev}/rte_bpf_ethdev.h         |   0
 lib/ethdev/rte_ethdev.c                      |  99 ++--
 lib/ethdev/rte_ethdev.h                      |  23 +-
 lib/ethdev/rte_ethdev_core.h                 |  12 +-
 lib/ethdev/rte_mirror.c                      | 508 +++++++++++++++++++
 lib/ethdev/rte_mirror.h                      | 147 ++++++
 lib/mbuf/rte_mbuf_dyn.h                      |   9 +
 lib/meson.build                              |   4 +-
 lib/pcapng/rte_pcapng.c                      | 179 ++++---
 lib/pcapng/rte_pcapng.h                      |  27 +-
 39 files changed, 2342 insertions(+), 252 deletions(-)
 create mode 100644 app/test-pmd/cmdline_mirror.c
 create mode 100644 app/test-pmd/cmdline_mirror.h
 create mode 100644 app/test/test_ethdev_mirror.c
 create mode 100644 doc/guides/prog_guide/ethdev/port_mirror.rst
 rename lib/{bpf/bpf_pkt.c => ethdev/ethdev_bpf.c} (95%)
 rename lib/{bpf => ethdev}/rte_bpf_ethdev.h (100%)
 create mode 100644 lib/ethdev/rte_mirror.c
 create mode 100644 lib/ethdev/rte_mirror.h
Signature · 1 line
2.47.2