Skip to content

Commit 1c42cad

Browse files
author
Pavel Siska
committed
Merge branch 'rpm-dpdk' of gitlab.liberouter.org:monitoring/ipfixprobe
2 parents 39bb08e + 0624fa4 commit 1c42cad

File tree

12 files changed

+563
-39
lines changed

12 files changed

+563
-39
lines changed

.gitlab-ci.yml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
default:
2+
image: $CI_REGISTRY/monitoring/ipfixprobe/rpmbuilder:latest
3+
4+
stages:
5+
- prepare
6+
- build
7+
- test
8+
- packages
9+
- deploy
10+
11+
ci_rpmbuilder:
12+
stage: prepare
13+
image: docker:latest
14+
services:
15+
- docker:dind
16+
variables:
17+
REPOSITORY: $CI_REGISTRY/monitoring/ipfixprobe/rpmbuilder
18+
19+
before_script:
20+
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
21+
script:
22+
- cd docker/rpmbuilder; docker build -t $REPOSITORY:latest .
23+
- docker push $REPOSITORY:latest
24+
only:
25+
changes:
26+
- docker/rpmbuilder/Dockerfile
27+
28+
ci_rpmbuilder_dpdk:
29+
stage: prepare
30+
image: docker:latest
31+
services:
32+
- docker:dind
33+
variables:
34+
REPOSITORY: $CI_REGISTRY/monitoring/ipfixprobe/rpmbuilder-dpdk
35+
36+
before_script:
37+
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
38+
script:
39+
- cd docker/rpmbuilder-dpdk; docker build -t $REPOSITORY:latest .
40+
- docker push $REPOSITORY:latest
41+
only:
42+
changes:
43+
- docker/rpmbuilder-dpdk/Dockerfile
44+
45+
ci_rpmbuilder_el7:
46+
stage: prepare
47+
image: docker:latest
48+
services:
49+
- docker:dind
50+
variables:
51+
REPOSITORY: $CI_REGISTRY/monitoring/ipfixprobe/rpmbuilder-epel7
52+
53+
before_script:
54+
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
55+
script:
56+
- cd docker/rpmbuilder-epel7/; docker build -t $REPOSITORY:latest .
57+
- docker push $REPOSITORY:latest
58+
only:
59+
changes:
60+
- docker/rpmbuilder-epel7/Dockerfile
61+
62+
basic-build:
63+
stage: build
64+
script:
65+
- autoreconf -i
66+
- ./configure -q
67+
- make
68+
artifacts:
69+
paths:
70+
- ipfixprobe
71+
cache:
72+
paths:
73+
- "*.o"
74+
75+
# run tests using the binary built before
76+
test:
77+
stage: test
78+
before_script:
79+
- git submodule init
80+
- git submodule update
81+
script:
82+
- autoreconf -i
83+
- ./configure -q --with-pcap --with-nemea --with-gtest
84+
- make check
85+
86+
buildrpm:
87+
stage: packages
88+
script:
89+
- autoreconf -i
90+
- ./configure -q
91+
- make rpm-nemea
92+
- make rpm-ndp
93+
artifacts:
94+
paths:
95+
- RPMBUILD/RPMS/
96+
- RPMBUILD/SRPMS/
97+
98+
buildrpmdpdk:
99+
stage: packages
100+
image: $CI_REGISTRY/monitoring/ipfixprobe/rpmbuilder-dpdk
101+
script:
102+
- autoreconf -i
103+
- ./configure -q
104+
- make rpm-nemea
105+
- make rpm-dpdk
106+
artifacts:
107+
paths:
108+
- RPMBUILD/RPMS/
109+
- RPMBUILD/SRPMS/
110+
111+
deploy:
112+
stage: deploy
113+
only:
114+
- rpm-dpdk
115+
before_script:
116+
- microdnf -y install copr-cli git
117+
script:
118+
- echo "Prepare COPR config..."
119+
- mkdir ~/.config
120+
- echo -e "[copr-cli]\nlogin = LOGIN\nusername = cejkat\ncopr_url = https://copr.fedorainfracloud.org\ntoken = TOKEN" | sed "s/TOKEN/${COPR_TOKEN}/; s/LOGIN/${COPR_LOGIN}/" > ~/.config/copr
121+
- echo "Run RPM build using COPR..."
122+
- copr build --nowait @CESNET/NEMEA RPMBUILD/SRPMS/ipfixprobe-dpdk-*.src.rpm
123+
- echo "Application successfully deployed."
124+
dependencies:
125+
- buildrpmdpdk
126+
127+
buildrpm_epel7:
128+
stage: packages
129+
image: $CI_REGISTRY/monitoring/ipfixprobe/rpmbuilder-epel7
130+
script:
131+
- autoreconf -i
132+
- ./configure -q
133+
- make rpm-ndp
134+
- make rpm-nemea
135+
artifacts:
136+
paths:
137+
- RPMBUILD/RPMS/
138+
- RPMBUILD/SRPMS/
139+

