Skip to content
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

build: add build of separate plugins #106

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
31 changes: 28 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ bin_PROGRAMS=ipfixprobe ipfixprobe_stats

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

AM_CPPFLAGS=-I$(srcdir)/include/

ipfixprobe_LDFLAGS=-lpthread -ldl -latomic
ipfixprobe_CFLAGS=-I$(srcdir)/include/ -fPIC
ipfixprobe_CXXFLAGS=-std=gnu++11 -Wno-write-strings -I$(srcdir)/include/ -fPIC
ipfixprobe_CXXFLAGS=-Wno-write-strings -I$(srcdir)/include/ -fPIC

if OS_CYGWIN
ipfixprobe_CXXFLAGS+=-Wl,--export-all-symbols
Expand All @@ -32,13 +34,24 @@ ipfixprobe_input_src=\
#example_la_SOURCES=example.cpp example.hpp
#example_la_LDFLAGS=-module -shared -avoid-version

if ENABLE_PCAP
pkglib_LTLIBRARIES=input-pcap.la
input_pcap_la_SOURCES= input/pcap.cpp input/pcap.hpp
input_pcap_la_LDFLAGS=-module -shared -avoid-version -lpcap
endif

if WITH_NDP
ipfixprobe_LDFLAGS+=-lnuma -lndpRI -L$(srcdir)/input/nfbCInterface/
ipfixprobe_CXXFLAGS+=-I$(srcdir)/input/nfbCInterface/include/
ipfixprobe_input_src+=\
input/ndp.cpp \
input/ndp.hpp

pkglib_LTLIBRARIES=input-ndp.la
input_ndp_la_CXXFLAGS=-I$(srcdir)/input/nfbCInterface/include/
input_ndp_la_SOURCES= input/ndp.cpp input/ndp.hpp
input_ndp_la_LDFLAGS=-module -shared -avoid-version -lnuma -lndpRI -L$(srcdir)/input/nfbCInterface/

endif

if WITH_RAW
Expand Down Expand Up @@ -156,6 +169,12 @@ if WITH_DPDK
ipfixprobe_input_src+=\
input/dpdk.cpp \
input/dpdk.h

pkglib_LTLIBRARIES=input-dpdk.la
input_dpdk_la_CFLAGS=-I$(srcdir)/include/ $(DPDK_CFLAGS)
input_dpdk_la_CXXFLAGS=$(DPDK_CFLAGS)
input_dpdk_la_SOURCES=input/dpdk.cpp input/dpdk.h
input_dpdk_la_LDFLAGS=-module -shared -avoid-version $(DPDK_LIBS)
endif

ipfixprobe_headers_src=\
Expand Down Expand Up @@ -200,7 +219,7 @@ endif

ipfixprobe_SOURCES=$(ipfixprobe_src) main.cpp

ipfixprobe_stats_CXXFLAGS=-std=gnu++11 -Wno-write-strings -I$(srcdir)/include/
ipfixprobe_stats_CXXFLAGS=-Wno-write-strings
ipfixprobe_stats_SOURCES=ipfixprobe_stats.cpp \
include/ipfixprobe/options.hpp \
include/ipfixprobe/utils.hpp \
Expand Down Expand Up @@ -268,6 +287,8 @@ srpm:
make ${AM_MAKEFLAGS} distdir='$(RPMDIR)/SOURCES/$(RPMFILENAME)' distdir
( cd "$(RPMDIR)/SOURCES/"; tar -z -c -f $(RPMFILENAME)-$(RELEASE).tar.gz $(RPMFILENAME); rm -rf $(RPMFILENAME); )
$(RPMBUILD) -bs $(PACKAGE_NAME).spec --define "_topdir `pwd`/$(RPMDIR)";
$(RPMBUILD) -bs $(PACKAGE_NAME)-dpdk.spec --define "_topdir `pwd`/$(RPMDIR)";
$(RPMBUILD) -bs $(PACKAGE_NAME)-ndp.spec --define "_topdir `pwd`/$(RPMDIR)";

.PHONY: rpm
rpm: srpm
Expand All @@ -279,7 +300,11 @@ rpm-nemea: srpm

