Page MenuHomeClusterLabs Projects

No OneTemporary

diff --git a/README b/README
index deb865aa..bd7c0f8a 100644
--- a/README
+++ b/README
@@ -1,45 +1,53 @@
#
# Copyright (C) 2010-2025 Red Hat, Inc. All rights reserved.
#
# Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
#
# This software licensed under GPL-2.0+
#
Upstream resources
------------------
https://github.com/kronosnet/kronosnet/
https://ci.kronosnet.org/
https://projects.clusterlabs.org/project/board/86/ (TODO list and activities tracking)
https://drive.google.com/drive/folders/0B_zxAPgZTkM_TklfYzN6a2FYUFE?resourcekey=0-Cfr5D94rZ8LVbeMPGjxbdg&usp=sharing (google shared drive)
https://lists.kronosnet.org/mailman3/postorius/lists/users.lists.kronosnet.org/
https://lists.kronosnet.org/mailman3/postorius/lists/devel.lists.kronosnet.org/
https://lists.kronosnet.org/mailman3/postorius/lists/commits.lists.kronosnet.org/
https://kronosnet.org/ (web 0.1 style)
IRC: #kronosnet on Libera.Chat
Architecture
------------
Please refer to the google shared drive Presentations directory for
diagrams and fancy schemas
Running knet on FreeBSD
-----------------------
knet requires big socket buffers and you need to set:
kern.ipc.maxsockbuf=18388608
in /etc/sysctl.conf or knet will fail to run.
For version 12 (or lower), knet requires also:
net.inet.sctp.blackhole=1
in /etc/sysctl.conf or knet will fail to work with SCTP.
This sysctl is obsoleted in version 13.
libnozzle requires if_tap.ko loaded in the kernel.
Please avoid to use ifconfig_DEFAULT in /etc/rc.conf to use
DHCP for all interfaces or the dhclient will interfere with
libnozzle interface management, causing errors on some
operations such as "ifconfig tap down".
+
+Running on Solaris / Illumos
+----------------------------
+
+Tune socket buffers for the protocol you intend to use:
+
+ndd -set /dev/udp udp_max_buf 8388608
+ndd -set /dev/sctp sctp_max_buf 8388608
diff --git a/configure.ac b/configure.ac
index 7d4b0459..94e45643 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,475 +1,591 @@
#
# Copyright (C) 2010-2025 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+
#
# -*- 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])
+AC_CANONICAL_HOST
+
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"])])
+case "$host_os" in
+ solaris*)
+ AC_MSG_NOTICE([Skipping --enable-new-dtags check, Solaris' RPATH logic is like RUNPATH on other platforms])
+ ;;
+ *)
+ 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 on ${host_os}"])])
+ ;;
+esac
AX_CHECK_LINK_FLAG([-Wl,--as-needed], [AM_LDFLAGS="$AM_LDFLAGS -Wl,--as-needed"])
saved_LDFLAGS="$LDFLAGS"
LDFLAGS="$AM_LDFLAGS $LDFLAGS"
LT_INIT
LDFLAGS="$saved_LDFLAGS"
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([libknet/handle.c])
AC_CONFIG_HEADERS([config.h])
-AC_CANONICAL_HOST
-
AC_LANG([C])
if test "$prefix" = "NONE"; then
prefix="/usr"
if test "$localstatedir" = "\${prefix}/var"; then
localstatedir="/var"
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
m4_version_prereq([2.70], [:], [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"])
AC_CHECK_PROGS([COVBUILD_EXEC], [cov-build])
AM_CONDITIONAL([HAS_COVBUILD], [test x$COVBUILD_EXEC != "x"])
AC_CHECK_PROGS([COVANALYZE_EXEC], [cov-analyze])
AM_CONDITIONAL([HAS_COVANALYZE], [test x$COVANALYZE_EXEC != "x"])
AC_CHECK_PROGS([COVFORMATERRORS_EXEC], [cov-format-errors])
AM_CONDITIONAL([HAS_COVFORMATERRORS], [test x$COVFORMATERRORS_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([functional-tests],
[AS_HELP_STRING([--disable-functional-tests],[disable execution of functional tests, useful for old and slow arches])],,
[ enable_functional_tests="yes" ])
AM_CONDITIONAL([RUN_FUN_TESTS], [test x$enable_functional_tests = 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])])
AC_ARG_ENABLE([compress-all],
[AS_HELP_STRING([--disable-compress-all],[disable libknet all compress modules support])],,
[ enable_compress_all="yes" ])
KNET_OPTION_DEFINES([zstd],[compress],[PKG_CHECK_MODULES([libzstd], [libzstd])])
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([install-tests],
[AS_HELP_STRING([--enable-install-tests],[install tests])],,
[ enable_install_tests="no" ])
AM_CONDITIONAL([INSTALL_TESTS], [test x$enable_install_tests = 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" ])
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="-Werror $@"
AC_MSG_CHECKING([whether $CC supports "$@"])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>], [
#ifdef __USE_FORTIFY_LEVEL
printf("%d\n", __USE_FORTIFY_LEVEL)
#else
printf("hello world\n")
#endif
])],
[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])])
+AC_CHECK_LIB([socket], [socket], [LIBS="$LIBS -lsocket"])
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"
# Check RTLD_DI_ORIGIN (not decalred by musl. glibc has it as an enum so cannot use ifdef)
AC_CHECK_DECL([RTLD_DI_ORIGIN], [AC_DEFINE([HAVE_RTLD_DI_ORIGIN], 1,
[define when RTLD_DI_ORIGIN is declared])], ,[[#include <dlfcn.h>]])
+AC_CHECK_DECLS([MSG_NOSIGNAL], [], [CFLAGS="$CFLAGS -DMSG_NOSIGNAL=0"], [#include <sys/socket.h>])
+
# 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])
;;
+ solaris*)
+ AC_DEFINE_UNQUOTED([KNET_SOLARIS], [1], [Compiling for Solaris platform])
+ build_for_solaris=yes
+ AC_MSG_RESULT([Solaris])
+ ;;
*)
AC_MSG_ERROR([Unsupported OS? hmmmm])
;;
esac
+AM_CONDITIONAL([BUILD_FOR_SOLARIS], [test "x$build_for_solaris" = "xyes"])
+
# 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"])])
+ AC_CHECK_LIB([sctp], [sctp_bindx], [LIBS="$LIBS -lsctp"], [
+ AC_MSG_ERROR([sctp library (-lsctp) not found.])
+ ])
+ AC_CACHE_CHECK([for netinet/sctp.h with netinet/in.h included], [ac_cv_have_sctp], [
+ AC_TRY_LINK([
+ #include <netinet/in.h>
+ #include <netinet/sctp.h>
+ ], [sctp_assoc_t my_sctp_assoc;],
+ [ac_cv_have_sctp=yes],
+ [AC_MSG_ERROR(["missing required sctp headers"])])
+ ])
+ if test "x$ac_cv_have_sctp" = xyes; then
+ AC_DEFINE([HAVE_NETINET_SCTP_H], [1], [define when HAVE_NETINET_SCTP_H is declared])
+ fi
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
PKG_CHECK_MODULES([libqb], [libqb])
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
AC_ARG_VAR([DOXYGEN2MAN], [override doxygen2man executable])
if test "x$cross_compiling" = "xno"; then
PKG_CHECK_VAR([libqb_PREFIX], [libqb], [prefix])
AC_PATH_PROG([DOXYGEN2MAN], [doxygen2man], [no], [$libqb_PREFIX/bin$PATH_SEPARATOR$PATH])
fi
if test "x$DOXYGEN2MAN" = "xno"; then
# 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_VAR([libqb_BUILD_PREFIX], [libqb], [prefix])
AC_PATH_PROG([DOXYGEN2MAN], [doxygen2man], [no], [$libqb_BUILD_PREFIX/bin$PATH_SEPARATOR$PATH])
if test "x$DOXYGEN2MAN" = "xno"; then
PKG_CHECK_MODULES([libxml_BUILD], [libxml-2.0])
DOXYGEN2MAN="\${abs_top_builddir}/man/doxyxml"
build_doxy=yes
fi
PKG_CONFIG="$saved_PKG_CONFIG"
ac_cv_path_PKG_CONFIG="$saved_ac_cv_path_PKG_CONFIG"
fi
AC_SUBST([DOXYGEN2MAN])
fi
AM_CONDITIONAL([BUILD_DOXYXML], [test "x$build_doxy" = "xyes"])
# 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 >= 3.3], [],
[PKG_CHECK_MODULES([libnlroute], [libnl-route-3.0 < 3.3],
[AC_DEFINE_UNQUOTED([LIBNL3_WORKAROUND], [1], [Enable libnl < 3.3 build workaround])], [])])
fi
fi
# local options
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],[enable debug build])])
AC_ARG_ENABLE([hardening],
[AS_HELP_STRING([--disable-hardening],[disable hardening build flags])],,
[ enable_hardening="yes" ])
AC_ARG_WITH([testdir],
[AS_HELP_STRING([--with-testdir=DIR],[path to /usr/lib../kronosnet/tests/ dir where to install the test suite])],
[ TESTDIR="$withval" ],
[ TESTDIR="$libdir/kronosnet/tests" ])
## do subst
AC_SUBST([TESTDIR])
# 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
# Check for availablility of hardening options
annocheck=no
if test "x${enable_hardening}" = xyes; then
# support only gcc for now
if echo $CC | grep -q gcc; then
ANNOPLUGIN="-fplugin=annobin"
annocheck=yes
fi
FORTIFY_CFLAGS=""
if test "x${enable_debug}" != xyes; then
for j in 3 2; do
FORTIFY_CFLAGS_TEMP="-D_FORTIFY_SOURCE=$j"
if cc_supports_flag "$OPT_CFLAGS $FORTIFY_CFLAGS_TEMP"; then
FORTIFY_CFLAGS="$FORTIFY_CFLAGS_TEMP"
break
fi
done
fi
- HARDENING_CFLAGS_ANNOCHECK="$ANNOPLUGIN -fPIC -DPIC -pie -fstack-protector-strong -fexceptions -D_GLIBCXX_ASSERTIONS -Wl,-z,now"
+ HARDENING_CFLAGS_ANNOCHECK="$ANNOPLUGIN -fPIC -DPIC"
+case "$host_os" in
+ solaris*)
+ # no support for -pie when linking, but supported during compile
+ ;;
+ *)
+ HARDENING_CFLAGS_ANNOCHECK="$HARDENING_CFLAGS_ANNOCHECK -pie"
+ ;;
+esac
+ HARDENING_CFLAGS_ANNOCHECK="$HARDENING_CFLAGS_ANNOCHECK -fstack-protector-strong -fexceptions -D_GLIBCXX_ASSERTIONS -Wl,-z,now"
HARDENING_CFLAGS="-fstack-clash-protection -fcf-protection=full -mcet -mstackrealign"
EXTRA_HARDENING_CFLAGS=""
# check for annobin required cflags/ldflags
for j in $HARDENING_CFLAGS_ANNOCHECK; do
if cc_supports_flag $j; then
EXTRA_HARDENING_CFLAGS="$EXTRA_HARDENING_CFLAGS $j"
else
annocheck=no
fi
done
# check for other hardening cflags/ldflags
for j in $HARDENING_CFLAGS; do
if cc_supports_flag $j; then
EXTRA_HARDENING_CFLAGS="$EXTRA_HARDENING_CFLAGS $j"
fi
done
EXTRA_HARDENING_CFLAGS="$EXTRA_HARDENING_CFLAGS $FORTIFY_CFLAGS"
# check if annocheck binary is available
if test "x${annocheck}" = xyes; then
AC_CHECK_PROGS([ANNOCHECK_EXEC], [annocheck])
if test "x${ANNOCHECK_EXEC}" = x; then
annocheck=no
fi
fi
AM_LDFLAGS="$AM_LDFLAGS $EXTRA_HARDENING_CFLAGS"
fi
if test "x${enable_debug}" = xyes; then
annocheck=no
fi
AM_CONDITIONAL([HAS_ANNOCHECK], [test "x$annocheck" = "xyes"])
# gdb flags
if test "x${GCC}" = xyes; then
GDB_CFLAGS="-ggdb3"
else
GDB_CFLAGS="-g"
fi
+# check flags for strdup()
+AC_CACHE_CHECK([for strdup requiring __EXTENSIONS__], [ac_cv_func_strdup], [
+ ac_cv_func_strdup=yes
+ # First, try to link with strdup() using standard flags
+ AC_TRY_LINK([
+ #include <string.h>
+ #include <stdlib.h>
+ ], [
+ char *s = strdup("test");
+ free(s);
+ ], [ac_cv_func_strdup=yes], [
+ # Failure, try again with -D__EXTENSIONS__
+ CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
+ AC_TRY_LINK([
+ #include <string.h>
+ #include <stdlib.h>
+ ], [
+ char *s = strdup("test");
+ free(s);
+ ],
+ [ac_cv_func_strdup=yes],
+ [AC_MSG_ERROR([no strdup() found])])
+ ])
+])
+
+# check flags for CMSG_SPACE()
+AC_CACHE_CHECK([for CMSG_SPACE() requiring _XOPEN_SOURCE], [ac_cv_macro_xopen_source], [
+ # First, try to link with strdup() using standard flags
+ AC_TRY_LINK([#include <sys/socket.h>], [
+ char c[CMSG_SPACE(1)];
+ c[0] = 'J';
+ ], [ac_cv_macro_xopen_source=yes], [
+ # Failure, try again with -D_XOPEN_SOURCE
+ CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
+ AC_TRY_LINK([#include <sys/socket.h>], [
+ char c[CMSG_SPACE(1)];
+ c[0] = 'J';
+ ],
+ [ac_cv_macro_xopen_source=yes],
+ [AC_MSG_ERROR([no CMSG_SPACE() found])])
+ ])
+])
+
+# check for character index warning
+AC_CACHE_CHECK([if -Wchar-subscripts warns for int8_t], [ac_cv_int8_t_warn], [
+ saveCFLAGS="$CFLAGS"
+ CFLAGS="-Werror -Wchar-subscripts"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdint.h>], [
+ char arr[256];
+ uint8_t i = 200;
+ arr[i] = 'J';
+ return 0;
+ ])],
+ [ac_cv_int8_t_warn=no],
+ [ac_cv_int8_t_warn=yes])
+ CFLAGS="$saveCFLAGS"
+])
+if test "x$ac_cv_int8_t_warn" = xyes; then
+ CFLAGS="$CFLAGS -Wno-char-subscripts"
+fi
+
+
DEFAULT_CFLAGS="-Werror -Wall -Wextra"
# manual overrides
# generates too much noise for stub APIs
UNWANTED_CFLAGS="-Wno-unused-parameter"
AC_SUBST([AM_CFLAGS],["$OPT_CFLAGS $GDB_CFLAGS $DEFAULT_CFLAGS $EXTRA_HARDENING_CFLAGS $UNWANTED_CFLAGS"])
AC_SUBST([AM_LDFLAGS])
AX_PROG_DATE
+case "$host_os" in
+ solaris*)
+ AC_CHECK_PROGS([DATE], [gdate date], [:])
+ AS_IF([test "x$DATE" != "x:"], [
+ ax_cv_prog_date_gnu_date="yes"
+ ax_cv_prog_date_gnu_utc="yes"
+ ])
+ ;;
+ *)
+ AC_CHECK_PROGS([DATE], [date], [:])
+ ;;
+esac
+AS_IF([test "x$DATE" = "x:"],
+ [AC_MSG_ERROR([Date command not found.])])
+
AS_IF([test "$ax_cv_prog_date_gnu_date:$ax_cv_prog_date_gnu_utc" = yes:yes],
- [UTC_DATE_AT="date -u -d@"],
+ [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])])])
+ [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)])])],
+ 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
libnozzle/Makefile
libnozzle/libnozzle.pc
libnozzle/tests/Makefile
libknet/Makefile
libknet/libknet.pc
libknet/tests/Makefile
man/Makefile
man/Doxyfile-knet
man/Doxyfile-nozzle
])
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/libknet/Makefile.am b/libknet/Makefile.am
index 7fad9694..5b2de5ec 100644
--- a/libknet/Makefile.am
+++ b/libknet/Makefile.am
@@ -1,170 +1,167 @@
#
# Copyright (C) 2010-2025 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+
#
MAINTAINERCLEANFILES = Makefile.in
include $(top_srcdir)/build-aux/check.mk
SYMFILE = libknet_exported_syms
EXTRA_DIST = $(SYMFILE)
SUBDIRS = . tests
# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
libversion = 5:0:4
-# override global LIBS that pulls in lots of craft we don't need here
-LIBS =
-
sources = \
common.c \
compat.c \
compress.c \
crypto.c \
handle.c \
handle_api.c \
host.c \
lib_config.c \
links.c \
links_acl.c \
links_acl_ip.c \
links_acl_loopback.c \
logging.c \
netutils.c \
onwire.c \
threads_common.c \
threads_dsthandler.c \
threads_heartbeat.c \
threads_pmtud.c \
threads_rx.c \
threads_tx.c \
transports.c \
transport_common.c \
transport_loopback.c \
transport_udp.c \
transport_sctp.c
include_HEADERS = libknet.h
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libknet.pc
noinst_HEADERS = \
common.h \
compat.h \
compress.h \
compress_model.h \
crypto.h \
crypto_model.h \
host.h \
internals.h \
links.h \
links_acl.h \
links_acl_ip.h \
links_acl_loopback.h \
logging.h \
netutils.h \
onwire.h \
threads_common.h \
threads_dsthandler.h \
threads_heartbeat.h \
threads_pmtud.h \
threads_rx.h \
threads_tx.h \
transports.h \
transport_common.h \
transport_loopback.h \
transport_udp.h \
transport_sctp.h
lib_LTLIBRARIES = libknet.la
libknet_la_SOURCES = $(sources)
AM_CFLAGS += $(libqb_CFLAGS)
-libknet_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) \
+libknet_la_CFLAGS = $(LIBS) $(AM_CFLAGS) $(PTHREAD_CFLAGS) \
-DPLUGINPATH="\"$(pkglibdir)\""
EXTRA_libknet_la_DEPENDENCIES = $(SYMFILE)
libknet_la_LDFLAGS = $(AM_LDFLAGS) \
-Wl,--version-script=$(srcdir)/$(SYMFILE) \
-version-info $(libversion)
libknet_la_LIBADD = $(PTHREAD_LIBS) $(dl_LIBS) $(rt_LIBS) $(m_LIBS)
check-local: check-annocheck-libs
# Prepare empty value for appending
pkglib_LTLIBRARIES =
# MODULE_LDFLAGS would mean a target-specific variable for Automake
MODULELDFLAGS = $(AM_LDFLAGS) -module -avoid-version -export-dynamic
if BUILD_COMPRESS_ZSTD
pkglib_LTLIBRARIES += compress_zstd.la
compress_zstd_la_LDFLAGS = $(MODULELDFLAGS)
compress_zstd_la_CFLAGS = $(AM_CFLAGS) $(libzstd_CFLAGS)
compress_zstd_la_LIBADD = $(libzstd_LIBS)
endif
if BUILD_COMPRESS_ZLIB
pkglib_LTLIBRARIES += compress_zlib.la
compress_zlib_la_LDFLAGS = $(MODULELDFLAGS)
compress_zlib_la_CFLAGS = $(AM_CFLAGS) $(zlib_CFLAGS)
compress_zlib_la_LIBADD = $(zlib_LIBS)
endif
if BUILD_COMPRESS_LZ4
pkglib_LTLIBRARIES += compress_lz4.la compress_lz4hc.la
compress_lz4_la_LDFLAGS = $(MODULELDFLAGS)
compress_lz4_la_CFLAGS = $(AM_CFLAGS) $(liblz4_CFLAGS)
compress_lz4_la_LIBADD = $(liblz4_LIBS)
compress_lz4hc_la_LDFLAGS = $(MODULELDFLAGS)
compress_lz4hc_la_CFLAGS = $(AM_CFLAGS) $(liblz4_CFLAGS)
compress_lz4hc_la_LIBADD = $(liblz4_LIBS)
endif
if BUILD_COMPRESS_LZO2
pkglib_LTLIBRARIES += compress_lzo2.la
compress_lzo2_la_LDFLAGS = $(MODULELDFLAGS)
compress_lzo2_la_CFLAGS = $(AM_CFLAGS) $(lzo2_CFLAGS)
compress_lzo2_la_LIBADD = $(lzo2_LIBS)
endif
if BUILD_COMPRESS_LZMA
pkglib_LTLIBRARIES += compress_lzma.la
compress_lzma_la_LDFLAGS = $(MODULELDFLAGS)
compress_lzma_la_CFLAGS = $(AM_CFLAGS) $(liblzma_CFLAGS)
compress_lzma_la_LIBADD = $(liblzma_LIBS)
endif
if BUILD_COMPRESS_BZIP2
pkglib_LTLIBRARIES += compress_bzip2.la
compress_bzip2_la_LDFLAGS = $(MODULELDFLAGS)
compress_bzip2_la_CFLAGS = $(AM_CFLAGS) $(bzip2_CFLAGS)
compress_bzip2_la_LIBADD = $(bzip2_LIBS)
endif
if BUILD_CRYPTO_NSS
pkglib_LTLIBRARIES += crypto_nss.la
crypto_nss_la_LDFLAGS = $(MODULELDFLAGS)
crypto_nss_la_CFLAGS = $(AM_CFLAGS) $(nss_CFLAGS)
crypto_nss_la_LIBADD = $(nss_LIBS)
endif
if BUILD_CRYPTO_OPENSSL
pkglib_LTLIBRARIES += crypto_openssl.la
crypto_openssl_la_LDFLAGS = $(MODULELDFLAGS)
crypto_openssl_la_CFLAGS = $(AM_CFLAGS) $(openssl_CFLAGS)
crypto_openssl_la_LIBADD = $(openssl_LIBS)
endif
diff --git a/libknet/tests/Makefile.am b/libknet/tests/Makefile.am
index 12c2574f..029f33ef 100644
--- a/libknet/tests/Makefile.am
+++ b/libknet/tests/Makefile.am
@@ -1,122 +1,122 @@
#
# Copyright (C) 2016-2025 Red Hat, Inc. All rights reserved.
#
# Authors: Fabio M. Di Nitto <fabbione@kronosnet.org>
#
# This software licensed under GPL-2.0+
#
MAINTAINERCLEANFILES = Makefile.in
include $(top_srcdir)/build-aux/check.mk
include $(top_srcdir)/libknet/tests/api-check.mk
EXTRA_DIST = \
api-test-coverage \
api-check.mk
AM_CPPFLAGS = -I$(top_srcdir)/libknet
AM_CFLAGS += $(PTHREAD_CFLAGS) $(libqb_CFLAGS)
-LIBS = $(top_builddir)/libknet/libknet.la \
+LIBS += $(top_builddir)/libknet/libknet.la \
$(PTHREAD_LIBS) $(dl_LIBS)
noinst_HEADERS = \
test-common.h
# the order of those tests is NOT random.
# some functions can only be tested properly after some dependents
# API have been validated upfront.
check_PROGRAMS = \
$(api_checks) \
$(int_checks)
if RUN_FUN_TESTS
check_PROGRAMS += $(fun_checks)
endif
int_checks = \
int_links_acl_ip_test \
int_timediff_test
fun_checks = \
fun_config_crypto_test \
fun_acl_check_test
# checks below need to be executed manually
# or with a specifi environment
long_run_checks = \
fun_pmtud_crypto_test
benchmarks = \
knet_bench_test
noinst_PROGRAMS = \
api_knet_handle_new_limit_test \
pckt_test \
$(benchmarks) \
$(long_run_checks) \
$(api_checks) \
$(int_checks) \
$(fun_checks)
noinst_SCRIPTS = \
api-test-coverage
TESTS = $(check_PROGRAMS)
if INSTALL_TESTS
testsuitedir = $(TESTDIR)
testsuite_PROGRAMS = $(noinst_PROGRAMS)
endif
check-local: check-api-test-coverage check-annocheck-bins
check-api-test-coverage:
chmod u+x $(top_srcdir)/libknet/tests/api-test-coverage
$(top_srcdir)/libknet/tests/api-test-coverage $(top_srcdir) $(top_builddir)
pckt_test_SOURCES = pckt_test.c
int_links_acl_ip_test_SOURCES = int_links_acl_ip.c \
../common.c \
../compat.c \
../logging.c \
../netutils.c \
../threads_common.c \
../onwire.c \
../transports.c \
../transport_common.c \
../transport_loopback.c \
../transport_sctp.c \
../transport_udp.c \
../links_acl.c \
../links_acl_ip.c \
../links_acl_loopback.c \
../lib_config.c
int_timediff_test_SOURCES = int_timediff.c
knet_bench_test_SOURCES = knet_bench.c \
test-common.c \
../common.c \
../logging.c \
../compat.c \
../transport_common.c \
../threads_common.c \
../onwire.c \
../lib_config.c
fun_pmtud_crypto_test_SOURCES = fun_pmtud_crypto.c \
test-common.c \
../onwire.c \
../logging.c \
../threads_common.c \
../lib_config.c
fun_config_crypto_test_SOURCES = fun_config_crypto.c \
test-common.c
fun_acl_check_test_SOURCES = fun_acl_check.c \
test-common.c
diff --git a/libknet/tests/api-test-coverage b/libknet/tests/api-test-coverage
index 6b4c0954..c4b1be71 100755
--- a/libknet/tests/api-test-coverage
+++ b/libknet/tests/api-test-coverage
@@ -1,90 +1,97 @@
#!/bin/sh
#
# Copyright (C) 2016-2025 Red Hat, Inc. All rights reserved.
#
# Author: Fabio M. Di Nitto <fabbione@kronosnet.org>
#
# This software licensed under GPL-2.0+
#
+grep=grep
+nm=nm
+if [ $(uname -s) == "SunOS" ]; then
+ grep=ggrep
+ nm=gnm
+fi
srcdir="$1"/libknet/tests
builddir="$2"/libknet/tests
-headerapicalls="$(grep knet_ "$srcdir"/../libknet.h | grep -v "^ \*" | grep -v ^struct | grep -v "^[[:space:]]" | grep -v typedef | sed -e 's/(.*//g' -e 's/^const //g' -e 's/\*//g' | awk '{print $2}')"
+headerapicalls="$($grep knet_ "$srcdir"/../libknet.h | $grep -v "^ \*" | $grep -v ^struct | $grep -v "^[[:space:]]" | $grep -v typedef | sed -e 's/(.*//g' -e 's/^const //g' -e 's/\*//g' | awk '{print $2}')"
# The PowerPC64 ELFv1 ABI defines the address of a function as that of a
# function descriptor defined in .opd, a data (D) section. Other ABIs
# use the entry address of the function itself in the text (T) section.
-exportedapicalls="$(nm -B -D "$builddir"/../.libs/libknet.so | grep ' [DT] ' | awk '{print $3}' | sed -e 's#@@LIBKNET##g')"
+# Filter additional symbols exported by ln(1) on Solaris.
+exportedapicalls="$($nm -B -D "$builddir"/../.libs/libknet.so | $grep ' [DT] ' | awk '{if ($3 != "_edata" && $3 != "_GLOBAL_OFFSET_TABLE_" && $3 != "_PROCEDURE_LINKAGE_TABLE_") {print $3}}' | sed -e 's#@@LIBKNET##g')"
echo "Checking for exported symbols NOT available in header file"
for i in $exportedapicalls; do
found=0
for x in $headerapicalls; do
if [ "$x" = "$i" ]; then
found=1
break;
fi
done
if [ "$found" = 0 ]; then
echo "Symbol $i not found in header file"
exit 1
fi
done
echo "Checking for symbols in header file NOT exported by binary lib"
for i in $headerapicalls; do
found=0
for x in $exportedapicalls; do
if [ "$x" = "$i" ]; then
found=1
break;
fi
done
if [ "$found" = 0 ]; then
echo "Symbol $i not found in binary lib"
exit 1
fi
done
echo "Checking for tests with memcheck exceptions"
-for i in $(grep -l is_memcheck "$srcdir"/*.c | grep -v test-common); do
+for i in $($grep -l is_memcheck "$srcdir"/*.c | $grep -v test-common); do
echo "WARNING: $(basename $i) - has memcheck exception enabled"
done
echo "Checking for tests with helgrind exceptions"
-for i in $(grep -l is_helgrind "$srcdir"/*.c | grep -v test-common); do
+for i in $($grep -l is_helgrind "$srcdir"/*.c | $grep -v test-common); do
echo "WARNING: $(basename $i) has helgrind exception enabled"
done
echo "Checking for api test coverage"
numapicalls=0
found=0
missing=0
for i in $headerapicalls; do
[ "$i" = knet_handle_new_ex ] && i=knet_handle_new # tested together
numapicalls=$((numapicalls + 1))
if [ -f $srcdir/api_${i}.c ]; then
found=$((found + 1))
else
missing=$((missing + 1))
echo "MISSING: $i"
fi
done
echo "Summary"
echo "-------"
echo "Found : $found"
echo "Missing : $missing"
echo "Total : $numapicalls"
which bc > /dev/null 2>&1 && {
coverage=$(echo "scale=3; $found / $numapicalls * 100" | bc -l)
echo "Coverage: $coverage%"
}
exit 0
diff --git a/libknet/tests/fun_pmtud_crypto.c b/libknet/tests/fun_pmtud_crypto.c
index b19e236a..44c8b701 100644
--- a/libknet/tests/fun_pmtud_crypto.c
+++ b/libknet/tests/fun_pmtud_crypto.c
@@ -1,243 +1,250 @@
/*
* Copyright (C) 2016-2025 Red Hat, Inc. All rights reserved.
*
* Authors: Fabio M. Di Nitto <fabbione@kronosnet.org>
*
* This software licensed under GPL-2.0+
*/
#include "config.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <inttypes.h>
#include <sys/ioctl.h>
+#ifdef KNET_SOLARIS
+#include <sys/sockio.h>
+#else
#include <net/ethernet.h>
+#endif
#include <ifaddrs.h>
#include <net/if.h>
#include "libknet.h"
#include "compress.h"
#include "internals.h"
#include "netutils.h"
#include "onwire.h"
#include "test-common.h"
static int private_data;
static void sock_notify(void *pvt_data,
int datafd,
int8_t channel,
uint8_t tx_rx,
int error,
int errorno)
{
return;
}
static int iface_fd = 0;
static int default_mtu = 0;
#ifdef KNET_LINUX
const char *loopback = "lo";
-#endif
-#ifdef KNET_BSD
+#else
+ #if defined(KNET_BSD) || defined(KNET_SOLARIS)
const char *loopback = "lo0";
+ #else
+ #error unspportes OS
+ #endif
#endif
static int fd_init(void)
{
#ifdef KNET_LINUX
return socket(AF_INET, SOCK_STREAM, 0);
#endif
#ifdef KNET_BSD
return socket(AF_LOCAL, SOCK_DGRAM, 0);
#endif
return -1;
}
static int set_iface_mtu(uint32_t mtu)
{
int err = 0;
struct ifreq ifr;
memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifr.ifr_name, loopback, IFNAMSIZ - 1);
ifr.ifr_mtu = mtu;
err = ioctl(iface_fd, SIOCSIFMTU, &ifr);
return err;
}
static int get_iface_mtu(void)
{
int err = 0, savederrno = 0;
struct ifreq ifr;
memset(&ifr, 0, sizeof(struct ifreq));
strncpy(ifr.ifr_name, loopback, IFNAMSIZ - 1);
err = ioctl(iface_fd, SIOCGIFMTU, &ifr);
if (err) {
savederrno = errno;
goto out_clean;
}
err = ifr.ifr_mtu;
out_clean:
errno = savederrno;
return err;
}
static void exit_local(int exit_code)
{
set_iface_mtu(default_mtu);
close(iface_fd);
iface_fd = 0;
exit(exit_code);
}
#define TESTNODES 1
static void test_mtu(const char *model, const char *crypto, const char *hash)
{
knet_handle_t knet_h[TESTNODES+1];
int logfds[2];
int datafd = 0;
int8_t channel = 0;
struct sockaddr_storage lo;
struct knet_handle_crypto_cfg knet_handle_crypto_cfg;
unsigned int data_mtu, expected_mtu;
size_t calculated_iface_mtu = 0, detected_iface_mtu = 0;
int res;
setup_logpipes(logfds);
knet_h[1] = knet_handle_start(logfds, KNET_LOG_DEBUG, knet_h);
flush_logs(logfds[0], stdout);
printf("Test knet_send with %s and valid data\n", model);
memset(&knet_handle_crypto_cfg, 0, sizeof(struct knet_handle_crypto_cfg));
strncpy(knet_handle_crypto_cfg.crypto_model, model, sizeof(knet_handle_crypto_cfg.crypto_model) - 1);
strncpy(knet_handle_crypto_cfg.crypto_cipher_type, crypto, sizeof(knet_handle_crypto_cfg.crypto_cipher_type) - 1);
strncpy(knet_handle_crypto_cfg.crypto_hash_type, hash, sizeof(knet_handle_crypto_cfg.crypto_hash_type) - 1);
knet_handle_crypto_cfg.private_key_len = 2000;
FAIL_ON_ERR(knet_handle_crypto(knet_h[1], &knet_handle_crypto_cfg));
FAIL_ON_ERR(knet_handle_enable_sock_notify(knet_h[1], &private_data, sock_notify)); // CHECK cond was <0 not !=0
datafd = 0;
channel = -1;
FAIL_ON_ERR(knet_handle_add_datafd(knet_h[1], &datafd, &channel));
FAIL_ON_ERR(knet_host_add(knet_h[1], 1));
FAIL_ON_ERR(_knet_link_set_config(knet_h[1], 1, 0, KNET_TRANSPORT_UDP, 0, AF_INET, 0, &lo));
FAIL_ON_ERR(knet_link_set_pong_count(knet_h[1], 1, 0, 1));
FAIL_ON_ERR(knet_link_set_enable(knet_h[1], 1, 0, 1));
FAIL_ON_ERR(wait_for_host(knet_h[1], 1, 4, logfds[0], stdout));
flush_logs(logfds[0], stdout);
FAIL_ON_ERR(knet_handle_pmtud_get(knet_h[1], &data_mtu));
calculated_iface_mtu = calc_data_outlen(knet_h[1], data_mtu + KNET_HEADER_ALL_SIZE) + 28;
detected_iface_mtu = get_iface_mtu();
/*
* 28 = 20 IP header + 8 UDP header
*/
expected_mtu = calc_max_data_outlen(knet_h[1], detected_iface_mtu - 28);
if (expected_mtu != data_mtu) {
printf("Wrong MTU detected! interface mtu: %zu knet mtu: %u expected mtu: %u\n", detected_iface_mtu, data_mtu, expected_mtu);
clean_exit(knet_h, TESTNODES, logfds, FAIL);
}
if ((detected_iface_mtu - calculated_iface_mtu) >= knet_h[1]->sec_block_size) {
printf("Wrong MTU detected! real iface mtu: %zu calculated: %zu\n", detected_iface_mtu, calculated_iface_mtu);
clean_exit(knet_h, TESTNODES, logfds, FAIL);
}
knet_handle_stop_everything(knet_h, TESTNODES);
close_logpipes(logfds);
}
static void test(const char *model, const char *crypto, const char *hash)
{
int i = 576;
int max = 65535;
while (i <= max) {
printf("Setting interface MTU to: %i\n", i);
set_iface_mtu(i);
test_mtu(model, crypto, hash);
if (i == max) {
break;
}
i = i + 15;
if (i > max) {
i = max;
}
}
}
int main(int argc, char *argv[])
{
struct knet_crypto_info crypto_list[16];
size_t crypto_list_entries;
#ifdef KNET_BSD
if (is_memcheck() || is_helgrind()) {
printf("valgrind-freebsd cannot run this test properly. Skipping\n");
return SKIP;
}
#endif
if (geteuid() != 0) {
printf("This test requires root privileges\n");
return SKIP;
}
iface_fd = fd_init();
if (iface_fd < 0) {
printf("fd_init failed: %s\n", strerror(errno));
return FAIL;
}
default_mtu = get_iface_mtu();
if (default_mtu < 0) {
printf("get_iface_mtu failed: %s\n", strerror(errno));
return FAIL;
}
memset(crypto_list, 0, sizeof(crypto_list));
if (knet_get_crypto_list(crypto_list, &crypto_list_entries) < 0) {
printf("knet_get_crypto_list failed: %s\n", strerror(errno));
return FAIL;
}
if (crypto_list_entries == 0) {
printf("no crypto modules detected. Skipping\n");
return SKIP;
}
test(crypto_list[0].name, "aes128", "sha1");
test(crypto_list[0].name, "aes128", "sha256");
test(crypto_list[0].name, "aes256", "sha1");
test(crypto_list[0].name, "aes256", "sha256");
exit_local(PASS);
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Sep 22, 11:03 PM (15 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2403372
Default Alt Text
(38 KB)

Event Timeline