Makefile.am

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ bin_PROGRAMS=ipfixprobe ipfixprobe_stats
99

1010
DISTCHECK_CONFIGURE_FLAGS="--with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)"
1111

12+
AM_CPPFLAGS=-I$(srcdir)/include/
13+
1214
ipfixprobe_LDFLAGS=-lpthread -ldl -latomic -ltelemetry -lappFs
1315
ipfixprobe_CFLAGS=-I$(srcdir)/include/ -fPIC -DFUSE_USE_VERSION=30
1416
ipfixprobe_CXXFLAGS=-std=gnu++17 -Wno-write-strings -I$(srcdir)/include/ -fPIC -DFUSE_USE_VERSION=30
@@ -33,13 +35,24 @@ ipfixprobe_input_src=\
3335
#example_la_SOURCES=example.cpp example.hpp
3436
#example_la_LDFLAGS=-module -shared -avoid-version
3537

38+
if ENABLE_PCAP
39+
pkglib_LTLIBRARIES=input-pcap.la
40+
input_pcap_la_SOURCES= input/pcap.cpp input/pcap.hpp
41+
input_pcap_la_LDFLAGS=-module -shared -avoid-version -lpcap
42+
endif
3643

3744
if WITH_NDP
3845
ipfixprobe_LDFLAGS+=-lnuma -lndpRI -L$(srcdir)/input/nfbCInterface/
3946
ipfixprobe_CXXFLAGS+=-I$(srcdir)/input/nfbCInterface/include/
4047
ipfixprobe_input_src+=\
4148
input/ndp.cpp \
4249
input/ndp.hpp
50+
51+
pkglib_LTLIBRARIES=input-ndp.la
52+
input_ndp_la_CXXFLAGS=-I$(srcdir)/input/nfbCInterface/include/
53+
input_ndp_la_SOURCES= input/ndp.cpp input/ndp.hpp
54+
input_ndp_la_LDFLAGS=-module -shared -avoid-version -lnuma -lndpRI -L$(srcdir)/input/nfbCInterface/
55+
4356
endif
4457

4558
if WITH_RAW
@@ -175,8 +188,7 @@ ipfixprobe_input_src+=\
175188
endif
176189

177190
if WITH_DPDK
178-
ipfixprobe_input_src+=\
179-
input/dpdk/dpdkMbuf.hpp \
191+
dpdk_src_files=input/dpdk/dpdkMbuf.hpp \
180192
input/dpdk/dpdkMbuf.cpp \
181193
input/dpdk/dpdkDevice.hpp \
182194
input/dpdk/dpdkDevice.cpp \
@@ -185,10 +197,19 @@ ipfixprobe_input_src+=\
185197
input/dpdk/dpdkPortTelemetry.cpp \
186198
input/dpdk/dpdkTelemetry.hpp \
187199
input/dpdk/dpdkTelemetry.cpp \
188-
input/dpdk.cpp \
189-
input/dpdk.h \
190-
input/dpdk-ring.cpp \
191-
input/dpdk-ring.h
200+
input/dpdk.cpp \
201+
input/dpdk.h \
202+
input/dpdk-ring.cpp \
203+
input/dpdk-ring.h
204+
205+
ipfixprobe_input_src+=$(dpdk_src_files)
206+
207+
pkglib_LTLIBRARIES=input-dpdk.la
208+
input_dpdk_la_CFLAGS=-I$(srcdir)/include/ $(DPDK_CFLAGS)
209+
input_dpdk_la_CXXFLAGS=$(DPDK_CFLAGS)
210+
input_dpdk_la_SOURCES=$(dpdk_src_files)
211+
input_dpdk_la_LDFLAGS=-module -shared -avoid-version $(DPDK_LIBS)
212+
192213
endif
193214