.PHONY: rpm-ndp
rpm-ndp: srpm
$(RPMBUILD) --define "_topdir `pwd`/$(RPMDIR)" --rebuild $(RPMDIR)/SRPMS/$(RPMFILENAME)-$(RELEASE).src.rpm --with ndp --with unwind;
$(RPMBUILD) --define "_topdir `pwd`/$(RPMDIR)" --rebuild $(RPMDIR)/SRPMS/$(PACKAGE_NAME)-ndp-$(VERSION)-$(RELEASE).src.rpm --with unwind;

.PHONY: rpm-dpdk
rpm-dpdk: srpm
$(RPMBUILD) --define "_topdir `pwd`/$(RPMDIR)" --rebuild $(RPMDIR)/SRPMS/$(PACKAGE_NAME)-dpdk-$(VERSION)-$(RELEASE).src.rpm --with unwind;
else
endif

Expand Down
76 changes: 52 additions & 24 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ RPM_BUILDREQ=

AC_CONFIG_MACRO_DIR([m4])
# Must be checked before default -g -O2 is set:
CXXFLAGS=" -std=gnu++11 "
AC_ARG_ENABLE([debug],
AC_HELP_STRING([--enable-debug],
[Enable build with debug symbols and without optimizations.]),
[if test "$enableval" = "yes"; then
CXXFLAGS="-Wall -g -O0 $CXXFLAGS"
CXXFLAGS+="-Wall -g -O0 $CXXFLAGS"
CFLAGS="-Wall -g -O0 $CFLAGS"
else
CXXFLAGS="-Wall -g -O3 $CXXFLAGS"
CXXFLAGS+="-Wall -g -O3 $CXXFLAGS"
CFLAGS="-Wall -g -O3 $CFLAGS"
fi], [CXXFLAGS="-Wall -g -O3 $CXXFLAGS"
fi], [CXXFLAGS+="-Wall -g -O3 $CXXFLAGS"
CPPFLAGS="-DNDEBUG=1 $CPPFLAGS"
CFLAGS="-Wall -g -O3"])
AM_CONDITIONAL(DEBUG, test x"$debug" = x"true")
Expand Down Expand Up @@ -81,6 +82,9 @@ AC_ARG_WITH([defaultsocketdir],
AC_SUBST([defaultsocketdir], [$with_defaultsocketdir])
AC_DEFINE_DIR([DEFAULTSOCKETDIR], [defaultsocketdir], [Default path to socket directory])

pkglibdir=$libdir/ipfixprobe
AC_DEFINE_DIR([PLUGINDIR], [pkglibdir], [Path to loadable plugins])

AC_CHECK_LIB(atomic, __atomic_store, [libatomic=yes], AC_MSG_ERROR([libatomic not found]))

### gtest
Expand Down Expand Up @@ -206,7 +210,7 @@ if test x${withndp} = xyes; then
), AC_MSG_ERROR([nfb/nfb.h not found. Try installing netcope-common-devel]))
fi

AM_CONDITIONAL(WITH_NDP, test x${libnfb} = xyes && test x${withndp} = xyes)
AM_CONDITIONAL(WITH_NDP, test x${libnfb} = xyes -a x${withndp} = xyes)
if [[ -z "$WITH_NDP_TRUE" ]]; then
AC_DEFINE([WITH_NDP], [1], [Define to 1 if the ndp is available])
CPPFLAGS="$CPPFLAGS -DIPXP_FLOW_CACHE_SIZE=19 -DIPXP_FLOW_LINE_SIZE=2" # 524288 cache records, 4 record per line
Expand All @@ -225,31 +229,47 @@ AC_ARG_WITH([pcap],
fi
], [withpcap="no"]
)

if test x${withpcap} = xyes; then
AC_CHECK_HEADER(pcap.h,
AC_CHECK_LIB(pcap, pcap_open_live, [libpcap=yes],
AC_CHECK_LIB(wpcap, pcap_open_live, [libwpcap=yes], AC_MSG_ERROR([libpcap not found. Try installing libpcap]))),
AC_MSG_ERROR([pcap.h not found. Try installing libpcap-devel or libwpcap-devel]))
AC_ARG_ENABLE([pcap-plugin],
AC_HELP_STRING([--disable-pcap-plugin],
[Disable build of input-pcap plugin.]),
[if test "$enableval" = "yes"; then
disablepcapplugin=no
else
disablepcapplugin=yes
fi], [disablepcapplugin=no])
AM_CONDITIONAL(DISABLE_PCAP_MODULE, test x"$disablepcapplugin" = x"yes")

