-
Notifications
You must be signed in to change notification settings - Fork 26
infra: add pdump support for live packet capture with tcpdump #561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,7 +65,7 @@ dpdk_dep = dependency( | |
| 'werror=false', | ||
| 'tests=false', | ||
| 'enable_drivers=net/virtio,net/vhost,net/i40e,net/ice,net/iavf,net/ixgbe,net/null,net/tap,common/mlx5,net/mlx5,bus/auxiliary,net/vmxnet3', | ||
| 'enable_libs=graph,hash,fib,rib,pcapng,gso,vhost,cryptodev,dmadev,security', | ||
| 'enable_libs=graph,hash,fib,rib,pcapng,pdump,bpf,gso,vhost,cryptodev,dmadev,security', | ||
| 'disable_apps=*', | ||
| 'enable_docs=false', | ||
| 'developer_mode=disabled', | ||
|
|
@@ -156,6 +156,42 @@ pkg.generate( | |
| install_dir: get_option('datadir') / 'pkgconfig', | ||
| ) | ||
|
|
||
| # libpcap with DPDK pdump support (for tcpdump packet capture against grout). | ||
| # Builds libpcap.so with grout:N device support. Stock tcpdump picks it up | ||
| # via LD_LIBRARY_PATH or system install — no tcpdump recompilation needed. | ||
| libpcap_srcdir = meson.current_source_dir() / 'subprojects' / 'libpcap' | ||
| libpcap_builddir = meson.current_build_dir() / 'libpcap-build' | ||
|
|
||
| dpdk_pkgconfig_path = meson.global_build_root() / 'meson-uninstalled' | ||
| dpdk_pc_path = meson.global_build_root() / 'meson-private' | ||
|
|
||
| libpcap_build = custom_target( | ||
| 'libpcap', | ||
| output: '.libpcap-stamp', | ||
| command: [ | ||
| 'sh', '-c', | ||
| 'mkdir -p "' + libpcap_builddir + '" && ' + | ||
| 'cd "' + libpcap_builddir + '" && ' + | ||
| 'export PKG_CONFIG_PATH="' + dpdk_pkgconfig_path + ':' + dpdk_pc_path + ':$PKG_CONFIG_PATH" && ' + | ||
| 'DPDK_LIBDIR="' + meson.global_build_root() + '/subprojects/dpdk/lib" && ' + | ||
| 'DPDK_DRVDIR="' + meson.global_build_root() + '/subprojects/dpdk/drivers" && ' + | ||
| 'cmake "' + libpcap_srcdir + '" ' + | ||
| '-DDISABLE_DPDK:BOOL=OFF ' + | ||
| '-DHAVE_RTE_ETH_DEV_COUNT_AVAIL:BOOL=ON ' + | ||
| '-DHAVE_STRUCT_RTE_ETHER_ADDR:BOOL=ON ' + | ||
| '-DDISABLE_DBUS:BOOL=ON ' + | ||
| '-DDISABLE_RDMA:BOOL=ON ' + | ||
| '-DDISABLE_BLUETOOTH:BOOL=ON ' + | ||
| '-DDISABLE_NETMAP:BOOL=ON ' + | ||
| '-DBUILD_SHARED_LIBS:BOOL=ON ' + | ||
| '"-DCMAKE_SHARED_LINKER_FLAGS=-L$DPDK_LIBDIR -L$DPDK_DRVDIR -Wl,-rpath,$DPDK_LIBDIR:$DPDK_DRVDIR" ' + | ||
| '&& make -j pcap && ' + | ||
| 'ln -sf libpcap.so.1 libpcap.so.0.8 && ' + | ||
| 'touch "@OUTPUT@"', | ||
| ], | ||
| build_by_default: true, | ||
| ) | ||
|
Comment on lines
+168
to
+193
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing build dependency on DPDK could cause parallel build failures. The Proposed fix libpcap_build = custom_target(
'libpcap',
output: '.libpcap-stamp',
+ depends: dpdk_dep.type_name() == 'internal' ? subproject('dpdk').get_variable('dpdk_lib') : [],
command: [Alternatively, if libpcap_build = custom_target(
'libpcap',
output: '.libpcap-stamp',
+ depends: [grout_exe],
command: [🤖 Prompt for AI Agents |
||
|
|
||
| cmocka_dep = dependency('cmocka', required: get_option('tests')) | ||
| if cmocka_dep.found() | ||
| fs = import('fs') | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| [wrap-git] | ||
| url = https://github.com/vjardin/libpcap | ||
| revision = vj_add_dpdk_grout | ||
| depth = 1 | ||
|
|
||
| [provide] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/bin/bash | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
| # Copyright (c) 2026 Vincent Jardin, Free Mobile, Iliad | ||
| # | ||
| # Wrapper to run system tcpdump with grout's libpcap (DPDK pdump support). | ||
| # | ||
| # This is a temporary workaround until libpcap merges the DPDK pdump | ||
| # capture module upstream and Linux distributions enable it at compile | ||
| # time. Track progress at: | ||
| # https://github.com/the-tcpdump-group/libpcap/pull/1656 | ||
| # | ||
| # Once distributions ship a libpcap with PCAP_SUPPORT_DPDK_PDUMP, | ||
| # this script is no longer needed — tcpdump will natively support | ||
| # "grout:N" devices. | ||
| # | ||
| # Usage: sudo ./subprojects/packagefiles/libpcap/grout-tcpdump.sh -i grout:0 -n | ||
|
|
||
| SCRIPT="$(readlink -f "$0")" | ||
| BASEDIR="$(dirname "$SCRIPT")/../../.." | ||
| LIBPCAP_DIR="$BASEDIR/build/libpcap-build" | ||
| DPDK_LIBDIR="$BASEDIR/build/subprojects/dpdk/lib" | ||
| DPDK_DRVDIR="$BASEDIR/build/subprojects/dpdk/drivers" | ||
|
|
||
| if [ ! -f "$LIBPCAP_DIR/libpcap.so" ]; then | ||
| echo "error: $LIBPCAP_DIR/libpcap.so not found, build grout first" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Our libpcap.so.0.8 symlink is found before the system one. | ||
| export LD_LIBRARY_PATH="$LIBPCAP_DIR:$DPDK_LIBDIR:$DPDK_DRVDIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" | ||
|
|
||
| # Tell the DPDK secondary process where to find PMD drivers. | ||
| # The compiled-in path (RTE_EAL_PMD_PATH) points to an install prefix | ||
| # that doesn't exist in a development build tree. | ||
| export DPDK_CFG="--proc-type=secondary -l0 --no-telemetry --log-level=critical -d $DPDK_DRVDIR" | ||
|
|
||
| exec tcpdump "$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
DPDK rte_pdump_init return value and rte_errno💡 Result:
The DPDK function rte_pdump_init returns an int value: 0 on success. It returns -1 on failure, in which case rte_errno is set accordingly to indicate the specific error condition. This follows the standard DPDK API convention for functions returning int, as seen in related APIs like rte_pdump_enable and older documentation explicitly stating "Returns: 0 on success, -1 on error, rte_errno is set accordingly." (e.g., DPDK 17.11 docs). No specific error codes unique to rte_pdump_init are documented; rte_errno provides DPDK-specific or system error details (e.g., E_RTE_SECONDARY if called from secondary process). Official DPDK documentation and manpages confirm the signature int rte_pdump_init(void) and usage in primary processes like testpmd for initializing the packet capture framework.
Citations:
Incorrect error code extraction from
rte_pdump_init().rte_pdump_init()returns -1 on failure with the actual error code stored inrte_errno. The current code negates the return value (yielding 1), which loses the real error information.Proposed fix
if (gr_config.pdump) { ret = rte_pdump_init(); if (ret < 0) { - ret = -ret; + ret = rte_errno; LOG(ERR, "rte_pdump_init: %s", rte_strerror(ret)); goto end; } LOG(NOTICE, "pdump enabled, secondary processes can attach for packet capture"); }🤖 Prompt for AI Agents