194215
ipfixprobe_headers_src=\
@@ -305,6 +326,8 @@ srpm:
305326
make ${AM_MAKEFLAGS} distdir='$(RPMDIR)/SOURCES/$(RPMFILENAME)' distdir
306327
( cd "$(RPMDIR)/SOURCES/"; tar -z -c -f $(RPMFILENAME)-$(RELEASE).tar.gz $(RPMFILENAME); rm -rf $(RPMFILENAME); )
307328
$(RPMBUILD) -bs $(PACKAGE_NAME).spec --define "_topdir `pwd`/$(RPMDIR)";
329+
$(RPMBUILD) -bs $(PACKAGE_NAME)-dpdk.spec --define "_topdir `pwd`/$(RPMDIR)";
330+
$(RPMBUILD) -bs $(PACKAGE_NAME)-ndp.spec --define "_topdir `pwd`/$(RPMDIR)";
308331

309332
.PHONY: rpm
310333
rpm: srpm
@@ -316,7 +339,11 @@ rpm-nemea: srpm
316339

317340
.PHONY: rpm-ndp
318341
rpm-ndp: srpm
319-
$(RPMBUILD) --define "_topdir `pwd`/$(RPMDIR)" --rebuild $(RPMDIR)/SRPMS/$(RPMFILENAME)-$(RELEASE).src.rpm --with ndp --with unwind;
342+
$(RPMBUILD) --define "_topdir `pwd`/$(RPMDIR)" --rebuild $(RPMDIR)/SRPMS/$(PACKAGE_NAME)-ndp-$(VERSION)-$(RELEASE).src.rpm --with unwind;
343+
344+
.PHONY: rpm-dpdk
345+
rpm-dpdk: srpm
346+
$(RPMBUILD) --define "_topdir `pwd`/$(RPMDIR)" --rebuild $(RPMDIR)/SRPMS/$(PACKAGE_NAME)-dpdk-$(VERSION)-$(RELEASE).src.rpm --with unwind;
320347
else
321348
endif
322349

configure.ac

Lines changed: 52 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@ RPM_BUILDREQ=
2020

2121
AC_CONFIG_MACRO_DIR([m4])
2222
# Must be checked before default -g -O2 is set:
23+
CXXFLAGS=" -std=gnu++17 "
2324
AC_ARG_ENABLE([debug],
2425
AC_HELP_STRING([--enable-debug],
2526
[Enable build with debug symbols and without optimizations.]),
2627
[if test "$enableval" = "yes"; then
27-
CXXFLAGS="-Wall -g -O0 $CXXFLAGS"
28+
CXXFLAGS+="-Wall -g -O0 $CXXFLAGS"
2829
CFLAGS="-Wall -g -O0 $CFLAGS"
2930
else
30-
CXXFLAGS="-Wall -g -O3 $CXXFLAGS"
31+
CXXFLAGS+="-Wall -g -O3 $CXXFLAGS"
3132
CFLAGS="-Wall -g -O3 $CFLAGS"
32-
fi], [CXXFLAGS="-Wall -g -O3 $CXXFLAGS"
33+
fi], [CXXFLAGS+="-Wall -g -O3 $CXXFLAGS"
3334
CPPFLAGS="-DNDEBUG=1 $CPPFLAGS"
3435
CFLAGS="-Wall -g -O3"])
3536
AM_CONDITIONAL(DEBUG, test x"$debug" = x"true")
@@ -81,6 +82,9 @@ AC_ARG_WITH([defaultsocketdir],
8182
AC_SUBST([defaultsocketdir], [$with_defaultsocketdir])
8283
AC_DEFINE_DIR([DEFAULTSOCKETDIR], [defaultsocketdir], [Default path to socket directory])
8384

85+
pkglibdir=$libdir/ipfixprobe
86+
AC_DEFINE_DIR([PLUGINDIR], [pkglibdir], [Path to loadable plugins])
87+
8488
AC_CHECK_LIB(atomic, __atomic_store, [libatomic=yes], AC_MSG_ERROR([libatomic not found]))
8589

8690
PKG_CHECK_MODULES([LIBLZ4], [liblz4])
@@ -217,7 +221,7 @@ if test x${withndp} = xyes; then
217221
), AC_MSG_ERROR([nfb/nfb.h not found. Try installing netcope-common-devel]))
218222
fi
219223