BACKUPLIBS=$LIBS
AC_CHECK_HEADER(pcap.h,
AC_CHECK_LIB(pcap, pcap_open_live, [libpcap=yes
have_pcap=yes],
AC_CHECK_LIB(wpcap, pcap_open_live, [libwpcap=yes
have_pcap=yes], [AC_MSG_WARN([libpcap not found. Try installing libpcap])
have_pcap=no])),
[AC_MSG_WARN([pcap.h not found. Try installing libpcap-devel or libwpcap-devel])
have_pcap=no])

if test x${withpcap} = xyes -a x${have_pcap} = xno; then
AC_MSG_ERROR([Cannot compile pcap plugin that was enabled by --with-pcap.])
fi

AM_CONDITIONAL(WITH_PCAP, test x${withpcap} && (test x${libpcap} = xyes || test x${libwpcap} = xyes))
if [[ -z "$WITH_PCAP_TRUE" ]]; then
AM_CONDITIONAL(ENABLE_PCAP, test x${have_pcap} = xyes -a x${disablepcapplugin} = xno)
AM_CONDITIONAL(WITH_PCAP, test x${withpcap} = xyes -a x${have_pcap} = xyes)
if test x${withpcap} = xyes -a x${have_pcap} = xyes; then
AC_DEFINE([WITH_PCAP], [1], [Define to 1 if the libpcap is available])
if [[ -z "$WITH_PCAP_TRUE" ]]; then
if test x${libpcap} = xyes; then
LIBS="-lpcap $LIBS"
RPM_REQUIRES+=" libpcap"
RPM_BUILDREQ+=" libpcap-devel"
else
LIBS="-lwpcap $LIBS"
RPM_REQUIRES+=" libwpcap"
RPM_BUILDREQ+=" libwpcap-devel"
fi
if test x${libpcap} = xyes; then
LIBS="-lpcap $LIBS"
RPM_REQUIRES+=" libpcap"
RPM_BUILDREQ+=" libpcap-devel"
else
LIBS="-lwpcap $LIBS"
RPM_REQUIRES+=" libwpcap"
RPM_BUILDREQ+=" libwpcap-devel"
fi
else
LIBS=$BACKUPLIBS
fi


