Page MenuHomeClusterLabs Projects

No OneTemporary

diff --git a/configure.ac b/configure.ac
index 3cb78af9..d0a5c539 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,530 +1,538 @@
#
# Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved.
#
# Authors: Fabio M. Di Nitto <fabbione@kronosnet.org>
# Federico Simoncelli <fsimon@kronosnet.org>
#
# This software licensed under GPL-2.0+, LGPL-2.0+
#
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
#
AC_PREREQ([2.63])
AC_INIT([kronosnet],
m4_esyscmd([build-aux/git-version-gen .tarball-version .gitarchivever]),
[devel@lists.kronosnet.org])
# Don't let AC_PROC_CC (invoked by AC_USE_SYSTEM_EXTENSIONS) replace
# undefined CFLAGS with -g -O2, overriding our special OPT_CFLAGS.
: ${CFLAGS=""}
AC_USE_SYSTEM_EXTENSIONS
AM_INIT_AUTOMAKE([1.13 dist-bzip2 dist-xz color-tests -Wno-portability subdir-objects])
LT_PREREQ([2.2.6])
# --enable-new-dtags: Use RUNPATH instead of RPATH.
# It is necessary to have this done before libtool does linker detection.
# See also: https://github.com/kronosnet/kronosnet/issues/107
# --as-needed: Modern systems have builtin ceil() making -lm superfluous but
# AC_SEARCH_LIBS can't detect this because it tests with a false prototype
AX_CHECK_LINK_FLAG([-Wl,--enable-new-dtags],
[AM_LDFLAGS=-Wl,--enable-new-dtags],
[AC_MSG_ERROR(["Linker support for --enable-new-dtags is required"])])
AX_CHECK_LINK_FLAG([-Wl,--as-needed], [AM_LDFLAGS="$AM_LDFLAGS -Wl,--as-needed"])
AC_SUBST([AM_LDFLAGS])
saved_LDFLAGS="$LDFLAGS"
LDFLAGS="$AM_LDFLAGS $LDFLAGS"
LT_INIT
LDFLAGS="$saved_LDFLAGS"
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([kronosnetd/main.c])
AC_CONFIG_HEADERS([config.h])
AC_CANONICAL_HOST
AC_LANG([C])
systemddir=${prefix}/lib/systemd/system
if test "$prefix" = "NONE"; then
prefix="/usr"
if test "$localstatedir" = "\${prefix}/var"; then
localstatedir="/var"
fi
if test "$sysconfdir" = "\${prefix}/etc"; then
sysconfdir="/etc"
fi
if test "$systemddir" = "NONE/lib/systemd/system"; then
systemddir=/lib/systemd/system
fi
if test "$libdir" = "\${exec_prefix}/lib"; then
if test -e /usr/lib64; then
libdir="/usr/lib64"
else
libdir="/usr/lib"
fi
fi
fi
AC_PROG_AWK
AC_PROG_GREP
AC_PROG_SED
AC_PROG_CPP
AC_PROG_CC
AC_PROG_CC_C99
if test "x$ac_cv_prog_cc_c99" = "xno"; then
AC_MSG_ERROR(["C99 support is required"])
fi
AC_PROG_LN_S
AC_PROG_INSTALL
AC_PROG_MAKE_SET
PKG_PROG_PKG_CONFIG
AC_CHECK_PROGS([VALGRIND_EXEC], [valgrind])
AM_CONDITIONAL([HAS_VALGRIND], [test x$VALGRIND_EXEC != "x"])
# KNET_OPTION_DEFINES(stem,type,detection code)
# stem: enters name of option, Automake conditional and preprocessor define
# type: compress or crypto, determines where the default comes from
AC_DEFUN([KNET_OPTION_DEFINES],[
AC_ARG_ENABLE([$2-$1],[AS_HELP_STRING([--disable-$2-$1],[disable libknet $1 support])],,
[enable_$2_$1="$enable_$2_all"])
AM_CONDITIONAL([BUILD_]m4_toupper([$2_$1]),[test "x$enable_$2_$1" = xyes])
if test "x$enable_$2_$1" = xyes; then
$3
fi
AC_DEFINE_UNQUOTED([WITH_]m4_toupper([$2_$1]), [`test "x$enable_$2_$1" != xyes; echo $?`], $1 $2 [built in])
])
AC_ARG_ENABLE([man],
[AS_HELP_STRING([--disable-man],[disable man page creation])],,
[ enable_man="yes" ])
AM_CONDITIONAL([BUILD_MAN], [test x$enable_man = xyes])
AC_ARG_ENABLE([libknet-sctp],
[AS_HELP_STRING([--disable-libknet-sctp],[disable libknet SCTP support])],,
[ enable_libknet_sctp="yes" ])
AM_CONDITIONAL([BUILD_SCTP], [test x$enable_libknet_sctp = xyes])
AC_ARG_ENABLE([crypto-all],
[AS_HELP_STRING([--disable-crypto-all],[disable libknet all crypto modules support])],,
[ enable_crypto_all="yes" ])
KNET_OPTION_DEFINES([nss],[crypto],[PKG_CHECK_MODULES([nss], [nss])])
KNET_OPTION_DEFINES([openssl],[crypto],[
PKG_CHECK_MODULES([openssl],[libcrypto < 1.1],
[AC_DEFINE_UNQUOTED([BUILDCRYPTOOPENSSL10], [1], [openssl 1.0 crypto])],
[PKG_CHECK_MODULES([openssl],[libcrypto >= 1.1],
[AC_DEFINE_UNQUOTED([BUILDCRYPTOOPENSSL11], [1], [openssl 1.1 crypto])])])
])
AC_ARG_ENABLE([compress-all],
[AS_HELP_STRING([--disable-compress-all],[disable libknet all compress modules support])],,
[ enable_compress_all="yes" ])
KNET_OPTION_DEFINES([zlib],[compress],[PKG_CHECK_MODULES([zlib], [zlib])])
KNET_OPTION_DEFINES([lz4],[compress],[PKG_CHECK_MODULES([liblz4], [liblz4])])
KNET_OPTION_DEFINES([lzo2],[compress],[
PKG_CHECK_MODULES([lzo2], [lzo2],
[# work around broken pkg-config file in v2.10
AC_SUBST([lzo2_CFLAGS],[`echo $lzo2_CFLAGS | sed 's,/lzo *, ,'`])],
[AC_CHECK_HEADERS([lzo/lzo1x.h],
[AC_CHECK_LIB([lzo2], [lzo1x_decompress_safe],
[AC_SUBST([lzo2_LIBS], [-llzo2])])],
[AC_MSG_ERROR(["missing required lzo/lzo1x.h header"])])])
])
KNET_OPTION_DEFINES([lzma],[compress],[PKG_CHECK_MODULES([liblzma], [liblzma])])
KNET_OPTION_DEFINES([bzip2],[compress],[
PKG_CHECK_MODULES([bzip2], [bzip2],,
[AC_CHECK_HEADERS([bzlib.h],
[AC_CHECK_LIB([bz2], [BZ2_bzBuffToBuffCompress],
[AC_SUBST([bzip2_LIBS], [-lbz2])])],
[AC_MSG_ERROR(["missing required bzlib.h"])])])
])
AC_ARG_ENABLE([poc],
[AS_HELP_STRING([--enable-poc],[enable building poc code])],,
[ enable_poc="no" ])
AM_CONDITIONAL([BUILD_POC], [test x$enable_poc = xyes])
AC_ARG_ENABLE([kronosnetd],
[AS_HELP_STRING([--enable-kronosnetd],[Kronosnetd support])],,
[ enable_kronosnetd="no" ])
AM_CONDITIONAL([BUILD_KRONOSNETD], [test x$enable_kronosnetd = xyes])
AC_ARG_ENABLE([runautogen],
[AS_HELP_STRING([--enable-runautogen],[run autogen.sh])],,
[ enable_runautogen="no" ])
AM_CONDITIONAL([BUILD_RUNAUTOGEN], [test x$enable_runautogen = xyes])
override_rpm_debuginfo_option="yes"
AC_ARG_ENABLE([rpm-debuginfo],
[AS_HELP_STRING([--enable-rpm-debuginfo],[build debuginfo packages])],,
[ enable_rpm_debuginfo="no", override_rpm_debuginfo_option="no" ])
AM_CONDITIONAL([BUILD_RPM_DEBUGINFO], [test x$enable_rpm_debuginfo = xyes])
AM_CONDITIONAL([OVERRIDE_RPM_DEBUGINFO], [test x$override_rpm_debuginfo_option = xyes])
AC_ARG_ENABLE([libnozzle],
[AS_HELP_STRING([--enable-libnozzle],[libnozzle support])],,
[ enable_libnozzle="yes" ])
if test "x$enable_kronosnetd" = xyes; then
enable_libnozzle=yes
fi
AM_CONDITIONAL([BUILD_LIBNOZZLE], [test x$enable_libnozzle = xyes])
## local helper functions
# this function checks if CC support options passed as
# args. Global CPPFLAGS are ignored during this test.
cc_supports_flag() {
saveCPPFLAGS="$CPPFLAGS"
CPPFLAGS="$@"
if echo $CC | grep -q clang; then
CPPFLAGS="-Werror $CPPFLAGS"
fi
AC_MSG_CHECKING([whether $CC supports "$@"])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[RC=0; AC_MSG_RESULT([yes])],
[RC=1; AC_MSG_RESULT([no])])
CPPFLAGS="$saveCPPFLAGS"
return $RC
}
# Checks for libraries.
AX_PTHREAD(,[AC_MSG_ERROR([POSIX threads support is required])])
saved_LIBS="$LIBS"
LIBS=
AC_SEARCH_LIBS([ceil], [m], , [AC_MSG_ERROR([ceil not found])])
AC_SUBST([m_LIBS], [$LIBS])
LIBS=
AC_SEARCH_LIBS([clock_gettime], [rt], , [AC_MSG_ERROR([clock_gettime not found])])
AC_SUBST([rt_LIBS], [$LIBS])
LIBS=
AC_SEARCH_LIBS([dlopen], [dl dld], , [AC_MSG_ERROR([dlopen not found])])
AC_SUBST([dl_LIBS], [$LIBS])
LIBS="$saved_LIBS"
# OS detection
AC_MSG_CHECKING([for os in ${host_os}])
case "$host_os" in
*linux*)
AC_DEFINE_UNQUOTED([KNET_LINUX], [1], [Compiling for Linux platform])
AC_MSG_RESULT([Linux])
;;
*bsd*)
AC_DEFINE_UNQUOTED([KNET_BSD], [1], [Compiling for BSD platform])
AC_MSG_RESULT([BSD])
;;
*)
AC_MSG_ERROR([Unsupported OS? hmmmm])
;;
esac
# Checks for header files.
AC_CHECK_HEADERS([sys/epoll.h])
AC_CHECK_FUNCS([kevent])
# if neither sys/epoll.h nor kevent are present, we should fail.
if test "x$ac_cv_header_sys_epoll_h" = xno && test "x$ac_cv_func_kevent" = xno; then
AC_MSG_ERROR([Both epoll and kevent unavailable on this OS])
fi
if test "x$ac_cv_header_sys_epoll_h" = xyes && test "x$ac_cv_func_kevent" = xyes; then
AC_MSG_ERROR([Both epoll and kevent available on this OS, please contact the maintainers to fix the code])
fi
if test "x$enable_libknet_sctp" = xyes; then
AC_CHECK_HEADERS([netinet/sctp.h],, [AC_MSG_ERROR(["missing required SCTP headers"])])
fi
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_INT8_T
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
if test "x$enable_man" = "xyes"; then
AC_ARG_VAR([DOXYGEN], [override doxygen executable])
AC_CHECK_PROGS([DOXYGEN], [doxygen], [no])
if test "x$DOXYGEN" = xno; then
AC_MSG_ERROR(["Doxygen command not found"])
fi
# required by doxyxml to build man pages dynamically
# Don't let AC_PROC_CC (invoked by AX_PROG_CC_FOR_BUILD) replace
# undefined CFLAGS_FOR_BUILD with -g -O2, overriding our special OPT_CFLAGS.
: ${CFLAGS_FOR_BUILD=""}
AX_PROG_CC_FOR_BUILD
saved_PKG_CONFIG="$PKG_CONFIG"
saved_ac_cv_path_PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
unset PKG_CONFIG ac_cv_path_PKG_CONFIG
AC_PATH_PROG([PKG_CONFIG], [pkg-config])
PKG_CHECK_MODULES([libqb_BUILD], [libqb])
PKG_CHECK_MODULES([libxml_BUILD], [libxml-2.0])
PKG_CONFIG="$saved_PKG_CONFIG"
ac_cv_path_PKG_CONFIG="$saved_ac_cv_path_PKG_CONFIG"
fi
-# checks (for kronosnetd)
+# checks for libnozzle
+if test "x$enable_libnozzle" = xyes; then
+ if `echo $host_os | grep -q linux`; then
+ PKG_CHECK_MODULES([libnl], [libnl-3.0])
+ PKG_CHECK_MODULES([libnlroute], [libnl-route-3.0])
+ fi
+fi
+
+# checks for kronosnetd
if test "x$enable_kronosnetd" = xyes; then
AC_CHECK_HEADERS([security/pam_appl.h],
[AC_CHECK_LIB([pam], [pam_start],
[AC_SUBST([pam_LIBS], [-lpam])],
[AC_MSG_ERROR([Unable to find LinuxPAM devel files])])])
AC_CHECK_HEADERS([security/pam_misc.h],
[AC_CHECK_LIB([pam_misc], [misc_conv],
[AC_SUBST([pam_misc_LIBS], [-lpam_misc])],
[AC_MSG_ERROR([Unable to find LinuxPAM MISC devel files])])])
PKG_CHECK_MODULES([libqb], [libqb])
AC_CHECK_LIB([qb], [qb_log_thread_priority_set],
[have_qb_log_thread_priority_set="yes"],
[have_qb_log_thread_priority_set="no"])
if test "x${have_qb_log_thread_priority_set}" = xyes; then
AC_DEFINE_UNQUOTED([HAVE_QB_LOG_THREAD_PRIORITY_SET], [1], [have qb_log_thread_priority_set])
fi
fi
# local options
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],[enable debug build])])
AC_ARG_WITH([initdefaultdir],
[AS_HELP_STRING([--with-initdefaultdir=DIR],[path to /etc/sysconfig or /etc/default dir])],
[ INITDEFAULTDIR="$withval" ],
[ INITDEFAULTDIR="$sysconfdir/default" ])
AC_ARG_WITH([initddir],
[AS_HELP_STRING([--with-initddir=DIR],[path to init script directory])],
[ INITDDIR="$withval" ],
[ INITDDIR="$sysconfdir/init.d" ])
AC_ARG_WITH([systemddir],
[AS_HELP_STRING([--with-systemddir=DIR],[path to systemd unit files directory])],
[ SYSTEMDDIR="$withval" ],
[ SYSTEMDDIR="$systemddir" ])
AC_ARG_WITH([syslogfacility],
[AS_HELP_STRING([--with-syslogfacility=FACILITY],[default syslog facility])],
[ SYSLOGFACILITY="$withval" ],
[ SYSLOGFACILITY="LOG_DAEMON" ])
AC_ARG_WITH([sysloglevel],
[AS_HELP_STRING([--with-sysloglevel=LEVEL],[default syslog level])],
[ SYSLOGLEVEL="$withval" ],
[ SYSLOGLEVEL="LOG_INFO" ])
AC_ARG_WITH([defaultadmgroup],
[AS_HELP_STRING([--with-defaultadmgroup=GROUP],
[define PAM group. Users part of this group will be allowed to configure
kronosnet. Others will only receive read-only rights.])],
[ DEFAULTADMGROUP="$withval" ],
[ DEFAULTADMGROUP="kronosnetadm" ])
## random vars
LOGDIR=${localstatedir}/log/
RUNDIR=${localstatedir}/run/
DEFAULT_CONFIG_DIR=${sysconfdir}/kronosnet
## do subst
AC_SUBST([DEFAULT_CONFIG_DIR])
AC_SUBST([INITDEFAULTDIR])
AC_SUBST([INITDDIR])
AC_SUBST([SYSTEMDDIR])
AC_SUBST([LOGDIR])
AC_SUBST([DEFAULTADMGROUP])
AC_DEFINE_UNQUOTED([DEFAULT_CONFIG_DIR],
["$(eval echo ${DEFAULT_CONFIG_DIR})"],
[Default config directory])
AC_DEFINE_UNQUOTED([DEFAULT_CONFIG_FILE],
["$(eval echo ${DEFAULT_CONFIG_DIR}/kronosnetd.conf)"],
[Default config file])
AC_DEFINE_UNQUOTED([LOGDIR],
["$(eval echo ${LOGDIR})"],
[Default logging directory])
AC_DEFINE_UNQUOTED([DEFAULT_LOG_FILE],
["$(eval echo ${LOGDIR}/kronosnetd.log)"],
[Default log file])
AC_DEFINE_UNQUOTED([RUNDIR],
["$(eval echo ${RUNDIR})"],
[Default run directory])
AC_DEFINE_UNQUOTED([SYSLOGFACILITY],
[$(eval echo ${SYSLOGFACILITY})],
[Default syslog facility])
AC_DEFINE_UNQUOTED([SYSLOGLEVEL],
[$(eval echo ${SYSLOGLEVEL})],
[Default syslog level])
AC_DEFINE_UNQUOTED([DEFAULTADMGROUP],
["$(eval echo ${DEFAULTADMGROUP})"],
[Default admin group])
# debug build stuff
if test "x${enable_debug}" = xyes; then
AC_DEFINE_UNQUOTED([DEBUG], [1], [Compiling Debugging code])
OPT_CFLAGS="-O0"
else
OPT_CFLAGS="-O3"
fi
# gdb flags
if test "x${GCC}" = xyes; then
GDB_FLAGS="-ggdb3"
else
GDB_FLAGS="-g"
fi
# extra warnings
EXTRA_WARNINGS=""
WARNLIST="
all
extra
unused
shadow
missing-prototypes
missing-declarations
suggest-attribute=noreturn
suggest-attribute=format
property-attribute-mismatch
strict-prototypes
declaration-after-statement
pointer-arith
write-strings
cast-align
bad-function-cast
missing-format-attribute
float-equal
format=2
format-signedness
format-security
format-nonliteral
no-long-long
unsigned-char
gnu89-inline
no-strict-aliasing
error
address
cpp
overflow
parentheses
sequence-point
switch
shift-overflow
shift-overflow=2
overlength-strings
retundent-decls
init-self
uninitialized
unused-but-set-variable
unused-const-variable
unused-function
unused-result
unused-value
unused-variable
unknown-pragmas
no-unused-parameter
"
for j in $WARNLIST; do
if cc_supports_flag -W$j; then
EXTRA_WARNINGS="$EXTRA_WARNINGS -W$j";
fi
done
AC_SUBST([AM_CFLAGS],["$OPT_CFLAGS $GDB_FLAGS $EXTRA_WARNINGS"])
AX_PROG_DATE
AS_IF([test "$ax_cv_prog_date_gnu_date:$ax_cv_prog_date_gnu_utc" = yes:yes],
[UTC_DATE_AT="date -u -d@"],
[AS_IF([test "x$ax_cv_prog_date_bsd_date" = xyes],
[UTC_DATE_AT="date -u -r"],
[AC_MSG_ERROR([date utility unable to convert epoch to UTC])])])
AC_SUBST([UTC_DATE_AT])
AC_ARG_VAR([SOURCE_EPOCH],[last modification date of the source])
AC_MSG_NOTICE([trying to determine source epoch])
AC_MSG_CHECKING([for source epoch in \$SOURCE_EPOCH])
AS_IF([test -n "$SOURCE_EPOCH"],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_CHECKING([for source epoch in source_epoch file])
AS_IF([test -e "$srcdir/source_epoch"],
[read SOURCE_EPOCH <"$srcdir/source_epoch"
AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_CHECKING([for source epoch baked in by gitattributes export-subst])
SOURCE_EPOCH='$Format:%at$' # template for rewriting by git-archive
AS_CASE([$SOURCE_EPOCH],
[?Format:*], # was not rewritten
[AC_MSG_RESULT([no])
AC_MSG_CHECKING([for source epoch in \$SOURCE_DATE_EPOCH])
AS_IF([test "x$SOURCE_DATE_EPOCH" != x],
[SOURCE_EPOCH="$SOURCE_DATE_EPOCH"
AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
AC_MSG_CHECKING([whether git log can provide a source epoch])
SOURCE_EPOCH=f${SOURCE_EPOCH#\$F} # convert into git log --pretty format
SOURCE_EPOCH=$(cd "$srcdir" && git log -1 --pretty=${SOURCE_EPOCH%$} 2>/dev/null)
AS_IF([test -n "$SOURCE_EPOCH"],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no, using current time and breaking reproducibility])
SOURCE_EPOCH=$(date +%s)])])],
[AC_MSG_RESULT([yes])]
)])
])
AC_MSG_NOTICE([using source epoch $($UTC_DATE_AT$SOURCE_EPOCH +'%F %T %Z')])
AC_CONFIG_FILES([
Makefile
init/Makefile
libnozzle/Makefile
libnozzle/libnozzle.pc
libnozzle/tests/Makefile
kronosnetd/Makefile
kronosnetd/kronosnetd.logrotate
libknet/Makefile
libknet/libknet.pc
libknet/tests/Makefile
man/Makefile
man/Doxyfile-knet
man/Doxyfile-nozzle
poc-code/Makefile
poc-code/iov-hash/Makefile
poc-code/access-list/Makefile
])
if test "x$VERSION" = "xUNKNOWN"; then
AC_MSG_ERROR([m4_text_wrap([
configure was unable to determine the source tree's current version. This
generally happens when using git archive (or the github download button)
generated tarball/zip file. In order to workaround this issue, either use git
clone https://github.com/kronosnet/kronosnet.git or use an official release
tarball, available at https://kronosnet.org/releases/. Alternatively you
can add a compatible version in a .tarball-version file at the top of the
source tree, wipe your autom4te.cache dir and generated configure, and rerun
autogen.sh.
], [ ], [ ], [76])])
fi
AC_OUTPUT
diff --git a/kronosnet.spec.in b/kronosnet.spec.in
index d07103b4..9e9903aa 100644
--- a/kronosnet.spec.in
+++ b/kronosnet.spec.in
@@ -1,537 +1,540 @@
###############################################################################
###############################################################################
##
## Copyright (C) 2012-2018 Red Hat, Inc. All rights reserved.
##
## This copyrighted material is made available to anyone wishing to use,
## modify, copy, or redistribute it subject to the terms and conditions
## of the GNU General Public License v.2 or higher
##
###############################################################################
###############################################################################
# keep around ready for later user
%global alphatag @alphatag@
%global numcomm @numcomm@
%global dirty @dirty@
# set defaults from ./configure invokation
%@sctp@ sctp
%@nss@ nss
%@openssl@ openssl
%@zlib@ zlib
%@lz4@ lz4
%@lzo2@ lzo2
%@lzma@ lzma
%@bzip2@ bzip2
%@kronosnetd@ kronosnetd
%@libnozzle@ libnozzle
%@runautogen@ runautogen
%@rpmdebuginfo@ rpmdebuginfo
%@overriderpmdebuginfo@ overriderpmdebuginfo
%@buildman@ buildman
%if %{with overriderpmdebuginfo}
%undefine _enable_debug_packages
%endif
%if %{with sctp}
%global buildsctp 1
%endif
%if %{with nss}
%global buildcryptonss 1
%endif
%if %{with openssl}
%global buildcryptoopenssl 1
%endif
%if %{with zlib}
%global buildcompresszlib 1
%endif
%if %{with lz4}
%global buildcompresslz4 1
%endif
%if %{with lzo2}
%global buildcompresslzo2 1
%endif
%if %{with lzma}
%global buildcompresslzma 1
%endif
%if %{with bzip2}
%global buildcompressbzip2 1
%endif
%if %{with libnozzle}
%global buildlibnozzle 1
%endif
%if %{with kronosnetd}
%global buildlibnozzle 1
%global buildkronosnetd 1
%endif
%if %{with runautogen}
%global buildautogen 1
%endif
%if %{with buildman}
%global buildmanpages 1
%endif
# main (empty) package
# http://www.rpm.org/max-rpm/s1-rpm-subpack-spec-file-changes.html
Name: kronosnet
Summary: Multipoint-to-Multipoint VPN daemon
Version: @version@
Release: 1%{?numcomm:.%{numcomm}}%{?alphatag:.%{alphatag}}%{?dirty:.%{dirty}}%{?dist}
License: GPLv2+ and LGPLv2+
Group: System Environment/Base
URL: https://github.com/kronosnet/kronosnet/
Source0: https://github.com/kronosnet/kronosnet/archive/%{name}-%{version}%{?numcomm:.%{numcomm}}%{?alphatag:-%{alphatag}}%{?dirty:-%{dirty}}.tar.gz
## Setup/build bits
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
# Build dependencies
BuildRequires: gcc
# required to build man pages
%if %{defined buildmanpages}
BuildRequires: libqb-devel libxml2-devel doxygen
%endif
%if %{defined buildsctp}
BuildRequires: lksctp-tools-devel
%endif
%if %{defined buildcryptonss}
BuildRequires: /usr/include/nss3/nss.h /usr/include/nspr4/nspr.h
%endif
%if %{defined buildcryptoopenssl}
BuildRequires: /usr/include/openssl/conf.h
%endif
%if %{defined buildcompresszlib}
BuildRequires: zlib-devel
%endif
%if %{defined buildcompresslz4}
BuildRequires: /usr/include/lz4hc.h
%endif
%if %{defined buildcompresslzo2}
BuildRequires: lzo-devel
%endif
%if %{defined buildcompresslzma}
BuildRequires: xz-devel
%endif
%if %{defined buildcompressbzip2}
BuildRequires: /usr/include/bzlib.h
%endif
%if %{defined buildkronosnetd}
BuildRequires: pam-devel
%endif
+%if %{defined buildlibnozzle}
+BuildRequires: libnl3-devel
+%endif
%if %{defined buildautogen}
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: libtool
%endif
%prep
%setup -q -n %{name}-%{version}%{?numcomm:.%{numcomm}}%{?alphatag:-%{alphatag}}%{?dirty:-%{dirty}}
%build
%if %{with runautogen}
./autogen.sh
%endif
%{configure} \
%if %{defined buildmanpages}
--enable-man \
%else
--disable-man \
%endif
%if %{defined buildsctp}
--enable-libknet-sctp \
%else
--disable-libknet-sctp \
%endif
%if %{defined buildcryptonss}
--enable-crypto-nss \
%else
--disable-crypto-nss \
%endif
%if %{defined buildcryptoopenssl}
--enable-crypto-openssl \
%else
--disable-crypto-openssl \
%endif
%if %{defined buildcompresszlib}
--enable-compress-zlib \
%else
--disable-compress-zlib \
%endif
%if %{defined buildcompresslz4}
--enable-compress-lz4 \
%else
--disable-compress-lz4 \
%endif
%if %{defined buildcompresslzo2}
--enable-compress-lzo2 \
%else
--disable-compress-lzo2 \
%endif
%if %{defined buildcompresslzma}
--enable-compress-lzma \
%else
--disable-compress-lzma \
%endif
%if %{defined buildcompressbzip2}
--enable-compress-bzip2 \
%else
--disable-compress-bzip2 \
%endif
%if %{defined buildkronosnetd}
--enable-kronosnetd \
%endif
%if %{defined buildlibnozzle}
--enable-libnozzle \
%endif
--with-initdefaultdir=%{_sysconfdir}/sysconfig/ \
%if %{defined _unitdir}
--with-systemddir=%{_unitdir}
%else
--with-initddir=%{_sysconfdir}/rc.d/init.d/
%endif
make %{_smp_mflags}
%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
# tree cleanup
# remove static libraries
find %{buildroot} -name "*.a" -exec rm {} \;
# remove libtools leftovers
find %{buildroot} -name "*.la" -exec rm {} \;
# handle systemd vs init script
%if %{defined _unitdir}
# remove init scripts
rm -rf %{buildroot}/etc/init.d
%else
# remove systemd specific bits
find %{buildroot} -name "*.service" -exec rm {} \;
%endif
# remove docs
rm -rf %{buildroot}/usr/share/doc/kronosnet
%clean
rm -rf %{buildroot}
# main empty package
%description
kronosnet source
%if %{defined buildkronosnetd}
## Runtime and subpackages section
%package -n kronosnetd
Group: System Environment/Base
Summary: Multipoint-to-Multipoint VPN daemon
%if %{defined _unitdir}
# Needed for systemd unit
Requires(post): systemd-sysv
Requires(post): systemd-units
Requires(preun): systemd-units
Requires(postun): systemd-units
%else
Requires(post): chkconfig
Requires(preun): chkconfig, initscripts
%endif
Requires(post): shadow-utils
Requires(preun): shadow-utils
Requires: pam, /etc/pam.d/passwd
%description -n kronosnetd
The kronosnet daemon is a bridge between kronosnet switching engine
and kernel network tap devices, to create and administer a
distributed LAN over multipoint-to-multipoint VPNs.
The daemon does a poor attempt to provide a configure UI similar
to other known network devices/tools (Cisco, quagga).
Beside looking horrific, it allows runtime changes and
reconfiguration of the kronosnet(s) without daemon reload
or service disruption.
%post -n kronosnetd
%if %{defined _unitdir}
%if 0%{?systemd_post:1}
%systemd_post kronosnetd.service
%else
/bin/systemctl daemon-reload >/dev/null 2>&1 || :
%endif
%else
/sbin/chkconfig --add kronosnetd
%endif
/usr/sbin/groupadd --force --system @defaultadmgroup@
%preun -n kronosnetd
%if %{defined _unitdir}
%if 0%{?systemd_preun:1}
%systemd_preun kronosnetd.service
%else
if [ "$1" -eq 0 ]; then
/bin/systemctl --no-reload disable kronosnetd.service
/bin/systemctl stop kronosnetd.service >/dev/null 2>&1
fi
%endif
%else
if [ "$1" = 0 ]; then
/sbin/service kronosnetd stop >/dev/null 2>&1
/sbin/chkconfig --del kronosnetd
fi
%endif
%files -n kronosnetd
%defattr(-,root,root,-)
%doc COPYING.* COPYRIGHT
%dir %{_sysconfdir}/kronosnet
%dir %{_sysconfdir}/kronosnet/*
%config(noreplace) %{_sysconfdir}/sysconfig/kronosnetd
%config(noreplace) %{_sysconfdir}/pam.d/kronosnetd
%config(noreplace) %{_sysconfdir}/logrotate.d/kronosnetd
%if %{defined _unitdir}
%{_unitdir}/kronosnetd.service
%else
%config(noreplace) %{_sysconfdir}/rc.d/init.d/kronosnetd
%endif
%{_sbindir}/*
%{_mandir}/man8/*
%endif
%if %{defined buildlibnozzle}
%package -n libnozzle1
Group: System Environment/Libraries
Summary: Simple userland wrapper around kernel tap devices
%description -n libnozzle1
This is an over-engineered commodity library to manage a pool
of tap devices and provides the basic
pre-up.d/up.d/down.d/post-down.d infrastructure.
%files -n libnozzle1
%defattr(-,root,root,-)
%doc COPYING.* COPYRIGHT
%{_libdir}/libnozzle.so.*
%post -n libnozzle1 -p /sbin/ldconfig
%postun -n libnozzle1 -p /sbin/ldconfig
%package -n libnozzle1-devel
Group: Development/Libraries
Summary: Simple userland wrapper around kernel tap devices (developer files)
Requires: libnozzle1 = %{version}-%{release}
Requires: pkgconfig
%description -n libnozzle1-devel
This is an over-engineered commodity library to manage a pool
of tap devices and provides the basic
pre-up.d/up.d/down.d/post-down.d infrastructure.
%files -n libnozzle1-devel
%defattr(-,root,root,-)
%doc COPYING.* COPYRIGHT
%{_libdir}/libnozzle.so
%{_includedir}/libnozzle.h
%{_libdir}/pkgconfig/libnozzle.pc
%endif
%package -n libknet1
Group: System Environment/Libraries
Summary: Kronosnet core switching implementation
%description -n libknet1
The whole kronosnet core is implemented in this library.
Please refer to the not-yet-existing documentation for further
information.
%files -n libknet1
%defattr(-,root,root,-)
%doc COPYING.* COPYRIGHT
%{_libdir}/libknet.so.*
%dir %{_libdir}/kronosnet
%post -n libknet1 -p /sbin/ldconfig
%postun -n libknet1 -p /sbin/ldconfig
%package -n libknet1-devel
Group: Development/Libraries
Summary: Kronosnet core switching implementation (developer files)
Requires: libknet1 = %{version}-%{release}
Requires: pkgconfig
%description -n libknet1-devel
The whole kronosnet core is implemented in this library.
Please refer to the not-yet-existing documentation for further
information.
%files -n libknet1-devel
%defattr(-,root,root,-)
%doc COPYING.* COPYRIGHT
%{_libdir}/libknet.so
%{_includedir}/libknet.h
%{_libdir}/pkgconfig/libknet.pc
%if %{defined buildmanpages}
%{_mandir}/man3/knet*.3.gz
%endif
%if %{defined buildcryptonss}
%package -n libknet1-crypto-nss-plugin
Group: System Environment/Libraries
Summary: libknet1 nss support
Requires: libknet1 = %{version}-%{release}
%description -n libknet1-crypto-nss-plugin
NSS crypto support for libknet1.
%files -n libknet1-crypto-nss-plugin
%defattr(-,root,root,-)
%{_libdir}/kronosnet/crypto_nss.so
%endif
%if %{defined buildcryptoopenssl}
%package -n libknet1-crypto-openssl-plugin
Group: System Environment/Libraries
Summary: libknet1 openssl support
Requires: libknet1 = %{version}-%{release}
%description -n libknet1-crypto-openssl-plugin
OpenSSL crypto support for libknet1.
%files -n libknet1-crypto-openssl-plugin
%defattr(-,root,root,-)
%{_libdir}/kronosnet/crypto_openssl.so
%endif
%if %{defined buildcompresszlib}
%package -n libknet1-compress-zlib-plugin
Group: System Environment/Libraries
Summary: libknet1 zlib support
Requires: libknet1 = %{version}-%{release}
%description -n libknet1-compress-zlib-plugin
zlib compression support for libknet1.
%files -n libknet1-compress-zlib-plugin
%defattr(-,root,root,-)
%{_libdir}/kronosnet/compress_zlib.so
%endif
%if %{defined buildcompresslz4}
%package -n libknet1-compress-lz4-plugin
Group: System Environment/Libraries
Summary: libknet1 lz4 and lz4hc support
Requires: libknet1 = %{version}-%{release}
%description -n libknet1-compress-lz4-plugin
lz4 and lz4hc compression support for libknet1.
%files -n libknet1-compress-lz4-plugin
%defattr(-,root,root,-)
%{_libdir}/kronosnet/compress_lz4.so
%{_libdir}/kronosnet/compress_lz4hc.so
%endif
%if %{defined buildcompresslzo2}
%package -n libknet1-compress-lzo2-plugin
Group: System Environment/Libraries
Summary: libknet1 lzo2 support
Requires: libknet1 = %{version}-%{release}
%description -n libknet1-compress-lzo2-plugin
lzo2 compression support for libknet1.
%files -n libknet1-compress-lzo2-plugin
%defattr(-,root,root,-)
%{_libdir}/kronosnet/compress_lzo2.so
%endif
%if %{defined buildcompresslzma}
%package -n libknet1-compress-lzma-plugin
Group: System Environment/Libraries
Summary: libknet1 lzma support
Requires: libknet1 = %{version}-%{release}
%description -n libknet1-compress-lzma-plugin
lzma compression support for libknet1.
%files -n libknet1-compress-lzma-plugin
%defattr(-,root,root,-)
%{_libdir}/kronosnet/compress_lzma.so
%endif
%if %{defined buildcompressbzip2}
%package -n libknet1-compress-bzip2-plugin
Group: System Environment/Libraries
Summary: libknet1 bzip2 support
Requires: libknet1 = %{version}-%{release}
%description -n libknet1-compress-bzip2-plugin
bzip2 compression support for libknet1.
%files -n libknet1-compress-bzip2-plugin
%defattr(-,root,root,-)
%{_libdir}/kronosnet/compress_bzip2.so
%endif
%package -n libknet1-crypto-plugins-all
Group: System Environment/Libraries
Summary: libknet1 crypto plugins meta package
%if %{defined buildcryptonss}
Requires: libknet1-crypto-nss-plugin
%endif
%if %{defined buildcryptoopenssl}
Requires: libknet1-crypto-openssl-plugin
%endif
%description -n libknet1-crypto-plugins-all
meta package to install all of libknet1 crypto plugins
%files -n libknet1-crypto-plugins-all
%package -n libknet1-compress-plugins-all
Group: System Environment/Libraries
Summary: libknet1 compress plugins meta package
%if %{defined buildcompresszlib}
Requires: libknet1-compress-zlib-plugin
%endif
%if %{defined buildcompresslz4}
Requires: libknet1-compress-lz4-plugin
%endif
%if %{defined buildcompresslzo2}
Requires: libknet1-compress-lzo2-plugin
%endif
%if %{defined buildcompresslzma}
Requires: libknet1-compress-lzma-plugin
%endif
%if %{defined buildcompressbzip2}
Requires: libknet1-compress-bzip2-plugin
%endif
%description -n libknet1-compress-plugins-all
meta package to install all of libknet1 compress plugins
%files -n libknet1-compress-plugins-all
%package -n libknet1-plugins-all
Group: System Environment/Libraries
Summary: libknet1 plugins meta package
Requires: libknet1-compress-plugins-all
Requires: libknet1-crypto-plugins-all
%description -n libknet1-plugins-all
meta package to install all of libknet1 plugins
%files -n libknet1-plugins-all
%if %{with rpmdebuginfo}
%debug_package
%endif
%changelog
* @date@ Autotools generated version <nobody@nowhere.org> - @version@-1-@numcomm@.@alphatag@.@dirty@
- These aren't the droids you're looking for.
diff --git a/libnozzle/Makefile.am b/libnozzle/Makefile.am
index 4982d94b..3a49d23b 100644
--- a/libnozzle/Makefile.am
+++ b/libnozzle/Makefile.am
@@ -1,49 +1,49 @@
#
# Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved.
#
# Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
#
# This software licensed under GPL-2.0+, LGPL-2.0+
#
MAINTAINERCLEANFILES = Makefile.in
include $(top_srcdir)/build-aux/check.mk
SYMFILE = libnozzle_exported_syms
EXTRA_DIST = $(SYMFILE)
if BUILD_LIBNOZZLE
SUBDIRS = . tests
libversion = 1:0:0
sources = libnozzle.c \
internals.c
include_HEADERS = libnozzle.h
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libnozzle.pc
noinst_HEADERS = \
internals.h
lib_LTLIBRARIES = libnozzle.la
libnozzle_la_SOURCES = $(sources)
-libnozzle_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS)
+libnozzle_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) $(libnl_CFLAGS) $(libnlroute_CFLAGS)
EXTRA_libnozzle_la_DEPENDENCIES = $(SYMFILE)
libnozzle_la_LDFLAGS = $(AM_LDFLAGS) \
-Wl,-version-script,$(srcdir)/$(SYMFILE) \
-version-info $(libversion)
-libnozzle_la_LIBADD = $(PTHREAD_LIBS)
+libnozzle_la_LIBADD = $(PTHREAD_LIBS) $(libnl_LIBS) $(libnlroute_LIBS)
endif
diff --git a/libnozzle/internals.h b/libnozzle/internals.h
index c41cd3de..c05d56de 100644
--- a/libnozzle/internals.h
+++ b/libnozzle/internals.h
@@ -1,71 +1,78 @@
/*
* Copyright (C) 2010-2017 Red Hat, Inc. All rights reserved.
*
* Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
*
* This software licensed under GPL-2.0+, LGPL-2.0+
*/
#ifndef __NOZZLE_INTERNALS_H__
#define __NOZZLE_INTERNALS_H__
#include "config.h"
+
+#ifdef KNET_LINUX
+#include <netlink/netlink.h>
+#endif
#include <net/if.h>
struct nozzle_lib_config {
struct nozzle_iface *head;
int ioctlfd;
+#ifdef KNET_LINUX
+ struct nl_sock *nlsock;
+#endif
};
#define IPADDR_CHAR_MAX 128
#define PREFIX_CHAR_MAX 4
struct nozzle_ip {
char ipaddr[IPADDR_CHAR_MAX + 1];
char prefix[PREFIX_CHAR_MAX + 1];
int domain; /* AF_INET or AF_INET6 */
struct nozzle_ip *next;
};
#define MACADDR_CHAR_MAX 18
/*
* 11 = post-down.d
* 1 = /
*/
#define UPDOWN_PATH_MAX PATH_MAX - 11 - 1 - IFNAMSIZ
struct nozzle_iface {
char name[IFNAMSIZ]; /* interface name */
int fd; /* interface fd */
int up; /* interface status 0 is down, 1 is up */
/*
* extra data
*/
struct nozzle_ip *ip; /* configured ip addresses */
/*
* default MAC address assigned by the kernel at creation time
*/
char default_mac[MACADDR_CHAR_MAX + 1];
int default_mtu; /* MTU assigned by the kernel at creation time */
int current_mtu; /* MTU configured by libnozzle user */
int hasupdown; /* interface has up/down path to scripts configured */
char updownpath[UPDOWN_PATH_MAX]; /* path to up/down scripts if configured */
struct nozzle_iface *next;
};
#define ifname ifr.ifr_name
int execute_bin_sh_command(const char *command, char **error_string);
int find_ip(nozzle_t nozzle,
const char *ipaddr, const char *prefix,
struct nozzle_ip **ip, struct nozzle_ip **ip_prev);
char *generate_v4_broadcast(const char *ipaddr, const char *prefix);
#endif
diff --git a/libnozzle/libnozzle.c b/libnozzle/libnozzle.c
index 4548f60b..f190e9af 100644
--- a/libnozzle/libnozzle.c
+++ b/libnozzle/libnozzle.c
@@ -1,1134 +1,1230 @@
/*
* Copyright (C) 2010-2018 Red Hat, Inc. All rights reserved.
*
* Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
*
* This software licensed under GPL-2.0+, LGPL-2.0+
*/
#include "config.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <net/ethernet.h>
#include <pthread.h>
#include <limits.h>
#include <stdio.h>
#include <net/if.h>
#include <ifaddrs.h>
#include <stdint.h>
#ifdef KNET_LINUX
#include <linux/if_tun.h>
#include <netinet/ether.h>
+#include <netlink/netlink.h>
+#include <netlink/route/addr.h>
+#include <netlink/route/link.h>
#endif
#ifdef KNET_BSD
#include <net/if_dl.h>
#endif
#include "libnozzle.h"
#include "internals.h"
/*
* internal functions are all _unlocked_
* locking should be handled at external API functions
*/
static int lib_init = 0;
static struct nozzle_lib_config lib_cfg;
static pthread_mutex_t config_mutex = PTHREAD_MUTEX_INITIALIZER;
/*
* internal helpers
*/
-static int _set_ip(nozzle_t nozzle, const char *command,
+#define IP_ADD 1
+#define IP_DEL 2
+
+static int _set_ip(nozzle_t nozzle, int command,
const char *ipaddr, const char *prefix,
char **error_string, int secondary)
{
+ int fam;
char *broadcast = NULL;
- char cmdline[4096];
+#ifdef KNET_LINUX
+ struct rtnl_addr *addr = NULL;
+ struct nl_addr *local_addr = NULL;
+ struct nl_addr *bcast_addr = NULL;
+ struct nl_cache *cache = NULL;
+ int ifindex;
+ int err = 0;
+#endif
#ifdef KNET_BSD
+ char cmdline[4096];
char proto[6];
- int v4 = 1;
-
- snprintf(proto, sizeof(proto), "inet");
#endif
if (!strchr(ipaddr, ':')) {
+ fam = AF_INET;
broadcast = generate_v4_broadcast(ipaddr, prefix);
if (!broadcast) {
errno = EINVAL;
return -1;
}
+ } else {
+ fam = AF_INET6;
}
-#ifdef KNET_BSD
- else {
- v4 = 0;
- snprintf(proto, sizeof(proto), "inet6");
+
+#ifdef KNET_LINUX
+ addr = rtnl_addr_alloc();
+ if (!addr) {
+ errno = ENOMEM;
+ return -1;
}
-#endif
- memset(cmdline, 0, sizeof(cmdline));
+ if (rtnl_link_alloc_cache(lib_cfg.nlsock, AF_UNSPEC, &cache) < 0) {
+ errno = ENOMEM;
+ err = -1;
+ goto out;
+ }
+
+ ifindex = rtnl_link_name2i(cache, nozzle->name);
+ if (ifindex == 0) {
+ errno = ENOENT;
+ err = -1;
+ goto out;
+ }
+
+ rtnl_addr_set_ifindex(addr, ifindex);
+
+ if (nl_addr_parse(ipaddr, fam, &local_addr) < 0) {
+ errno = EINVAL;
+ err = -1;
+ goto out;
+ }
+
+ if (rtnl_addr_set_local(addr, local_addr) < 0) {
+ errno = EINVAL;
+ err = -1;
+ goto out;
+ }
-#ifdef KNET_LINUX
if (broadcast) {
- snprintf(cmdline, sizeof(cmdline)-1,
- "ip addr %s %s/%s dev %s broadcast %s",
- command, ipaddr, prefix,
- nozzle->name, broadcast);
+ if (nl_addr_parse(broadcast, fam, &bcast_addr) < 0) {
+ errno = EINVAL;
+ err = -1;
+ goto out;
+ }
+
+ if (rtnl_addr_set_broadcast(addr, bcast_addr) < 0) {
+ errno = EINVAL;
+ err = -1;
+ goto out;
+ }
+ }
+
+ rtnl_addr_set_prefixlen(addr, atoi(prefix));
+
+ if (command == IP_ADD) {
+ if (rtnl_addr_add(lib_cfg.nlsock, addr, 0) < 0) {
+ errno = EINVAL;
+ err = -1;
+ goto out;
+ }
} else {
- snprintf(cmdline, sizeof(cmdline)-1,
- "ip addr %s %s/%s dev %s",
- command, ipaddr, prefix,
- nozzle->name);
+ if (rtnl_addr_delete(lib_cfg.nlsock, addr, 0) < 0) {
+ errno = EINVAL;
+ err = -1;
+ goto out;
+ }
+ }
+out:
+ if (addr) {
+ rtnl_addr_put(addr);
+ }
+ if (local_addr) {
+ nl_addr_put(local_addr);
+ }
+ if (bcast_addr) {
+ nl_addr_put(bcast_addr);
+ }
+ if (cache) {
+ nl_cache_put(cache);
+ }
+ if (broadcast) {
+ free(broadcast);
}
+ return err;
#endif
#ifdef KNET_BSD
- if (!strcmp(command, "add")) {
+ memset(cmdline, 0, sizeof(cmdline));
+
+ if (fam == AF_INET) {
+ snprintf(proto, sizeof(proto), "inet");
+ } else {
+ snprintf(proto, sizeof(proto), "inet6");
+ }
+
+ if (command == IP_ADD) {
snprintf(cmdline, sizeof(cmdline)-1,
"ifconfig %s %s %s/%s",
nozzle->name, proto, ipaddr, prefix);
if (broadcast) {
snprintf(cmdline + strlen(cmdline),
sizeof(cmdline) - strlen(cmdline) -1,
" broadcast %s", broadcast);
}
- if ((secondary) && (v4)) {
+ if ((secondary) && (fam == AF_INET)) {
snprintf(cmdline + strlen(cmdline),
sizeof(cmdline) - strlen(cmdline) -1,
" alias");
}
} else {
snprintf(cmdline, sizeof(cmdline)-1,
"ifconfig %s %s %s/%s delete",
nozzle->name, proto, ipaddr, prefix);
}
-#endif
if (broadcast) {
free(broadcast);
}
return execute_bin_sh_command(cmdline, error_string);
+#endif
}
/*
* internal helpers below should be completed
*
* keep all ioctl work within this file
*/
static void lib_fini(void)
{
if (lib_cfg.head == NULL) {
+#ifdef KNET_LINUX
+ nl_close(lib_cfg.nlsock);
+ nl_socket_free(lib_cfg.nlsock);
+#endif
close(lib_cfg.ioctlfd);
lib_init = 0;
}
}
static void destroy_iface(nozzle_t nozzle)
{
#ifdef KNET_BSD
struct ifreq ifr;
#endif
if (!nozzle)
return;
if (nozzle->fd)
close(nozzle->fd);
#ifdef KNET_BSD
memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifname, nozzle->name, IFNAMSIZ);
ioctl(lib_cfg.ioctlfd, SIOCIFDESTROY, &ifr);
#endif
free(nozzle);
lib_fini();
return;
}
static int is_valid_nozzle(const nozzle_t nozzle)
{
nozzle_t temp;
if (!nozzle) {
return 0;
}
if (!lib_init) {
return 0;
}
temp = lib_cfg.head;
while (temp != NULL) {
if (nozzle == temp)
return 1;
temp = temp->next;
}
return 0;
}
static int get_iface_mtu(const nozzle_t nozzle)
{
int err = 0, savederrno = 0;
struct ifreq ifr;
memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifname, nozzle->name, IFNAMSIZ);
err = ioctl(lib_cfg.ioctlfd, SIOCGIFMTU, &ifr);
if (err) {
savederrno = errno;
goto out_clean;
}
err = ifr.ifr_mtu;
out_clean:
errno = savederrno;
return err;
}
static int get_iface_mac(const nozzle_t nozzle, char **ether_addr)
{
int err = 0, savederrno = 0;
struct ifreq ifr;
char mac[MACADDR_CHAR_MAX];
#ifdef KNET_BSD
struct ifaddrs *ifap = NULL;
struct ifaddrs *ifa;
int found = 0;
#endif
memset(&mac, 0, MACADDR_CHAR_MAX);
memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifname, nozzle->name, IFNAMSIZ);
#ifdef KNET_LINUX
err = ioctl(lib_cfg.ioctlfd, SIOCGIFHWADDR, &ifr);
if (err) {
savederrno = errno;
goto out_clean;
}
ether_ntoa_r((struct ether_addr *)ifr.ifr_hwaddr.sa_data, mac);
#endif
#ifdef KNET_BSD
/*
* there is no ioctl to get the ether address of an interface on FreeBSD
* (not to be confused with hwaddr). Use workaround described here:
* https://lists.freebsd.org/pipermail/freebsd-hackers/2004-June/007394.html
*/
err = getifaddrs(&ifap);
if (err < 0) {
savederrno = errno;
goto out_clean;
}
ifa = ifap;
while (ifa) {
if (!strncmp(nozzle->name, ifa->ifa_name, IFNAMSIZ)) {
found = 1;
break;
}
ifa=ifa->ifa_next;
}
if (found) {
ether_ntoa_r((struct ether_addr *)LLADDR((struct sockaddr_dl *)ifa->ifa_addr), mac);
} else {
errno = EINVAL;
err = -1;
}
freeifaddrs(ifap);
if (err) {
goto out_clean;
}
#endif
*ether_addr = strdup(mac);
if (!*ether_addr) {
savederrno = errno;
err = -1;
}
out_clean:
errno = savederrno;
return err;
}
static int set_iface_down(nozzle_t nozzle)
{
int err = 0, savederrno = 0;
struct ifreq ifr;
if (!nozzle->up) {
goto out_clean;
}
memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifname, nozzle->name, IFNAMSIZ);
err = ioctl(lib_cfg.ioctlfd, SIOCGIFFLAGS, &ifr);
if (err) {
savederrno = errno;
goto out_clean;
}
ifr.ifr_flags &= ~IFF_UP;
err = ioctl(lib_cfg.ioctlfd, SIOCSIFFLAGS, &ifr);
if (err) {
savederrno = errno;
goto out_clean;
}
nozzle->up = 0;
out_clean:
errno = savederrno;
return err;
}
/*
* public API
*/
int nozzle_set_mtu(nozzle_t nozzle, const int mtu, char **error_string)
{
int err = 0, savederrno = 0;
struct nozzle_ip *tmp_ip;
struct ifreq ifr;
if ((!mtu) || (!error_string)) {
errno = EINVAL;
return -1;
}
savederrno = pthread_mutex_lock(&config_mutex);
if (savederrno) {
errno = savederrno;
return -1;
}
if (!is_valid_nozzle(nozzle)) {
savederrno = EINVAL;
err = -1;
goto out_clean;
}
err = nozzle->current_mtu = get_iface_mtu(nozzle);
if (err < 0) {
savederrno = errno;
goto out_clean;
}
memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifname, nozzle->name, IFNAMSIZ);
ifr.ifr_mtu = mtu;
err = ioctl(lib_cfg.ioctlfd, SIOCSIFMTU, &ifr);
if (err) {
savederrno = errno;
goto out_clean;
}
if ((nozzle->current_mtu < 1280) && (mtu >= 1280)) {
tmp_ip = nozzle->ip;
while(tmp_ip) {
if (tmp_ip->domain == AF_INET6) {
- err = _set_ip(nozzle, "add", tmp_ip->ipaddr, tmp_ip->prefix, error_string, 0);
+ err = _set_ip(nozzle, IP_ADD, tmp_ip->ipaddr, tmp_ip->prefix, error_string, 0);
if (err) {
savederrno = errno;
err = -1;
goto out_clean;
}
}
tmp_ip = tmp_ip->next;
}
}
out_clean:
pthread_mutex_unlock(&config_mutex);
errno = savederrno;
return err;
}
int nozzle_reset_mtu(nozzle_t nozzle, char **error_string)
{
return nozzle_set_mtu(nozzle, nozzle->default_mtu, error_string);
}
int nozzle_add_ip(nozzle_t nozzle, const char *ipaddr, const char *prefix, char **error_string)
{
int err = 0, savederrno = 0;
int found = 0;
struct nozzle_ip *ip = NULL, *ip_prev = NULL, *ip_last = NULL;
int secondary = 0;
if ((!ipaddr) || (!prefix) || (!error_string)) {
errno = EINVAL;
return -1;
}
savederrno = pthread_mutex_lock(&config_mutex);
if (savederrno) {
errno = savederrno;
return -1;
}
if (!is_valid_nozzle(nozzle)) {
savederrno = EINVAL;
err = -1;
goto out_clean;
}
found = find_ip(nozzle, ipaddr, prefix, &ip, &ip_prev);
if (found) {
goto out_clean;
}
ip = malloc(sizeof(struct nozzle_ip));
if (!ip) {
savederrno = errno;
err = -1 ;
goto out_clean;
}
memset(ip, 0, sizeof(struct nozzle_ip));
strncpy(ip->ipaddr, ipaddr, IPADDR_CHAR_MAX);
strncpy(ip->prefix, prefix, PREFIX_CHAR_MAX);
if (!strchr(ip->ipaddr, ':')) {
ip->domain = AF_INET;
} else {
ip->domain = AF_INET6;
}
/*
* if user asks for an IPv6 address, but MTU < 1280
* store the IP and bring it up later if and when MTU > 1280
*/
if ((ip->domain == AF_INET6) && (get_iface_mtu(nozzle) < 1280)) {
err = 0;
} else {
if (nozzle->ip) {
secondary = 1;
}
- err = _set_ip(nozzle, "add", ipaddr, prefix, error_string, secondary);
+ err = _set_ip(nozzle, IP_ADD, ipaddr, prefix, error_string, secondary);
savederrno = errno;
}
if (err) {
free(ip);
goto out_clean;
}
if (nozzle->ip) {
ip_last = nozzle->ip;
while (ip_last->next != NULL) {
ip_last = ip_last->next;
}
ip_last->next = ip;
} else {
nozzle->ip = ip;
}
out_clean:
pthread_mutex_unlock(&config_mutex);
errno = savederrno;
return err;
}
int nozzle_del_ip(nozzle_t nozzle, const char *ipaddr, const char *prefix, char **error_string)
{
int err = 0, savederrno = 0;
int found = 0;
struct nozzle_ip *ip = NULL, *ip_prev = NULL;
if ((!ipaddr) || (!prefix) || (!error_string)) {
errno = EINVAL;
return -1;
}
savederrno = pthread_mutex_lock(&config_mutex);
if (savederrno) {
errno = savederrno;
return -1;
}
if (!is_valid_nozzle(nozzle)) {
savederrno = EINVAL;
err = -1;
goto out_clean;
}
found = find_ip(nozzle, ipaddr, prefix, &ip, &ip_prev);
if (!found) {
goto out_clean;
}
- err = _set_ip(nozzle, "del", ipaddr, prefix, error_string, 0);
+ err = _set_ip(nozzle, IP_DEL, ipaddr, prefix, error_string, 0);
savederrno = errno;
if (!err) {
if (ip == ip_prev) {
nozzle->ip = ip->next;
} else {
ip_prev->next = ip->next;
}
free(ip);
}
out_clean:
pthread_mutex_unlock(&config_mutex);
errno = savederrno;
return err;
}
int nozzle_get_ips(const nozzle_t nozzle, char **ipaddr_list, int *entries)
{
int err = 0, savederrno = 0;
int found = 0;
char *ip_list = NULL;
int size = 0, offset = 0, len;
struct nozzle_ip *ip = NULL;
if ((!ipaddr_list) || (!entries)) {
errno = EINVAL;
return -1;
}
savederrno = pthread_mutex_lock(&config_mutex);
if (savederrno) {
errno = savederrno;
return -1;
}
if (!is_valid_nozzle(nozzle)) {
savederrno = EINVAL;
goto out_clean;
}
ip = nozzle->ip;
while (ip) {
found++;
ip = ip->next;
}
if (!found) {
*ipaddr_list = NULL;
*entries = 0;
goto out_clean;
}
size = found * (IPADDR_CHAR_MAX + PREFIX_CHAR_MAX + 2);
ip_list = malloc(size);
if (!ip_list) {
savederrno = errno;
err = -1;
goto out_clean;
}
memset(ip_list, 0, size);
ip = nozzle->ip;
while (ip) {
len = strlen(ip->ipaddr);
memmove(ip_list + offset, ip->ipaddr, len);
offset = offset + len + 1;
len = strlen(ip->prefix);
memmove(ip_list + offset, ip->prefix, len);
offset = offset + len + 1;
ip = ip->next;
}
*ipaddr_list = ip_list;
*entries = found;
out_clean:
pthread_mutex_unlock(&config_mutex);
errno = savederrno;
return err;
}
int nozzle_run_updown(const nozzle_t nozzle, uint8_t action, char **exec_string)
{
int err = 0, savederrno = 0;
char command[PATH_MAX];
const char *action_str = NULL;
struct stat sb;
if (action > NOZZLE_POSTDOWN) {
errno = EINVAL;
return -1;
}
if (!exec_string) {
errno = EINVAL;
return -1;
}
savederrno = pthread_mutex_lock(&config_mutex);
if (savederrno) {
errno = savederrno;
return -1;
}
if (!is_valid_nozzle(nozzle)) {
savederrno = EINVAL;
err = -1;
goto out_clean;
}
if (!nozzle->hasupdown) {
savederrno = EINVAL;
err = -1;
goto out_clean;
}
switch(action) {
case NOZZLE_PREUP:
action_str = "pre-up.d";
break;
case NOZZLE_UP:
action_str = "up.d";
break;
case NOZZLE_DOWN:
action_str = "down.d";
break;
case NOZZLE_POSTDOWN:
action_str = "post-down.d";
break;
}
memset(command, 0, PATH_MAX);
snprintf(command, PATH_MAX, "%s%s/%s", nozzle->updownpath, action_str, nozzle->name);
err = stat(command, &sb);
if (err) {
savederrno = errno;
goto out_clean;
}
err = execute_bin_sh_command(command, exec_string);
savederrno = errno;
out_clean:
pthread_mutex_unlock(&config_mutex);
errno = savederrno;
return err;
}
/*
* functions below should be completed
*/
nozzle_t nozzle_open(char *devname, size_t devname_size, const char *updownpath)
{
int savederrno = 0;
nozzle_t nozzle = NULL;
char *temp_mac = NULL;
#ifdef KNET_LINUX
struct ifreq ifr;
#endif
#ifdef KNET_BSD
uint16_t i;
long int nozzlenum = 0;
char curnozzle[IFNAMSIZ];
#endif
if (devname == NULL) {
errno = EINVAL;
return NULL;
}
if (devname_size < IFNAMSIZ) {
errno = EINVAL;
return NULL;
}
if (strlen(devname) > IFNAMSIZ) {
errno = E2BIG;
return NULL;
}
#ifdef KNET_BSD
/*
* BSD does not support named devices like Linux
* but it is possible to force a nozzleX device number
* where X is 0 to 255.
*/
if (strlen(devname)) {
if (strncmp(devname, "tap", 3)) {
errno = EINVAL;
return NULL;
}
errno = 0;
nozzlenum = strtol(devname+3, NULL, 10);
if (errno) {
errno = EINVAL;
return NULL;
}
if ((nozzlenum < 0) || (nozzlenum > 255)) {
errno = EINVAL;
return NULL;
}
}
#endif
if (updownpath) {
/* only absolute paths */
if (updownpath[0] != '/') {
errno = EINVAL;
return NULL;
}
if (strlen(updownpath) >= UPDOWN_PATH_MAX) {
errno = E2BIG;
return NULL;
}
}
savederrno = pthread_mutex_lock(&config_mutex);
if (savederrno) {
errno = savederrno;
return NULL;
}
if (!lib_init) {
lib_cfg.head = NULL;
#ifdef KNET_LINUX
+ lib_cfg.nlsock = nl_socket_alloc();
+ if (!lib_cfg.nlsock) {
+ savederrno = errno;
+ goto out_error;
+ }
+ if (nl_connect(lib_cfg.nlsock, NETLINK_ROUTE) < 0) {
+ savederrno = EBUSY;
+ goto out_error;
+ }
lib_cfg.ioctlfd = socket(AF_INET, SOCK_STREAM, 0);
#endif
#ifdef KNET_BSD
lib_cfg.ioctlfd = socket(AF_LOCAL, SOCK_DGRAM, 0);
#endif
if (lib_cfg.ioctlfd < 0) {
savederrno = errno;
goto out_error;
}
lib_init = 1;
}
nozzle = malloc(sizeof(struct nozzle_iface));
if (!nozzle) {
savederrno = ENOMEM;
goto out_error;
}
memset(nozzle, 0, sizeof(struct nozzle_iface));
#ifdef KNET_BSD
if (!strlen(devname)) {
for (i = 0; i < 256; i++) {
snprintf(curnozzle, sizeof(curnozzle) - 1, "/dev/tap%u", i);
nozzle->fd = open(curnozzle, O_RDWR);
savederrno = errno;
if (nozzle->fd > 0) {
break;
}
}
snprintf(curnozzle, sizeof(curnozzle) -1 , "tap%u", i);
} else {
snprintf(curnozzle, sizeof(curnozzle) - 1, "/dev/%s", devname);
nozzle->fd = open(curnozzle, O_RDWR);
savederrno = errno;
snprintf(curnozzle, sizeof(curnozzle) - 1, "%s", devname);
}
if (nozzle->fd < 0) {
savederrno = EBUSY;
goto out_error;
}
strncpy(devname, curnozzle, IFNAMSIZ);
strncpy(nozzle->name, curnozzle, IFNAMSIZ);
#endif
#ifdef KNET_LINUX
if ((nozzle->fd = open("/dev/net/tun", O_RDWR)) < 0) {
savederrno = errno;
goto out_error;
}
memset(&ifr, 0, sizeof(struct ifreq));
memmove(ifname, devname, IFNAMSIZ);
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
if (ioctl(nozzle->fd, TUNSETIFF, &ifr) < 0) {
savederrno = errno;
goto out_error;
}
if ((strlen(devname) > 0) && (strcmp(devname, ifname) != 0)) {
savederrno = EBUSY;
goto out_error;
}
strncpy(devname, ifname, IFNAMSIZ);
strncpy(nozzle->name, ifname, IFNAMSIZ);
#endif
nozzle->default_mtu = get_iface_mtu(nozzle);
if (nozzle->default_mtu < 0) {
savederrno = errno;
goto out_error;
}
if (get_iface_mac(nozzle, &temp_mac) < 0) {
savederrno = errno;
goto out_error;
}
strncpy(nozzle->default_mac, temp_mac, 18);
free(temp_mac);
if (updownpath) {
int len = strlen(updownpath);
strcpy(nozzle->updownpath, updownpath);
if (nozzle->updownpath[len-1] != '/') {
nozzle->updownpath[len] = '/';
}
nozzle->hasupdown = 1;
}
nozzle->next = lib_cfg.head;
lib_cfg.head = nozzle;
pthread_mutex_unlock(&config_mutex);
errno = savederrno;
return nozzle;
out_error:
destroy_iface(nozzle);
pthread_mutex_unlock(&config_mutex);
errno = savederrno;
return NULL;
}
int nozzle_close(nozzle_t nozzle)
{
int err = 0, savederrno = 0;
nozzle_t temp = lib_cfg.head;
nozzle_t prev = lib_cfg.head;
struct nozzle_ip *ip, *ip_next;
savederrno = pthread_mutex_lock(&config_mutex);
if (savederrno) {
errno = savederrno;
return -1;
}
if (!is_valid_nozzle(nozzle)) {
savederrno = EINVAL;
err = -1;
goto out_clean;
}
while ((temp) && (temp != nozzle)) {
prev = temp;
temp = temp->next;
}
if (nozzle == prev) {
lib_cfg.head = nozzle->next;
} else {
prev->next = nozzle->next;
}
ip = nozzle->ip;
while (ip) {
ip_next = ip->next;
free(ip);
ip = ip_next;
}
destroy_iface(nozzle);
out_clean:
pthread_mutex_unlock(&config_mutex);
errno = savederrno;
return err;
}
int nozzle_set_up(nozzle_t nozzle)
{
int err = 0, savederrno = 0;
struct ifreq ifr;
savederrno = pthread_mutex_lock(&config_mutex);
if (savederrno) {
errno = savederrno;
return -1;
}
if (!is_valid_nozzle(nozzle)) {
savederrno = EINVAL;
err = -1;
goto out_clean;
}
if (nozzle->up) {
goto out_clean;
}
memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifname, nozzle->name, IFNAMSIZ);
err = ioctl(lib_cfg.ioctlfd, SIOCGIFFLAGS, &ifr);
if (err) {
savederrno = errno;
goto out_clean;
}
ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
err = ioctl(lib_cfg.ioctlfd, SIOCSIFFLAGS, &ifr);
if (err) {
savederrno = errno;
goto out_clean;
}
nozzle->up = 1;
out_clean:
pthread_mutex_unlock(&config_mutex);
errno = savederrno;
return err;
}
int nozzle_set_down(nozzle_t nozzle)
{
int err = 0, savederrno = 0;
savederrno = pthread_mutex_lock(&config_mutex);
if (savederrno) {
errno = savederrno;
return -1;
}
if (!is_valid_nozzle(nozzle)) {
savederrno = EINVAL;
err = -1;
goto out_clean;
}
err = set_iface_down(nozzle);
savederrno = errno;
out_clean:
pthread_mutex_unlock(&config_mutex);
errno = savederrno;
return err;
}
int nozzle_get_mtu(const nozzle_t nozzle)
{
int err = 0, savederrno = 0;
savederrno = pthread_mutex_lock(&config_mutex);
if (savederrno) {
errno = savederrno;
return -1;
}
if (!is_valid_nozzle(nozzle)) {
savederrno = EINVAL;
err = -1;
goto out_clean;
}
err = get_iface_mtu(nozzle);
savederrno = errno;
out_clean:
pthread_mutex_unlock(&config_mutex);
savederrno = errno;
return err;
}
int nozzle_get_mac(const nozzle_t nozzle, char **ether_addr)
{
int err = 0, savederrno = 0;
if (!ether_addr) {
errno = EINVAL;
return -1;
}
savederrno = pthread_mutex_lock(&config_mutex);
if (savederrno) {
errno = savederrno;
return -1;
}
if (!is_valid_nozzle(nozzle)) {
savederrno = EINVAL;
err = -1;
goto out_clean;
}
err = get_iface_mac(nozzle, ether_addr);
out_clean:
pthread_mutex_unlock(&config_mutex);
errno = savederrno;
return err;
}
int nozzle_set_mac(nozzle_t nozzle, const char *ether_addr)
{
int err = 0, savederrno = 0;
struct ifreq ifr;
if (!ether_addr) {
errno = EINVAL;
return -1;
}
savederrno = pthread_mutex_lock(&config_mutex);
if (savederrno) {
errno = savederrno;
return -1;
}
if (!is_valid_nozzle(nozzle)) {
savederrno = EINVAL;
err = -1;
goto out_clean;
}
memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifname, nozzle->name, IFNAMSIZ);
#ifdef KNET_LINUX
err = ioctl(lib_cfg.ioctlfd, SIOCGIFHWADDR, &ifr);
if (err) {
savederrno = errno;
goto out_clean;
}
memmove(ifr.ifr_hwaddr.sa_data, ether_aton(ether_addr), ETH_ALEN);
err = ioctl(lib_cfg.ioctlfd, SIOCSIFHWADDR, &ifr);
savederrno = errno;
#endif
#ifdef KNET_BSD
err = ioctl(lib_cfg.ioctlfd, SIOCGIFADDR, &ifr);
if (err) {
savederrno = errno;
goto out_clean;
}
memmove(ifr.ifr_addr.sa_data, ether_aton(ether_addr), ETHER_ADDR_LEN);
ifr.ifr_addr.sa_len = ETHER_ADDR_LEN;
err = ioctl(lib_cfg.ioctlfd, SIOCSIFLLADDR, &ifr);
savederrno = errno;
#endif
out_clean:
pthread_mutex_unlock(&config_mutex);
errno = savederrno;
return err;
}
int nozzle_reset_mac(nozzle_t nozzle)
{
return nozzle_set_mac(nozzle, nozzle->default_mac);
}
nozzle_t nozzle_get_handle_by_name(const char *devname)
{
int savederrno = 0;
nozzle_t nozzle;
if ((devname == NULL) || (strlen(devname) > IFNAMSIZ)) {
errno = EINVAL;
return NULL;
}
savederrno = pthread_mutex_lock(&config_mutex);
if (savederrno) {
errno = savederrno;
return NULL;
}
nozzle = lib_cfg.head;
while (nozzle != NULL) {
if (!strcmp(devname, nozzle->name))
break;
nozzle = nozzle->next;
}
if (!nozzle) {
savederrno = ENOENT;
}
pthread_mutex_unlock(&config_mutex);
errno = savederrno;
return nozzle;
}
const char *nozzle_get_name_by_handle(const nozzle_t nozzle)
{
int savederrno = 0;
char *name = NULL;
savederrno = pthread_mutex_lock(&config_mutex);
if (savederrno) {
errno = savederrno;
return NULL;
}
if (!is_valid_nozzle(nozzle)) {
savederrno = ENOENT;
goto out_clean;
}
name = nozzle->name;
out_clean:
pthread_mutex_unlock(&config_mutex);
errno = savederrno;
return name;
}
int nozzle_get_fd(const nozzle_t nozzle)
{
int fd = -1, savederrno = 0;
savederrno = pthread_mutex_lock(&config_mutex);
if (savederrno) {
errno = savederrno;
return -1;
}
if (!is_valid_nozzle(nozzle)) {
savederrno = ENOENT;
fd = -1;
goto out_clean;
}
fd = nozzle->fd;
out_clean:
pthread_mutex_unlock(&config_mutex);
errno = savederrno;
return fd;
}
diff --git a/libnozzle/tests/Makefile.am b/libnozzle/tests/Makefile.am
index e02593df..78419d1c 100644
--- a/libnozzle/tests/Makefile.am
+++ b/libnozzle/tests/Makefile.am
@@ -1,40 +1,40 @@
#
# Copyright (C) 2010-2017 Red Hat, Inc. All rights reserved.
#
# Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
#
# This software licensed under GPL-2.0+, LGPL-2.0+
#
MAINTAINERCLEANFILES = Makefile.in
include $(top_srcdir)/build-aux/check.mk
EXTRA_DIST = tap_updown_bad tap_updown_good api-test-coverage
if BUILD_LIBNOZZLE
check_PROGRAMS = nozzle_test
TESTS = $(check_PROGRAMS)
noinst_PROGRAMS = $(check_PROGRAMS)
check-local: check-api-test-coverage
check-api-test-coverage:
chmod u+x $(top_srcdir)/libnozzle/tests/api-test-coverage
$(top_srcdir)/libnozzle/tests/api-test-coverage $(top_srcdir) $(top_builddir)
nozzle_test_SOURCES = nozzle_test.c \
../internals.c
nozzle_test_CPPFLAGS = -I$(top_srcdir)/libnozzle \
-DABSBUILDDIR=\"$(abs_builddir)\"
-nozzle_test_CFLAGS = $(PTHREAD_CFLAGS)
+nozzle_test_CFLAGS = $(PTHREAD_CFLAGS) $(libnl_CFLAGS)
nozzle_test_LDFLAGS = $(top_builddir)/libnozzle/libnozzle.la \
- $(PTHREAD_LIBS)
+ $(PTHREAD_LIBS) $(libnl_LIBS)
endif

File Metadata

Mime Type
text/x-diff
Expires
Tue, Feb 25, 12:12 AM (22 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1464553
Default Alt Text
(59 KB)

Event Timeline