220-
AM_CONDITIONAL(WITH_NDP, test x${libnfb} = xyes && test x${withndp} = xyes)
224+
AM_CONDITIONAL(WITH_NDP, test x${libnfb} = xyes -a x${withndp} = xyes)
221225
if [[ -z "$WITH_NDP_TRUE" ]]; then
222226
AC_DEFINE([WITH_NDP], [1], [Define to 1 if the ndp is available])
223227
CPPFLAGS="$CPPFLAGS -DIPXP_FLOW_CACHE_SIZE=19 -DIPXP_FLOW_LINE_SIZE=2" # 524288 cache records, 4 record per line
@@ -236,31 +240,47 @@ AC_ARG_WITH([pcap],
236240
fi
237241
], [withpcap="no"]
238242
)
239-
240-
if test x${withpcap} = xyes; then
241-
AC_CHECK_HEADER(pcap.h,
242-
AC_CHECK_LIB(pcap, pcap_open_live, [libpcap=yes],
243-
AC_CHECK_LIB(wpcap, pcap_open_live, [libwpcap=yes], AC_MSG_ERROR([libpcap not found. Try installing libpcap]))),
244-
AC_MSG_ERROR([pcap.h not found. Try installing libpcap-devel or libwpcap-devel]))
243+
AC_ARG_ENABLE([pcap-plugin],
244+
AC_HELP_STRING([--disable-pcap-plugin],
245+
[Disable build of input-pcap plugin.]),
246+
[if test "$enableval" = "yes"; then
247+
disablepcapplugin=no
248+
else
249+
disablepcapplugin=yes
250+
fi], [disablepcapplugin=no])
251+
AM_CONDITIONAL(DISABLE_PCAP_MODULE, test x"$disablepcapplugin" = x"yes")
252+
253+
BACKUPLIBS=$LIBS
254+
AC_CHECK_HEADER(pcap.h,
255+
AC_CHECK_LIB(pcap, pcap_open_live, [libpcap=yes
256+
have_pcap=yes],
257+
AC_CHECK_LIB(wpcap, pcap_open_live, [libwpcap=yes
258+
have_pcap=yes], [AC_MSG_WARN([libpcap not found. Try installing libpcap])
259+
have_pcap=no])),
260+
[AC_MSG_WARN([pcap.h not found. Try installing libpcap-devel or libwpcap-devel])
261+
have_pcap=no])
262+
263+
if test x${withpcap} = xyes -a x${have_pcap} = xno; then
264+
AC_MSG_ERROR([Cannot compile pcap plugin that was enabled by --with-pcap.])
245265
fi
246266