AC_ARG_WITH([unwind],
AC_HELP_STRING([--with-unwind],[Compile ipfixprobe with libunwind to print stack on crash]),
[
Expand Down Expand Up @@ -375,7 +395,7 @@ AM_CONDITIONAL(WITH_STEM, test x${withstem} = xyes)
if [[ -z "$WITH_STEM_TRUE" ]]; then
AC_DEFINE([WITH_STEM], [1], [Define to 1 to use flexprobe testing interface])
CFLAGS="-I/usr/local/include/Stem $CFLAGS"
CXXFLAGS="-I/usr/local/include/Stem -std=gnu++17 -g -Wno-write-strings $CXXFLAGS"
CXXFLAGS="-I/usr/local/include/Stem -g -Wno-write-strings $CXXFLAGS"
LIBS="-lstem $LIBS"
fi

Expand Down Expand Up @@ -436,6 +456,8 @@ fi

AC_CONFIG_FILES([Makefile
ipfixprobe.spec
ipfixprobe-dpdk.spec
ipfixprobe-ndp.spec
ipfixprobe.bash
input/nfbCInterface/Makefile
init/Makefile
Expand Down Expand Up @@ -472,6 +494,12 @@ echo " LIBS...................: $LIBS"
echo "Enforced NEMEA (for copr): $COPRRPM"
echo "FlexProbe Data Interface.: $withflexprobe"
echo "DPDK Interface...........: $withdpdk"
echo "pcap Interface...........: $withpcap"
if test -n "$ENABLE_PCAP_TRUE"; then
echo " pcap module...........: no"
else
echo " pcap module...........: yes"
fi
echo
echo "Installation.............: make install (as root if needed, with 'su' or 'sudo')"
echo " prefix.................: $prefix"
Expand Down
109 changes: 109 additions & 0 deletions ipfixprobe-dpdk.spec.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
%bcond_without raw
%bcond_with nemea
%bcond_with unwind
%bcond_with is_el7

%if %{with raw}
%global compile_raw yes
%else
%global compile_raw no
%endif

%if %{with nemea}
%global compile_nemea yes
%else
%global compile_nemea @COPRRPM@
%endif

%if %{with unwind}
%global compile_unwind yes
%else
%global compile_unwind @COPRRPM@
%endif

%if "%{dist}" == ".el7"
%global is_el7 yes
%else
%global is_el7 no
%endif

Name: ipfixprobe-dpdk
Version: @PACKAGE_VERSION@
Release: @RELEASE@
URL: http://nemea.liberouter.org/
Source: https://www.liberouter.org/repo/SOURCES/ipfixprobe-%{version}-%{release}.tar.gz
Group: Liberouter
License: BSD
Vendor: CESNET, z.s.p.o.
Packager: @USERNAME@ <@USERMAIL@>
BuildRoot: %{_tmppath}/ipfixprobe-%{version}-%{release}
Summary: IPFIX flow exporter with DPDK support and various extending IPFIX elements exported by plugins.
Requires: libatomic
BuildRequires: gcc gcc-c++ make doxygen pkgconfig libatomic
Provides: ipfixprobe
Requires: dpdk
BuildRequires: dpdk-devel

%if %{with nemea} || "@COPRRPM@" == "yes"
Requires: libtrap
BuildRequires: libtrap-devel
BuildRequires: unirec
%endif

%if %{with unwind} || "@COPRRPM@" == "yes"
Requires: libunwind
BuildRequires: libunwind-devel
%endif

%if "%{is_el7}" == "yes"
Requires: openssl11
BuildRequires: openssl11-devel
%else
Requires: openssl
BuildRequires: openssl-devel
%endif

%description
This package contains IPFIX flow exporter with DPDK support.

%package -n ipfixprobe-input-dpdk
Group: Liberouter
License: BSD
Vendor: CESNET, z.s.p.o.
Packager: @USERNAME@ <@USERMAIL@>
Summary: NDP input plugin for ipfixprobe IPFIX flow exporter.
Requires: dpdk
BuildRequires: dpdk-devel
Provides: ipfixprobe-input-dpdk

%description -n ipfixprobe-input-dpdk
Input plugin to monitor network traffic on network interface using DPDK and HW acceleration cards.

%prep
%setup -n ipfixprobe-%{version}

%build
./configure -q --enable-silent-rules --prefix=%{_prefix} --libdir=%{_libdir} --bindir=%{_bindir} --sysconfdir=%{_sysconfdir} --docdir=%{_docdir} --mandir=%{_mandir} --datadir=%{_datadir} --with-raw=%{compile_raw} --with-nemea=%{compile_nemea} --with-unwind=%{compile_unwind} --enable-legacy-ssl=%{is_el7} --with-dpdk --disable-pcap-plugin
make clean
make -j5

%install
make -j5 DESTDIR=$RPM_BUILD_ROOT install

%post
test -x %{_bindir}/ipfixprobe && setcap "CAP_NET_RAW+eip" %{_bindir}/ipfixprobe || true
ldconfig

%files
%attr(0755, root, nemead) %{_bindir}/ipfixprobe
%attr(0755, root, nemead) %{_bindir}/ipfixprobe_stats
%attr(0755, root, nemead) %{_bindir}/ipfixprobed
%{_sysconfdir}/bash_completion.d/ipfixprobe.bash
%{_sysconfdir}/ipfixprobe/link0.conf.example
%{_docdir}/ipfixprobe/README.md
@systemdsystemunitdir@

%files -n ipfixprobe-input-dpdk
%{_libdir}/ipfixprobe/input-dpdk.so
%{_libdir}/ipfixprobe/input-dpdk.la

Loading