Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/Dockerfile.base
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ FROM ubuntu:24.04
ENV DEBIAN_FRONTEND noninteractive

RUN apt update -y
RUN apt install -y meson clang
RUN apt install -y meson clang cmake
RUN apt install -y python3-pyelftools libnuma-dev libpcap-dev git
1 change: 1 addition & 0 deletions .github/workflows/Dockerfile.base.dev
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ ARG PROTOC_GEN_GO_GRPC_VERSION=latest

RUN apt-get update -y && apt-get install -y \
meson \
cmake \
clang \
clang-format-19 \
clang-tidy-19 \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: meson clang python3-pyelftools libnuma-dev libpcap-dev git protobuf-compiler jq clang-tidy-19
packages: meson clang cmake python3-pyelftools libnuma-dev libpcap-dev git protobuf-compiler jq clang-tidy-19
version: 1.1

- name: Install LLVM 19 toolchain
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/fuzz-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: meson clang python3-pyelftools libnuma-dev libpcap-dev git protobuf-compiler jq
packages: meson clang cmake python3-pyelftools libnuma-dev libpcap-dev git protobuf-compiler jq
version: 1.1

- uses: actions/checkout@v4
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "subprojects/dpdk"]
path = subprojects/dpdk
url = https://github.com/yanet-platform/dpdk
[submodule "subprojects/libpcap"]
path = subprojects/libpcap
url = https://github.com/the-tcpdump-group/libpcap.git
75 changes: 56 additions & 19 deletions modules/pdump/api/meson.build
Original file line number Diff line number Diff line change
@@ -1,38 +1,75 @@
cp_dependencies = [
lib_common_dep,
lib_config_cp_dep,
]
pdump_dataplane_inc = include_directories('../dataplane')

ext_deps = ['rte_bpf']
# libpcap: git submodule at subprojects/libpcap, built with CMake into this
# module's build dir (Meson's cmake.subproject hits a dependency cycle in upstream libpcap).
fs = import('fs')
cmake = find_program('cmake', required: true, version: '>=3.5')
pcap_src_root = meson.project_source_root() / 'subprojects' / 'libpcap'
if not fs.exists(pcap_src_root / 'CMakeLists.txt')
error(
'pdump: missing libpcap sources at subprojects/libpcap. Initialize git submodules: git submodule update --init --recursive',
)
endif

foreach e:ext_deps
cp_dependencies += libdpdk.get_variable('static_' + e)
endforeach
pcap_cmake_build = meson.current_build_dir() / 'external' / 'libpcap-cmake'
pcap_prefix = meson.current_build_dir() / 'external' / 'libpcap-install'
libpcap_a = pcap_prefix / 'lib' / 'libpcap.a'

pdump_cp_link_deps = []
foreach l:libdpdk.get_variable('dpdk_static_libraries')
if l.name() in ext_deps
pdump_cp_link_deps += l
endif
endforeach
pcap_cmake_args = [
'-S', pcap_src_root,
'-B', pcap_cmake_build,
'-G', 'Ninja',
'-DCMAKE_INSTALL_PREFIX=' + pcap_prefix,
'-DCMAKE_BUILD_TYPE=' + (get_option('buildtype') == 'debug' ? 'Debug' : 'RelWithDebInfo'),
'-DBUILD_SHARED_LIBS=OFF',
'-DDISABLE_BLUETOOTH=ON',
'-DDISABLE_NETMAP=ON',
'-DDISABLE_DPDK=ON',
'-DDISABLE_DBUS=ON',
'-DDISABLE_RDMA=ON',
'-DDISABLE_DAG=ON',
'-DDISABLE_SEPTEL=ON',
'-DDISABLE_SNF=ON',
'-DDISABLE_TC=ON',
'-DCMAKE_C_FLAGS=' + ' '.join(yanet_c_args),
'-DCMAKE_EXE_LINKER_FLAGS=' + ' '.join(yanet_link_args),
'-DCMAKE_SHARED_LINKER_FLAGS=' + ' '.join(yanet_link_args),
'-DCMAKE_MODULE_LINKER_FLAGS=' + ' '.join(yanet_link_args),
]
if host_machine.system() == 'linux'
pcap_cmake_args += ['-DBUILD_WITH_LIBNL=OFF', '-DDISABLE_LINUX_USBMON=ON']
endif

pdump_dataplane_inc = include_directories('../dataplane')
if not fs.exists(libpcap_a)
message('[pdump] Configuring libpcap with CMake in ' + pcap_cmake_build)
run_command(cmake, pcap_cmake_args, check: true)
message('[pdump] Building and installing libpcap to ' + pcap_prefix)
run_command(cmake, '--build', pcap_cmake_build, '--target', 'install', check: true)
else
message('[pdump] Reusing built libpcap: ' + libpcap_a)
endif

api_sources = files(
'controlplane.c',
pcap_libdir = pcap_prefix / 'lib'
pcap_incdir = pcap_prefix / 'include'
message('[pdump] Linking pdump_cp with static libpcap from ' + pcap_libdir)
libpcap_dep = declare_dependency(
compile_args: ['-I' + pcap_incdir],
dependencies: cc.find_library('pcap', dirs: pcap_libdir, static: true),
)

cp_dependencies = [lib_common_dep, lib_config_cp_dep, libdpdk_dep, libpcap_dep]
api_sources = files('controlplane.c')

lib_pdump_cp = static_library(
'pdump_cp',
api_sources,
c_args: yanet_c_args,
link_args: yanet_link_args,
link_whole: pdump_cp_link_deps,
dependencies: cp_dependencies,
include_directories: [yanet_rootdir, pdump_dataplane_inc],
install: false,
)

lib_pdump_cp_dep = declare_dependency(
link_with: lib_pdump_cp,
dependencies: cp_dependencies,
)
3 changes: 2 additions & 1 deletion modules/pdump/controlplane/ffi.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package pdump

//#cgo CFLAGS: -I../../../ -I../dataplane
//#cgo CFLAGS: -I../../../build/modules/pdump/api/external/libpcap-install/include
//#cgo LDFLAGS: -L../../../build/modules/pdump/api -lpdump_cp
//#cgo LDFLAGS: -lpcap
//#cgo LDFLAGS: -L../../../build/modules/pdump/api/external/libpcap-install/lib -Wl,-Bstatic -lpcap -Wl,-Bdynamic
//
//#include <stdlib.h>
//#include "modules/pdump/api/controlplane.h"
Expand Down
1 change: 1 addition & 0 deletions subprojects/libpcap
Submodule libpcap added at bbcbc9
Loading