247-
AM_CONDITIONAL(WITH_PCAP, test x${withpcap} && (test x${libpcap} = xyes || test x${libwpcap} = xyes))
248-
if [[ -z "$WITH_PCAP_TRUE" ]]; then
267+
AM_CONDITIONAL(ENABLE_PCAP, test x${have_pcap} = xyes -a x${disablepcapplugin} = xno)
268+
AM_CONDITIONAL(WITH_PCAP, test x${withpcap} = xyes -a x${have_pcap} = xyes)
269+
if test x${withpcap} = xyes -a x${have_pcap} = xyes; then
249270
AC_DEFINE([WITH_PCAP], [1], [Define to 1 if the libpcap is available])
250-
if [[ -z "$WITH_PCAP_TRUE" ]]; then
251-
if test x${libpcap} = xyes; then
252-
LIBS="-lpcap $LIBS"
253-
RPM_REQUIRES+=" libpcap"
254-
RPM_BUILDREQ+=" libpcap-devel"
255-
else
256-
LIBS="-lwpcap $LIBS"
257-
RPM_REQUIRES+=" libwpcap"
258-
RPM_BUILDREQ+=" libwpcap-devel"
259-
fi
271+
if test x${libpcap} = xyes; then
272+
LIBS="-lpcap $LIBS"
273+
RPM_REQUIRES+=" libpcap"
274+
RPM_BUILDREQ+=" libpcap-devel"
275+
else
276+
LIBS="-lwpcap $LIBS"
277+
RPM_REQUIRES+=" libwpcap"
278+
RPM_BUILDREQ+=" libwpcap-devel"
260279
fi
280+
else
281+
LIBS=$BACKUPLIBS
261282
fi
262283

263-
264284
AC_ARG_WITH([unwind],
265285
AC_HELP_STRING([--with-unwind],[Compile ipfixprobe with libunwind to print stack on crash]),
266286
[
@@ -400,7 +420,7 @@ AM_CONDITIONAL(WITH_STEM, test x${withstem} = xyes)
400420
if [[ -z "$WITH_STEM_TRUE" ]]; then
401421
AC_DEFINE([WITH_STEM], [1], [Define to 1 to use flexprobe testing interface])
402422
CFLAGS="-I/usr/local/include/Stem $CFLAGS"
403-
CXXFLAGS="-I/usr/local/include/Stem -std=gnu++17 -g -Wno-write-strings $CXXFLAGS"
423+
CXXFLAGS="-I/usr/local/include/Stem -g -Wno-write-strings $CXXFLAGS"
404424
LIBS="-lstem $LIBS"
405425
fi
406426

@@ -463,6 +483,8 @@ fi
463483

464484
AC_CONFIG_FILES([Makefile
465485
ipfixprobe.spec
486+
ipfixprobe-dpdk.spec
487+
ipfixprobe-ndp.spec
466488
ipfixprobe.bash
467489
input/nfbCInterface/Makefile
468490
init/Makefile
@@ -499,6 +521,12 @@ echo " LIBS...................: $LIBS"
499521
echo "Enforced NEMEA (for copr): $COPRRPM"
500522
echo "FlexProbe Data Interface.: $withflexprobe"
501523
echo "DPDK Interface...........: $withdpdk"
524+
echo "pcap Interface...........: $withpcap"
525+
if test -n "$ENABLE_PCAP_TRUE"; then
526+
echo " pcap module...........: no"
527+
else
528+
echo " pcap module...........: yes"
529+
fi
502530
echo
503531
echo "Installation.............: make install (as root if needed, with 'su' or 'sudo')"
504532
echo " prefix.................: $prefix"

docker/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
# How to build and push docker images
2+
3+
To login:
4+
5+
```
6+
podman login gitlab.liberouter.org:5050
7+
```
8+
9+
To build new image with tag rpmbuilder:
10+
```
11+
cd rpmbuilder
12+
podman build -t rpmbuilder .
13+
```
14+
15+
To push rpmbuilder image to repository:
16+
17+
```
18+
podman push rpmbuilder:latest gitlab.liberouter.org:5050/monitoring/ipfixprobe
19+
```
20+
21+
=======
122
# ipfixprobe Docker wrapper
223

324
This repository contains a Docker container that processes network traffic from a pcap file using `ipfixprobe`. It accepts a pcap file and a processing script, runs it inside the container, and outputs the results in CSV format.

0 commit comments

Comments
 (0)