2009-07-08 13:19:16 -07:00
# -*- autoconf -*-
2017-03-07 20:48:08 -08:00
# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Nicira, Inc.
2009-07-08 13:19:16 -07:00
#
2009-06-15 15:11:30 -07:00
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
2009-07-08 13:19:16 -07:00
#
2009-06-15 15:11:30 -07:00
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
2009-07-08 13:19:16 -07:00
2011-04-12 11:43:11 -07:00
dnl OVS_ENABLE_WERROR
AC_DEFUN([OVS_ENABLE_WERROR],
[AC_ARG_ENABLE(
[Werror],
[AC_HELP_STRING([--enable-Werror], [Add -Werror to CFLAGS])],
[], [enable_Werror=no])
AC_CONFIG_COMMANDS_PRE(
[if test "X$enable_Werror" = Xyes; then
2014-09-11 21:34:21 +02:00
OVS_CFLAGS="$OVS_CFLAGS -Werror"
2017-07-06 15:12:00 -07:00
fi])
# Unless --enable-Werror is specified, report but do not fail the build
# for errors reported by flake8.
if test "X$enable_Werror" = Xyes; then
FLAKE8_WERROR=
else
FLAKE8_WERROR=-
fi
2018-01-11 13:59:04 -08:00
AC_SUBST([FLAKE8_WERROR])
# If --enable-Werror is specified, fail the build on sparse warnings.
if test "X$enable_Werror" = Xyes; then
SPARSE_WERROR=-Wsparse-error
else
SPARSE_WERROR=
fi
AC_SUBST([SPARSE_WERROR])])
2011-04-12 11:43:11 -07:00
2011-06-22 09:26:31 -07:00
dnl OVS_CHECK_LINUX
2009-07-08 13:19:16 -07:00
dnl
2016-10-18 21:03:45 +01:00
dnl Configure linux kernel source tree
2011-06-22 09:26:31 -07:00
AC_DEFUN([OVS_CHECK_LINUX], [
2011-06-22 11:07:33 -07:00
AC_ARG_WITH([linux],
[AC_HELP_STRING([--with-linux=/path/to/linux],
[Specify the Linux kernel build directory])])
AC_ARG_WITH([linux-source],
[AC_HELP_STRING([--with-linux-source=/path/to/linux-source],
[Specify the Linux kernel source directory
2014-05-09 13:28:49 +09:00
(usually figured out automatically from build
directory)])])
2011-06-22 11:07:33 -07:00
# Deprecated equivalents to --with-linux, --with-linux-source.
AC_ARG_WITH([l26])
AC_ARG_WITH([l26-source])
if test X"$with_linux" != X; then
KBUILD=$with_linux
elif test X"$with_l26" != X; then
KBUILD=$with_l26
AC_MSG_WARN([--with-l26 is deprecated, please use --with-linux instead])
else
KBUILD=
fi
if test X"$KBUILD" != X; then
if test X"$with_linux_source" != X; then
KSRC=$with_linux_source
elif test X"$with_l26_source" != X; then
KSRC=$with_l26_source
AC_MSG_WARN([--with-l26-source is deprecated, please use --with-linux-source instead])
2011-06-22 15:09:35 -07:00
else
KSRC=
2011-06-22 11:07:33 -07:00
fi
elif test X"$with_linux_source" != X || test X"$with_l26_source" != X; then
AC_MSG_ERROR([Linux source directory may not be specified without Linux build directory])
fi
2011-06-22 09:26:31 -07:00
if test -n "$KBUILD"; then
KBUILD=`eval echo "$KBUILD"`
case $KBUILD in
2010-04-13 15:08:37 -07:00
/*) ;;
2011-06-22 09:26:31 -07:00
*) KBUILD=`pwd`/$KBUILD ;;
2010-04-13 15:08:37 -07:00
esac
2009-07-08 13:19:16 -07:00
datapath: Fix build with kernel header layout recently adopted by Debian.
Recent Debian kernel-header packages divide kernel headers into two
directories: the "common" headers that are not architecture-specific,
which go in a directory named like
/usr/src/kernel-headers-2.6.31-1-common,
and architecture-specific headers in a directory named, e.g.
/usr/src/kernel-headers-2.6.31-1-686.
OVS needs to look at the ones in the "common" directory as part of its
configuration process, but the build directory provided on --with-l26 is
the architecture-specific directory. We also need the
architecture-specific directory, since it is the one that we use as part
of the "make", so we can't simply make the user specify the common
directory on --with-l26. Furthermore, there is no easy-to-see link
between the two directories, except as part of the text in a Makefile,
which is not the easiest language to parse.
This commit attempts to kluge around the problem by using the Debian
directory naming. If the build directory does not contain the headers,
then we replace the last component of its name by "-common" and check
for the headers there. This is not ideal, but it does solve the actual
problem at hand.
Tested with Debian's linux-headers-2.6.31-1-686 and with a few older
sets of headers that do not use this scheme.
2009-11-18 11:05:00 -08:00
# The build directory is what the user provided.
# Make sure that it exists.
2011-06-22 11:07:33 -07:00
AC_MSG_CHECKING([for Linux build directory])
2011-06-22 09:26:31 -07:00
if test -d "$KBUILD"; then
2014-05-09 13:28:49 +09:00
AC_MSG_RESULT([$KBUILD])
AC_SUBST(KBUILD)
2009-07-08 13:19:16 -07:00
else
2014-05-09 13:28:49 +09:00
AC_MSG_RESULT([no])
AC_ERROR([source dir $KBUILD doesn't exist])
2009-07-08 13:19:16 -07:00
fi
datapath: Fix build with kernel header layout recently adopted by Debian.
Recent Debian kernel-header packages divide kernel headers into two
directories: the "common" headers that are not architecture-specific,
which go in a directory named like
/usr/src/kernel-headers-2.6.31-1-common,
and architecture-specific headers in a directory named, e.g.
/usr/src/kernel-headers-2.6.31-1-686.
OVS needs to look at the ones in the "common" directory as part of its
configuration process, but the build directory provided on --with-l26 is
the architecture-specific directory. We also need the
architecture-specific directory, since it is the one that we use as part
of the "make", so we can't simply make the user specify the common
directory on --with-l26. Furthermore, there is no easy-to-see link
between the two directories, except as part of the text in a Makefile,
which is not the easiest language to parse.
This commit attempts to kluge around the problem by using the Debian
directory naming. If the build directory does not contain the headers,
then we replace the last component of its name by "-common" and check
for the headers there. This is not ideal, but it does solve the actual
problem at hand.
Tested with Debian's linux-headers-2.6.31-1-686 and with a few older
sets of headers that do not use this scheme.
2009-11-18 11:05:00 -08:00
# Debian breaks kernel headers into "source" header and "build" headers.
2011-06-22 09:26:31 -07:00
# We want the source headers, but $KBUILD gives us the "build" headers.
datapath: Fix build with kernel header layout recently adopted by Debian.
Recent Debian kernel-header packages divide kernel headers into two
directories: the "common" headers that are not architecture-specific,
which go in a directory named like
/usr/src/kernel-headers-2.6.31-1-common,
and architecture-specific headers in a directory named, e.g.
/usr/src/kernel-headers-2.6.31-1-686.
OVS needs to look at the ones in the "common" directory as part of its
configuration process, but the build directory provided on --with-l26 is
the architecture-specific directory. We also need the
architecture-specific directory, since it is the one that we use as part
of the "make", so we can't simply make the user specify the common
directory on --with-l26. Furthermore, there is no easy-to-see link
between the two directories, except as part of the text in a Makefile,
which is not the easiest language to parse.
This commit attempts to kluge around the problem by using the Debian
directory naming. If the build directory does not contain the headers,
then we replace the last component of its name by "-common" and check
for the headers there. This is not ideal, but it does solve the actual
problem at hand.
Tested with Debian's linux-headers-2.6.31-1-686 and with a few older
sets of headers that do not use this scheme.
2009-11-18 11:05:00 -08:00
# Use heuristics to find the source headers.
2011-06-22 11:07:33 -07:00
AC_MSG_CHECKING([for Linux source directory])
2011-06-22 09:26:31 -07:00
if test -n "$KSRC"; then
KSRC=`eval echo "$KSRC"`
case $KSRC in
2010-07-02 10:10:04 -07:00
/*) ;;
2011-06-22 09:26:31 -07:00
*) KSRC=`pwd`/$KSRC ;;
2010-01-08 13:09:10 -08:00
esac
2011-06-22 09:26:31 -07:00
if test ! -e $KSRC/include/linux/kernel.h; then
2011-06-22 15:09:50 -07:00
AC_MSG_ERROR([$KSRC is not a kernel source directory])
2010-07-02 10:10:04 -07:00
fi
else
2011-06-22 09:26:31 -07:00
KSRC=$KBUILD
if test ! -e $KSRC/include/linux/kernel.h; then
2012-02-16 10:34:55 -08:00
# Debian kernel build Makefiles tend to include a line of the form:
# MAKEARGS := -C /usr/src/linux-headers-3.2.0-1-common O=/usr/src/linux-headers-3.2.0-1-486
# First try to extract the source directory from this line.
KSRC=`sed -n 's/.*-C \([[^ ]]*\).*/\1/p' "$KBUILD"/Makefile`
if test ! -e "$KSRC"/include/linux/kernel.h; then
# Didn't work. Fall back to name-based heuristics that used to work.
case `echo "$KBUILD" | sed 's,/*$,,'` in # (
*/build)
KSRC=`echo "$KBUILD" | sed 's,/build/*$,/source,'`
;; # (
*)
KSRC=`(cd $KBUILD && pwd -P) | sed 's,-[[^-]]*$,-common,'`
;;
esac
fi
2010-07-02 10:10:04 -07:00
fi
2012-02-16 10:34:55 -08:00
if test ! -e "$KSRC"/include/linux/kernel.h; then
2011-06-22 11:07:33 -07:00
AC_MSG_ERROR([cannot find source directory (please use --with-linux-source)])
datapath: Fix build with kernel header layout recently adopted by Debian.
Recent Debian kernel-header packages divide kernel headers into two
directories: the "common" headers that are not architecture-specific,
which go in a directory named like
/usr/src/kernel-headers-2.6.31-1-common,
and architecture-specific headers in a directory named, e.g.
/usr/src/kernel-headers-2.6.31-1-686.
OVS needs to look at the ones in the "common" directory as part of its
configuration process, but the build directory provided on --with-l26 is
the architecture-specific directory. We also need the
architecture-specific directory, since it is the one that we use as part
of the "make", so we can't simply make the user specify the common
directory on --with-l26. Furthermore, there is no easy-to-see link
between the two directories, except as part of the text in a Makefile,
which is not the easiest language to parse.
This commit attempts to kluge around the problem by using the Debian
directory naming. If the build directory does not contain the headers,
then we replace the last component of its name by "-common" and check
for the headers there. This is not ideal, but it does solve the actual
problem at hand.
Tested with Debian's linux-headers-2.6.31-1-686 and with a few older
sets of headers that do not use this scheme.
2009-11-18 11:05:00 -08:00
fi
fi
2011-06-22 09:26:31 -07:00
AC_MSG_RESULT([$KSRC])
datapath: Fix build with kernel header layout recently adopted by Debian.
Recent Debian kernel-header packages divide kernel headers into two
directories: the "common" headers that are not architecture-specific,
which go in a directory named like
/usr/src/kernel-headers-2.6.31-1-common,
and architecture-specific headers in a directory named, e.g.
/usr/src/kernel-headers-2.6.31-1-686.
OVS needs to look at the ones in the "common" directory as part of its
configuration process, but the build directory provided on --with-l26 is
the architecture-specific directory. We also need the
architecture-specific directory, since it is the one that we use as part
of the "make", so we can't simply make the user specify the common
directory on --with-l26. Furthermore, there is no easy-to-see link
between the two directories, except as part of the text in a Makefile,
which is not the easiest language to parse.
This commit attempts to kluge around the problem by using the Debian
directory naming. If the build directory does not contain the headers,
then we replace the last component of its name by "-common" and check
for the headers there. This is not ideal, but it does solve the actual
problem at hand.
Tested with Debian's linux-headers-2.6.31-1-686 and with a few older
sets of headers that do not use this scheme.
2009-11-18 11:05:00 -08:00
AC_MSG_CHECKING([for kernel version])
2011-06-22 10:15:23 -07:00
version=`sed -n 's/^VERSION = //p' "$KSRC/Makefile"`
2011-06-22 09:26:31 -07:00
patchlevel=`sed -n 's/^PATCHLEVEL = //p' "$KSRC/Makefile"`
sublevel=`sed -n 's/^SUBLEVEL = //p' "$KSRC/Makefile"`
2011-06-22 10:15:23 -07:00
if test X"$version" = X || test X"$patchlevel" = X; then
datapath: Fix build with kernel header layout recently adopted by Debian.
Recent Debian kernel-header packages divide kernel headers into two
directories: the "common" headers that are not architecture-specific,
which go in a directory named like
/usr/src/kernel-headers-2.6.31-1-common,
and architecture-specific headers in a directory named, e.g.
/usr/src/kernel-headers-2.6.31-1-686.
OVS needs to look at the ones in the "common" directory as part of its
configuration process, but the build directory provided on --with-l26 is
the architecture-specific directory. We also need the
architecture-specific directory, since it is the one that we use as part
of the "make", so we can't simply make the user specify the common
directory on --with-l26. Furthermore, there is no easy-to-see link
between the two directories, except as part of the text in a Makefile,
which is not the easiest language to parse.
This commit attempts to kluge around the problem by using the Debian
directory naming. If the build directory does not contain the headers,
then we replace the last component of its name by "-common" and check
for the headers there. This is not ideal, but it does solve the actual
problem at hand.
Tested with Debian's linux-headers-2.6.31-1-686 and with a few older
sets of headers that do not use this scheme.
2009-11-18 11:05:00 -08:00
AC_ERROR([cannot determine kernel version])
2011-06-22 10:15:23 -07:00
elif test X"$sublevel" = X; then
kversion=$version.$patchlevel
else
kversion=$version.$patchlevel.$sublevel
datapath: Fix build with kernel header layout recently adopted by Debian.
Recent Debian kernel-header packages divide kernel headers into two
directories: the "common" headers that are not architecture-specific,
which go in a directory named like
/usr/src/kernel-headers-2.6.31-1-common,
and architecture-specific headers in a directory named, e.g.
/usr/src/kernel-headers-2.6.31-1-686.
OVS needs to look at the ones in the "common" directory as part of its
configuration process, but the build directory provided on --with-l26 is
the architecture-specific directory. We also need the
architecture-specific directory, since it is the one that we use as part
of the "make", so we can't simply make the user specify the common
directory on --with-l26. Furthermore, there is no easy-to-see link
between the two directories, except as part of the text in a Makefile,
which is not the easiest language to parse.
This commit attempts to kluge around the problem by using the Debian
directory naming. If the build directory does not contain the headers,
then we replace the last component of its name by "-common" and check
for the headers there. This is not ideal, but it does solve the actual
problem at hand.
Tested with Debian's linux-headers-2.6.31-1-686 and with a few older
sets of headers that do not use this scheme.
2009-11-18 11:05:00 -08:00
fi
2011-06-22 10:15:23 -07:00
AC_MSG_RESULT([$kversion])
2015-04-09 18:40:51 -07:00
if test "$version" -ge 4; then
2018-08-21 07:42:08 -07:00
if test "$version" = 4 && test "$patchlevel" -le 17; then
2015-04-09 18:40:51 -07:00
: # Linux 4.x
2013-09-03 11:02:40 -07:00
else
2018-08-21 07:42:08 -07:00
AC_ERROR([Linux kernel in $KBUILD is version $kversion, but version newer than 4.17.x is not supported (please refer to the FAQ for advice)])
2013-09-03 11:02:40 -07:00
fi
2016-02-29 09:54:15 -08:00
elif test "$version" = 3 && test "$patchlevel" -ge 10; then
2015-04-09 18:40:51 -07:00
: # Linux 3.x
2011-06-22 10:15:23 -07:00
else
2016-02-29 09:54:15 -08:00
AC_ERROR([Linux kernel in $KBUILD is version $kversion, but version 3.10 or later is required])
2009-07-08 13:19:16 -07:00
fi
2012-12-07 12:37:02 +09:00
if (test ! -e "$KBUILD"/include/linux/version.h && \
test ! -e "$KBUILD"/include/generated/uapi/linux/version.h)|| \
2011-06-22 09:26:31 -07:00
(test ! -e "$KBUILD"/include/linux/autoconf.h && \
test ! -e "$KBUILD"/include/generated/autoconf.h); then
2014-05-09 13:28:49 +09:00
AC_MSG_ERROR([Linux kernel source in $KBUILD is not configured])
2009-07-08 13:19:16 -07:00
fi
2011-06-22 09:26:31 -07:00
OVS_CHECK_LINUX_COMPAT
2009-07-08 13:19:16 -07:00
fi
2011-06-22 09:26:31 -07:00
AM_CONDITIONAL(LINUX_ENABLED, test -n "$KBUILD")
2009-07-08 13:19:16 -07:00
])
2017-05-28 14:59:45 +03:00
dnl OVS_CHECK_LINUX_TC
dnl
dnl Configure Linux tc compat.
AC_DEFUN([OVS_CHECK_LINUX_TC], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([#include <linux/pkt_cls.h>], [
2018-07-31 13:40:39 +03:00
int x = TCA_FLOWER_KEY_ENC_IP_TTL_MASK;
2017-05-28 14:59:45 +03:00
])],
2018-07-31 13:40:39 +03:00
[AC_DEFINE([HAVE_TCA_FLOWER_KEY_ENC_IP_TTL_MASK], [1],
[Define to 1 if TCA_FLOWER_KEY_ENC_IP_TTL_MASK is available.])])
2017-05-28 14:59:45 +03:00
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([#include <linux/tc_act/tc_vlan.h>], [
int x = TCA_VLAN_PUSH_VLAN_PRIORITY;
])],
[AC_DEFINE([HAVE_TCA_VLAN_PUSH_VLAN_PRIORITY], [1],
2018-07-31 13:40:39 +03:00
[Define to 1 if TCA_VLAN_PUSH_VLAN_PRIORITY is available.])])
2017-05-28 14:59:45 +03:00
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([#include <linux/tc_act/tc_tunnel_key.h>], [
2018-07-31 13:40:38 +03:00
int x = TCA_TUNNEL_KEY_ENC_TTL;
2017-05-28 14:59:45 +03:00
])],
2018-07-31 13:40:38 +03:00
[AC_DEFINE([HAVE_TCA_TUNNEL_KEY_ENC_TTL], [1],
[Define to 1 if TCA_TUNNEL_KEY_ENC_TTL is available.])])
2017-09-18 07:16:01 +03:00
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([#include <linux/tc_act/tc_pedit.h>], [
int x = TCA_PEDIT_KEY_EX_HDR_TYPE_UDP;
])],
[AC_DEFINE([HAVE_TCA_PEDIT_KEY_EX_HDR_TYPE_UDP], [1],
2018-07-31 13:40:39 +03:00
[Define to 1 if TCA_PEDIT_KEY_EX_HDR_TYPE_UDP is available.])])
2017-05-28 14:59:45 +03:00
])
2014-03-24 19:23:08 -07:00
dnl OVS_CHECK_DPDK
dnl
dnl Configure DPDK source tree
AC_DEFUN([OVS_CHECK_DPDK], [
AC_ARG_WITH([dpdk],
[AC_HELP_STRING([--with-dpdk=/path/to/dpdk],
2016-06-01 18:48:07 +02:00
[Specify the DPDK build directory])],
[have_dpdk=true])
2014-03-24 19:23:08 -07:00
2016-04-12 11:44:15 +01:00
AC_MSG_CHECKING([whether dpdk datapath is enabled])
2016-06-01 18:48:07 +02:00
if test "$have_dpdk" != true || test "$with_dpdk" = no; then
2016-04-12 11:44:15 +01:00
AC_MSG_RESULT([no])
DPDKLIB_FOUND=false
else
AC_MSG_RESULT([yes])
case "$with_dpdk" in
yes)
DPDK_AUTO_DISCOVER="true"
2017-07-14 08:36:39 +02:00
PKG_CHECK_MODULES([DPDK], [libdpdk],
[DPDK_INCLUDE="$DPDK_CFLAGS"],
[DPDK_INCLUDE="-I/usr/local/include/dpdk -I/usr/include/dpdk"])
2016-04-12 11:44:15 +01:00
;;
*)
DPDK_AUTO_DISCOVER="false"
2017-07-14 08:36:39 +02:00
DPDK_INCLUDE_PATH="$with_dpdk/include"
2016-04-12 11:44:15 +01:00
# If 'with_dpdk' is passed install directory, point to headers
# installed in $DESTDIR/$prefix/include/dpdk
2017-07-14 08:36:39 +02:00
if test -e "$DPDK_INCLUDE_PATH/rte_config.h"; then
DPDK_INCLUDE="-I$DPDK_INCLUDE_PATH"
elif test -e "$DPDK_INCLUDE_PATH/dpdk/rte_config.h"; then
DPDK_INCLUDE="-I$DPDK_INCLUDE_PATH/dpdk"
2017-07-07 09:16:27 -07:00
fi
2016-04-12 11:44:15 +01:00
DPDK_LIB_DIR="$with_dpdk/lib"
;;
esac
2014-03-24 19:23:08 -07:00
2015-09-04 13:35:57 +01:00
DPDK_LIB="-ldpdk"
2015-06-25 07:46:55 -07:00
DPDK_EXTRA_LIB=""
2014-03-24 19:23:08 -07:00
2014-09-11 21:34:21 +02:00
ovs_save_CFLAGS="$CFLAGS"
ovs_save_LDFLAGS="$LDFLAGS"
2017-07-14 08:36:39 +02:00
CFLAGS="$CFLAGS $DPDK_INCLUDE"
2016-04-12 11:44:15 +01:00
if test "$DPDK_AUTO_DISCOVER" = "false"; then
LDFLAGS="$LDFLAGS -L${DPDK_LIB_DIR}"
fi
2016-08-04 11:44:40 +01:00
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(
[
#include <rte_config.h>
#if RTE_LIBRTE_VHOST_NUMA
#error
#endif
], [])
], [],
[AC_SEARCH_LIBS([get_mempolicy],[numa],[],[AC_MSG_ERROR([unable to find libnuma, install the dependency package])])
2016-08-17 13:17:03 +01:00
DPDK_EXTRA_LIB="-lnuma"
AC_DEFINE([VHOST_NUMA], [1], [NUMA Aware vHost support detected in DPDK.])])
2016-06-18 23:13:44 +01:00
2016-08-10 15:28:27 +01:00
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(
[
#include <rte_config.h>
#if RTE_LIBRTE_PMD_PCAP
#error
#endif
], [])
], [],
[AC_SEARCH_LIBS([pcap_dump],[pcap],[],[AC_MSG_ERROR([unable to find libpcap, install the dependency package])])
DPDK_EXTRA_LIB="-lpcap"
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM(
[
#include <rte_config.h>
#if RTE_LIBRTE_PDUMP
#error
#endif
], [])
], [],
[AC_DEFINE([DPDK_PDUMP], [1], [DPDK pdump enabled in OVS.])])
])
2014-06-03 11:29:53 -07:00
# On some systems we have to add -ldl to link with dpdk
#
# This code, at first, tries to link without -ldl (""),
# then adds it and tries again.
# Before each attempt the search cache must be unset,
# otherwise autoconf will stick with the old result
2016-04-12 11:44:15 +01:00
DPDKLIB_FOUND=false
2014-06-03 11:29:53 -07:00
save_LIBS=$LIBS
for extras in "" "-ldl"; do
2016-08-04 11:44:40 +01:00
LIBS="$DPDK_LIB $extras $save_LIBS $DPDK_EXTRA_LIB"
2014-06-03 11:29:53 -07:00
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([#include <rte_config.h>
#include <rte_eal.h>],
[int rte_argc; char ** rte_argv;
rte_eal_init(rte_argc, rte_argv);])],
2016-04-12 11:44:15 +01:00
[DPDKLIB_FOUND=true])
if $DPDKLIB_FOUND; then
2014-06-03 11:29:53 -07:00
break
fi
done
2016-04-12 11:44:15 +01:00
# If linking unsuccessful
if test "$DPDKLIB_FOUND" = "false" ; then
if $DPDK_AUTO_DISCOVER; then
AC_MSG_ERROR([Could not find DPDK library in default search path, Use --with-dpdk to specify the DPDK library installed in non-standard location])
else
AC_MSG_ERROR([Could not find DPDK libraries in $DPDK_LIB_DIR])
fi
2014-06-03 11:29:53 -07:00
fi
2014-09-11 21:34:21 +02:00
CFLAGS="$ovs_save_CFLAGS"
LDFLAGS="$ovs_save_LDFLAGS"
2016-04-12 11:44:15 +01:00
if test "$DPDK_AUTO_DISCOVER" = "false"; then
OVS_LDFLAGS="$OVS_LDFLAGS -L$DPDK_LIB_DIR"
fi
2017-07-14 08:36:39 +02:00
OVS_CFLAGS="$OVS_CFLAGS $DPDK_INCLUDE"
2016-01-12 14:15:39 +03:00
OVS_ENABLE_OPTION([-mssse3])
2014-03-24 19:23:08 -07:00
2015-03-20 06:02:13 -07:00
# DPDK pmd drivers are not linked unless --whole-archive is used.
2014-08-12 10:43:35 -07:00
#
# This happens because the rest of the DPDK code doesn't use any symbol in
# the pmd driver objects, and the drivers register themselves using an
# __attribute__((constructor)) function.
#
# These options are specified inside a single -Wl directive to prevent
# autotools from reordering them.
2015-03-20 06:02:13 -07:00
DPDK_vswitchd_LDFLAGS=-Wl,--whole-archive,$DPDK_LIB,--no-whole-archive
2014-08-19 01:23:55 +00:00
AC_SUBST([DPDK_vswitchd_LDFLAGS])
2014-03-24 19:23:08 -07:00
AC_DEFINE([DPDK_NETDEV], [1], [System uses the DPDK module.])
fi
2016-04-12 11:44:15 +01:00
AM_CONDITIONAL([DPDK_NETDEV], test "$DPDKLIB_FOUND" = true)
2014-03-24 19:23:08 -07:00
])
2010-09-08 16:46:43 -07:00
dnl OVS_GREP_IFELSE(FILE, REGEX, [IF-MATCH], [IF-NO-MATCH])
2009-07-08 13:19:16 -07:00
dnl
dnl Greps FILE for REGEX. If it matches, runs IF-MATCH, otherwise IF-NO-MATCH.
2010-09-08 16:46:43 -07:00
dnl If IF-MATCH is empty then it defines to OVS_DEFINE(HAVE_<REGEX>), with
dnl <REGEX> translated to uppercase.
2009-07-08 13:19:16 -07:00
AC_DEFUN([OVS_GREP_IFELSE], [
AC_MSG_CHECKING([whether $2 matches in $1])
2010-11-02 16:00:16 -07:00
if test -f $1; then
grep '$2' $1 >/dev/null 2>&1
status=$?
case $status in
2016-10-18 21:03:45 +01:00
0)
2010-11-02 16:00:16 -07:00
AC_MSG_RESULT([yes])
2010-09-08 16:46:43 -07:00
m4_if([$3], [], [OVS_DEFINE([HAVE_]m4_toupper([$2]))], [$3])
2010-11-02 16:00:16 -07:00
;;
2016-10-18 21:03:45 +01:00
1)
2010-11-02 16:00:16 -07:00
AC_MSG_RESULT([no])
$4
;;
2016-10-18 21:03:45 +01:00
*)
2010-11-02 16:00:16 -07:00
AC_MSG_ERROR([grep exited with status $status])
;;
esac
else
AC_MSG_RESULT([file not found])
$4
fi
2009-07-08 13:19:16 -07:00
])
2015-03-24 16:16:18 -07:00
dnl OVS_FIND_FIELD_IFELSE(FILE, STRUCTURE, REGEX, [IF-MATCH], [IF-NO-MATCH])
dnl
dnl Looks for STRUCTURE in FILE. If it is found, greps for REGEX within the
dnl structure definition. If this is successful, runs IF-MATCH, otherwise
dnl IF_NO_MATCH. If IF-MATCH is empty then it defines to
dnl OVS_DEFINE(HAVE_<STRUCTURE>_WITH_<REGEX>), with <STRUCTURE> and <REGEX>
dnl translated to uppercase.
AC_DEFUN([OVS_FIND_FIELD_IFELSE], [
AC_MSG_CHECKING([whether $2 has member $3 in $1])
if test -f $1; then
2015-07-16 16:34:03 -07:00
awk '/$2.{/,/^}/' $1 2>/dev/null | grep '$3' >/dev/null
2015-03-24 16:16:18 -07:00
status=$?
case $status in
0)
AC_MSG_RESULT([yes])
m4_if([$4], [], [OVS_DEFINE([HAVE_]m4_toupper([$2])[_WITH_]m4_toupper([$3]))], [$4])
;;
1)
AC_MSG_RESULT([no])
$5
;;
*)
AC_MSG_ERROR([grep exited with status $status])
;;
esac
else
AC_MSG_RESULT([file not found])
$5
fi
])
2016-06-20 18:51:06 -07:00
dnl OVS_FIND_PARAM_IFELSE(FILE, FUNCTION, REGEX, [IF-MATCH], [IF-NO-MATCH])
dnl
dnl Looks for FUNCTION in FILE. If it is found, greps for REGEX within
dnl the function signature starting from the line matching FUNCTION
dnl and ending with the line containing the closing parenthesis. If
dnl this is successful, runs IF-MATCH, otherwise IF_NO_MATCH. If
dnl IF-MATCH is empty then it defines to
dnl OVS_DEFINE(HAVE_<FUNCTION>_WITH_<REGEX>), with <FUNCTION> and
dnl <REGEX> translated to uppercase.
AC_DEFUN([OVS_FIND_PARAM_IFELSE], [
AC_MSG_CHECKING([whether $2 has parameter $3 in $1])
if test -f $1; then
awk '/$2[[ \t\n]]*\(/,/\)/' $1 2>/dev/null | grep '$3' >/dev/null
status=$?
case $status in
0)
AC_MSG_RESULT([yes])
m4_if([$4], [], [OVS_DEFINE([HAVE_]m4_toupper([$2])[_WITH_]m4_toupper([$3]))], [$4])
;;
1)
AC_MSG_RESULT([no])
$5
;;
*)
AC_MSG_ERROR([grep exited with status $status])
;;
esac
else
AC_MSG_RESULT([file not found])
$5
fi
])
2009-07-08 13:19:16 -07:00
dnl OVS_DEFINE(NAME)
dnl
dnl Defines NAME to 1 in kcompat.h.
AC_DEFUN([OVS_DEFINE], [
2011-06-23 17:10:00 -07:00
echo '#define $1 1' >> datapath/linux/kcompat.h.new
2009-07-08 13:19:16 -07:00
])
2011-06-22 09:26:31 -07:00
dnl OVS_CHECK_LINUX_COMPAT
2009-07-08 13:19:16 -07:00
dnl
2016-02-29 09:54:15 -08:00
dnl Runs various Autoconf checks on the Linux kernel source in
2011-06-22 09:26:31 -07:00
dnl the directory in $KBUILD.
AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
2011-06-23 17:10:00 -07:00
rm -f datapath/linux/kcompat.h.new
mkdir -p datapath/linux
: > datapath/linux/kcompat.h.new
2010-05-14 15:39:48 -07:00
2015-12-03 11:40:53 -08:00
echo '#include <linux/version.h>
#ifndef RHEL_RELEASE_CODE
#define RHEL_RELEASE_CODE 0
#define RHEL_RELEASE_VERSION(a, b) 0
#endif' >> datapath/linux/kcompat.h.new
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/arch/x86/include/asm/checksum_32.h], [src_err,],
2010-11-02 15:43:32 -07:00
[OVS_DEFINE([HAVE_CSUM_COPY_DBG])])
2015-12-03 11:40:53 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/addrconf.h], [ipv6_dst_lookup.*net],
[OVS_DEFINE([HAVE_IPV6_DST_LOOKUP_NET])])
OVS_GREP_IFELSE([$KSRC/include/net/addrconf.h], [ipv6_stub])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/err.h], [ERR_CAST])
2014-09-12 16:03:34 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/err.h], [IS_ERR_OR_NULL])
2016-07-17 09:52:11 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/err.h], [PTR_ERR_OR_ZERO])
2010-05-14 15:39:48 -07:00
2018-08-17 02:05:04 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/jump_label.h], [DEFINE_STATIC_KEY_FALSE],
[OVS_DEFINE([HAVE_UPSTREAM_STATIC_KEY])])
2013-03-12 11:34:29 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/etherdevice.h], [eth_hw_addr_random])
2014-05-01 15:50:48 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/etherdevice.h], [ether_addr_copy])
2013-03-12 11:34:29 -07:00
2015-12-03 11:40:53 -08:00
OVS_GREP_IFELSE([$KSRC/include/uapi/linux/if_link.h], [IFLA_GENEVE_TOS])
OVS_GREP_IFELSE([$KSRC/include/uapi/linux/if_link.h], [rtnl_link_stats64])
OVS_GREP_IFELSE([$KSRC/include/linux/if_link.h], [rtnl_link_stats64])
2013-03-12 11:34:29 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/if_vlan.h], [vlan_set_encap_proto])
2015-09-18 15:23:21 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/if_vlan.h], [vlan_hwaccel_push_inside])
2013-03-12 11:34:29 -07:00
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/in.h], [ipv4_is_multicast])
2015-08-28 10:37:09 -03:00
OVS_GREP_IFELSE([$KSRC/include/linux/in.h], [proto_ports_offset])
2013-09-24 18:42:43 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/ip.h], [__ip_select_ident.*dst_entry],
[OVS_DEFINE([HAVE_IP_SELECT_IDENT_USING_DST_ENTRY])])
2015-12-03 11:40:53 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/ip.h], [__ip_select_ident.*net],
[OVS_DEFINE([HAVE_IP_SELECT_IDENT_USING_NET])])
2015-03-24 16:16:18 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/ip.h], [inet_get_local_port_range.*net],
[OVS_DEFINE([HAVE_INET_GET_LOCAL_PORT_RANGE_USING_NET])])
2016-05-02 11:19:11 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/ip.h], [ip_defrag.*net],
[OVS_DEFINE([HAVE_IP_DEFRAG_TAKES_NET])])
2016-06-22 18:00:42 -07:00
OVS_FIND_PARAM_IFELSE([$KSRC/include/net/ip.h],
[ip_do_fragment], [net],
[OVS_DEFINE([HAVE_IP_DO_FRAGMENT_TAKES_NET])])
2016-07-18 15:13:15 -07:00
OVS_FIND_PARAM_IFELSE([$KSRC/include/net/ip.h],
[ip_local_out], [net],
[OVS_DEFINE([HAVE_IP_LOCAL_OUT_TAKES_NET])])
2015-12-02 23:53:43 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/ip.h], [ip_skb_dst_mtu])
2016-02-02 15:19:02 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/ip.h], [IPSKB_FRAG_PMTU],
[OVS_DEFINE([HAVE_CORRECT_MRU_HANDLING])])
datapath: Set a large MTU on tunnel devices.
Upstream commit:
Prior to 4.3, openvswitch tunnel vports (vxlan, gre and geneve) could
transmit vxlan packets of any size, constrained only by the ability to
send out the resulting packets. 4.3 introduced netdevs corresponding
to tunnel vports. These netdevs have an MTU, which limits the size of
a packet that can be successfully encapsulated. The default MTU
values are low (1500 or less), which is awkwardly small in the context
of physical networks supporting jumbo frames, and leads to a
conspicuous change in behaviour for userspace.
Instead, set the MTU on openvswitch-created netdevs to be the relevant
maximum (i.e. the maximum IP packet size minus any relevant overhead),
effectively restoring the behaviour prior to 4.3.
Signed-off-by: David Wragg <david@weave.works>
Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream: 7e059158d57b ("vxlan, gre, geneve: Set a large MTU on ovs-created
tunnel devices")
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Jesse Gross <jesse@kernel.org>
2016-02-10 00:05:58 +00:00
OVS_GREP_IFELSE([$KSRC/include/net/ip_tunnels.h], [__ip_tunnel_change_mtu])
2015-12-02 23:53:45 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/inet_frag.h], [hashfn.*const],
[OVS_DEFINE([HAVE_INET_FRAGS_CONST])])
2015-12-24 10:40:02 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/inet_frag.h], [last_in],
[OVS_DEFINE([HAVE_INET_FRAGS_LAST_IN])])
2015-12-24 10:41:35 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/inet_frag.h], [inet_frag_evicting])
2016-07-12 15:26:19 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/inet_frag.h], [inet_frag_evictor])
2015-12-24 10:54:37 -08:00
OVS_FIND_FIELD_IFELSE([$KSRC/include/net/inet_frag.h], [inet_frags],
[frags_work])
2015-12-24 11:06:18 -08:00
OVS_FIND_FIELD_IFELSE([$KSRC/include/net/inet_frag.h], [inet_frags],
[rwlock])
2015-12-24 10:41:35 -08:00
OVS_FIND_FIELD_IFELSE([$KSRC/include/net/inet_frag.h], [inet_frag_queue],
[list_evictor])
2016-08-01 13:58:38 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/inet_frag.h], [inet_frag_lru_move])
2016-12-08 18:34:05 -08:00
OVS_FIND_PARAM_IFELSE([$KSRC/include/net/inet_frag.h],
[sub_frag_mem_limit], [struct.netns_frags],
[OVS_DEFINE([HAVE_SUB_FRAG_MEM_LIMIT_ARG_STRUCT_NETNS_FRAGS])])
OVS_GREP_IFELSE([$KSRC/include/net/inet_frag.h], [void.*inet_frags_init],
[OVS_DEFINE([HAVE_VOID_INET_FRAGS_INIT])])
2016-01-07 17:58:59 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/inetpeer.h], [vif],
[OVS_DEFINE([HAVE_INETPEER_VIF_SUPPORT])])
2015-12-24 10:40:02 -08:00
2016-07-08 16:24:02 -07:00
dnl Check for dst_cache and ipv6 lable to use backported tunnel infrastructure.
dnl OVS does not really need ipv6 label field, but its presence signifies that
dnl the stack has all required ipv6 support.
dnl OVS also does not need dst_cache But this dependency allows us to write
dnl much cleaner code.
2016-07-07 21:49:10 -07:00
OVS_FIND_FIELD_IFELSE([$KSRC/include/net/ip_tunnels.h], [ip_tunnel_key],
[label],
[OVS_GREP_IFELSE([$KSRC/include/net/ip_tunnels.h],
[iptunnel_pull_offloads],
2016-10-18 21:03:45 +01:00
[OVS_GREP_IFELSE([$KSRC/include/net/dst_cache.h], [dst_cache],
2018-05-16 13:13:20 -07:00
[OVS_GREP_IFELSE([$KSRC/include/net/erspan.h], [erspan_md2],
[OVS_DEFINE([USE_UPSTREAM_TUNNEL])])])])])
2010-05-14 15:39:48 -07:00
2018-04-20 11:13:07 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/dst_cache.h], [dst_cache],
[OVS_DEFINE([USE_BUILTIN_DST_CACHE])])
2017-05-01 10:24:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/mpls.h], [mpls_hdr],
[OVS_DEFINE([MPLS_HEADER_IS_L3])])
2015-09-18 15:23:32 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/net.h], [sock_create_kern.*net],
[OVS_DEFINE([HAVE_SOCK_CREATE_KERN_NET])])
2016-07-07 19:35:33 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [ndo_fill_metadata_dst])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [dev_disable_lro])
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [dev_get_stats])
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [dev_get_by_index_rcu])
2015-12-02 23:53:42 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [dev_recursion_level])
2013-04-25 14:28:16 +02:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [__skb_gso_segment])
2018-01-31 21:53:06 +08:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [skb_gso_error_unwind])
2013-04-25 14:28:16 +02:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [can_checksum_protocol])
2015-12-03 11:40:53 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [ndo_get_iflink])
2016-08-01 20:12:06 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [ndo_features_check],
[OVS_DEFINE([USE_UPSTREAM_TUNNEL_GSO])])
2016-07-08 16:24:02 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [ndo_add_vxlan_port])
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [ndo_add_geneve_port])
2018-08-04 16:31:36 +08:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [ndo_udp_tunnel_add])
2013-12-17 10:22:40 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [netdev_features_t])
2016-02-29 09:54:15 -08:00
dnl Ubuntu kernel 3.13 has defined this struct but not used for netdev->tstats.
dnl So check type of tstats.
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [pcpu_sw_netstats.*tstats],
[OVS_DEFINE([HAVE_PCPU_SW_NETSTATS])])
2015-12-03 11:40:53 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [netif_needs_gso.*net_device],
[OVS_DEFINE([HAVE_NETIF_NEEDS_GSO_NETDEV])])
2017-07-21 16:46:05 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [skb_csum_hwoffload_help])
2015-12-03 11:40:53 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [udp_offload])
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [udp_offload.*uoff],
[OVS_DEFINE([HAVE_UDP_OFFLOAD_ARG_UOFF])])
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [gro_remcsum])
2016-07-17 09:52:11 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h], [IFF_PHONY_HEADROOM])
2016-12-08 18:34:05 -08:00
OVS_FIND_FIELD_IFELSE([$KSRC/include/linux/netdevice.h], [net_device_ops],
[extended])
2016-07-17 19:24:07 -07:00
OVS_FIND_PARAM_IFELSE([$KSRC/include/linux/netdevice.h],
[netdev_master_upper_dev_link], [upper_priv],
[OVS_DEFINE([HAVE_NETDEV_MASTER_UPPER_DEV_LINK_PRIV])])
2017-08-22 17:52:29 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h],
[netdev_master_upper_dev_link_rh],
[OVS_DEFINE([HAVE_NETDEV_MASTER_UPPER_DEV_LINK_RH])])
datapath: use core MTU range checking in core net infra
Upstream commit:
commit 61e84623ace35ce48975e8f90bbbac7557c43d61
Author: Jarod Wilson <jarod@redhat.com>
Date: Fri Oct 7 22:04:33 2016 -0400
net: centralize net_device min/max MTU checking
While looking into an MTU issue with sfc, I started noticing that almost
every NIC driver with an ndo_change_mtu function implemented almost
exactly the same range checks, and in many cases, that was the only
practical thing their ndo_change_mtu function was doing. Quite a few
drivers have either 68, 64, 60 or 46 as their minimum MTU value checked,
and then various sizes from 1500 to 65535 for their maximum MTU value. We
can remove a whole lot of redundant code here if we simple store min_mtu
and max_mtu in net_device, and check against those in net/core/dev.c's
dev_set_mtu().
In theory, there should be zero functional change with this patch, it just
puts the infrastructure in place. Subsequent patches will attempt to start
using said infrastructure, with theoretically zero change in
functionality.
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream commit:
commit 91572088e3fdbf4fe31cf397926d8b890fdb3237
Author: Jarod Wilson <jarod@redhat.com>
Date: Thu Oct 20 13:55:20 2016 -0400
net: use core MTU range checking in core net infra
...
openvswitch:
- set min/max_mtu, remove internal_dev_change_mtu
- note: max_mtu wasn't checked previously, it's been set to 65535, which
is the largest possible size supported
...
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Upstream commit:
commit 425df17ce3a26d98f76e2b6b0af2acf4aeb0b026
Author: Jarno Rajahalme <jarno@ovn.org>
Date: Tue Feb 14 21:16:28 2017 -0800
openvswitch: Set internal device max mtu to ETH_MAX_MTU.
Commit 91572088e3fd ("net: use core MTU range checking in core net
infra") changed the openvswitch internal device to use the core net
infra for controlling the MTU range, but failed to actually set the
max_mtu as described in the commit message, which now defaults to
ETH_DATA_LEN.
This patch fixes this by setting max_mtu to ETH_MAX_MTU after
ether_setup() call.
Fixes: 91572088e3fd ("net: use core MTU range checking in core net infra")
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
This backport detects the new max_mtu field in the struct netdevice
and uses the upstream code if it exists, and local backport code if
not. The latter case is amended with bounds checks with new upstream
macros ETH_MIN_MTU and ETH_MAX_MTU and the corresponding error
messages from the upstream commit.
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Signed-off-by: Joe Stringer <joe@ovn.org>
2017-02-15 17:34:19 -08:00
OVS_FIND_FIELD_IFELSE([$KSRC/include/linux/netdevice.h], [net_device],
[max_mtu])
2018-05-11 10:32:12 -07:00
OVS_FIND_FIELD_IFELSE([$KSRC/include/linux/netdevice.h], [net_device_ops_extended],
[ndo_change_mtu], [OVS_DEFINE([HAVE_RHEL7_MAX_MTU])])
2015-12-03 11:40:53 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/netfilter.h], [nf_hook_state])
OVS_GREP_IFELSE([$KSRC/include/linux/netfilter.h], [nf_register_net_hook])
2015-05-03 11:56:54 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/netfilter.h], [nf_hookfn.*nf_hook_ops],
[OVS_DEFINE([HAVE_NF_HOOKFN_ARG_OPS])])
2016-07-18 15:13:15 -07:00
OVS_FIND_PARAM_IFELSE([$KSRC/include/linux/netfilter.h], [nf_hookfn], [priv],
[OVS_DEFINE([HAVE_NF_HOOKFN_ARG_PRIV])])
OVS_FIND_FIELD_IFELSE([$KSRC/include/linux/netfilter.h], [nf_hook_ops],
[owner], [OVS_DEFINE([HAVE_NF_HOOKS_OPS_OWNER])])
2018-08-17 02:05:02 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/netfilter.h], [NFPROTO_INET])
2016-07-18 15:13:15 -07:00
2015-12-24 11:32:38 -08:00
OVS_FIND_FIELD_IFELSE([$KSRC/include/linux/netfilter_ipv6.h], [nf_ipv6_ops],
2016-03-21 11:39:38 -07:00
[fragment.*sock], [OVS_DEFINE([HAVE_NF_IPV6_OPS_FRAGMENT])])
2014-05-01 15:50:48 -07:00
compat: nf_ct_delete compat.
Upstream commit:
commit f330a7fdbe1611104622faff7e614a246a7d20f0
Author: Florian Westphal <fw@strlen.de>
Date: Thu Aug 25 15:33:31 2016 +0200
netfilter: conntrack: get rid of conntrack timer
With stats enabled this eats 80 bytes on x86_64 per nf_conn entry, as
Eric Dumazet pointed out during netfilter workshop 2016.
Eric also says: "Another reason was the fact that Thomas was about to
change max timer range [..]" (500462a9de657f8, 'timers: Switch to
a non-cascading wheel').
Remove the timer and use a 32bit jiffies value containing timestamp until
entry is valid.
During conntrack lookup, even before doing tuple comparision, check
the timeout value and evict the entry in case it is too old.
The dying bit is used as a synchronization point to avoid races where
multiple cpus try to evict the same entry.
Because lookup is always lockless, we need to bump the refcnt once
when we evict, else we could try to evict already-dead entry that
is being recycled.
This is the standard/expected way when conntrack entries are destroyed.
Followup patches will introduce garbage colliction via work queue
and further places where we can reap obsoleted entries (e.g. during
netlink dumps), this is needed to avoid expired conntracks from hanging
around for too long when lookup rate is low after a busy period.
Signed-off-by: Florian Westphal <fw@strlen.de>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Upstream commit f330a7fdbe16 ("netfilter: conntrack: get rid of
conntrack timer") changes the way nf_ct_delete() is called. Prior to
commit the call pattern was like this:
if (del_timer(&ct->timeout))
nf_ct_delete(ct, ...);
After this change nf_ct_delete() is called directly:
nf_ct_delete(ct, ...);
This patch provides a replacement implementation for nf_ct_delete()
that first calls the del_timer(). This replacement is only used if
the struct nf_conn has member 'timeout' of type 'struct timer_list'.
The following patch introduces the first caller to nf_ct_delete() in
the OVS kernel module.
Linux <3.12 does not have nf_ct_delete() at all, so we inline it if it
does not exist. The inlined code is from 3.11 death_by_timeout(),
which in later versions simply calls nf_ct_delete().
Upstream commit 02982c27ba1e1bd9f9d4747214e19ca83aa88d0e introduced
nf_ct_delete() in Linux 3.12. This commit has the original code that
is being inlined here.
Signed-off-by: Jarno Rajahalme <jarno@ovn.org>
Acked-by: Joe Stringer <joe@ovn.org>
2017-03-08 17:18:23 -08:00
OVS_FIND_FIELD_IFELSE([$KSRC/include/net/netfilter/nf_conntrack.h],
[nf_conn], [struct timer_list[[ \t]]*timeout],
[OVS_DEFINE([HAVE_NF_CONN_TIMER])])
OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack.h],
[nf_ct_delete(], [OVS_DEFINE([HAVE_NF_CT_DELETE])])
2016-06-20 18:51:06 -07:00
OVS_FIND_PARAM_IFELSE([$KSRC/include/net/netfilter/nf_conntrack.h],
[nf_ct_tmpl_alloc], [nf_conntrack_zone],
2015-12-02 23:53:38 -08:00
[OVS_DEFINE([HAVE_NF_CT_TMPL_ALLOC_TAKES_STRUCT_ZONE])])
2016-06-20 18:51:06 -07:00
OVS_FIND_PARAM_IFELSE([$KSRC/include/net/netfilter/nf_conntrack.h],
[nf_ct_get_tuplepr], [struct.net],
2016-05-02 11:19:10 -07:00
[OVS_DEFINE([HAVE_NF_CT_GET_TUPLEPR_TAKES_STRUCT_NET])])
2017-03-08 17:18:22 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack.h],
[nf_ct_set])
2017-05-03 11:53:29 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack.h],
[nf_ct_is_untracked])
2015-12-24 11:29:34 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_zones.h],
[nf_ct_zone_init])
2018-08-17 02:05:02 -07:00
OVS_FIND_FIELD_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_l3proto.h],
[net_ns_get])
2015-12-24 11:34:35 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_labels.h],
[nf_connlabels_get])
2016-06-20 18:51:09 -07:00
OVS_FIND_PARAM_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_labels.h],
[nf_connlabels_get], [int bit],
[OVS_DEFINE([HAVE_NF_CONNLABELS_GET_TAKES_BIT])])
2016-10-20 15:22:14 -07:00
OVS_FIND_FIELD_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_labels.h],
[nf_conn_labels], [words])
2016-06-20 18:51:06 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_nat.h], [nf_ct_nat_ext_add])
OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_nat.h], [nf_nat_alloc_null_binding])
2018-07-16 17:56:00 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_nat.h], [nf_nat_range2])
2016-06-20 18:51:06 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_seqadj.h], [nf_ct_seq_adjust])
2018-08-17 02:05:03 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_count.h], [nf_conncount_gc_list],
[OVS_DEFINE([HAVE_UPSTREAM_NF_CONNCOUNT])])
2015-12-02 23:53:38 -08:00
2014-05-01 15:50:48 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/random.h], [prandom_u32])
2015-12-02 23:53:41 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/random.h], [prandom_u32_max])
2010-05-14 15:39:48 -07:00
2015-12-03 11:40:53 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/rtnetlink.h], [get_link_net])
OVS_GREP_IFELSE([$KSRC/include/net/rtnetlink.h], [name_assign_type])
OVS_GREP_IFELSE([$KSRC/include/net/rtnetlink.h], [rtnl_create_link.*src_net],
[OVS_DEFINE([HAVE_RTNL_CREATE_LINK_SRC_NET])])
OVS_GREP_IFELSE([$KSRC/include/net/net_namespace.h], [possible_net_t])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/rcupdate.h], [rcu_read_lock_held], [],
[OVS_GREP_IFELSE([$KSRC/include/linux/rtnetlink.h],
2011-02-07 17:22:58 -08:00
[rcu_read_lock_held])])
2013-12-20 15:34:40 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/rtnetlink.h], [lockdep_rtnl_is_held])
datapath: Introduce net_rwsem and remove rtnl_lock()
This patch backports the following two upstream commits and
add a new symbol HAVE_NET_RWSEM in acinclude.m4 to determine
whether to use new introduced rw_semaphore, net_rwsem.
Upstream commit:
commit f0b07bb151b098d291fd1fd71ef7a2df56fb124a
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date: Thu Mar 29 19:20:32 2018 +0300
net: Introduce net_rwsem to protect net_namespace_list
rtnl_lock() is used everywhere, and contention is very high.
When someone wants to iterate over alive net namespaces,
he/she has no a possibility to do that without exclusive lock.
But the exclusive rtnl_lock() in such places is overkill,
and it just increases the contention. Yes, there is already
for_each_net_rcu() in kernel, but it requires rcu_read_lock(),
and this can't be sleepable. Also, sometimes it may be need
really prevent net_namespace_list growth, so for_each_net_rcu()
is not fit there.
This patch introduces new rw_semaphore, which will be used
instead of rtnl_mutex to protect net_namespace_list. It is
sleepable and allows not-exclusive iterations over net
namespaces list. It allows to stop using rtnl_lock()
in several places (what is made in next patches) and makes
less the time, we keep rtnl_mutex. Here we just add new lock,
while the explanation of we can remove rtnl_lock() there are
in next patches.
Fine grained locks generally are better, then one big lock,
so let's do that with net_namespace_list, while the situation
allows that.
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream commit:
commit ec9c780925c57588637e1dbd8650d294107311c0
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date: Thu Mar 29 19:21:09 2018 +0300
ovs: Remove rtnl_lock() from ovs_exit_net()
Here we iterate for_each_net() and removes
vport from alive net to the exiting net.
ovs_net::dps are protected by ovs_mutex(),
and the others, who change it (ovs_dp_cmd_new(),
__dp_destroy()) also take it.
The same with datapath::ports list.
So, we remove rtnl_lock() here.
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Justin Pettit <jpettit@ovn.org>
2018-07-16 17:55:59 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/rtnetlink.h], [net_rwsem])
2016-10-18 21:03:45 +01:00
2009-11-18 15:19:50 -08:00
# Check for the proto_data_valid member in struct sk_buff. The [^@]
# is necessary because some versions of this header remove the
# member but retain the kerneldoc comment that describes it (which
# starts with @). The brackets must be doubled because of m4
# quoting rules.
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [[[^@]]proto_data_valid],
2009-11-18 15:19:50 -08:00
[OVS_DEFINE([HAVE_PROTO_DATA_VALID])])
2015-10-09 13:21:30 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_checksum_start_offset])
2015-12-03 11:40:53 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [inner_protocol])
2016-07-08 16:24:02 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [inner_protocol_type])
2016-07-08 18:25:55 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_inner_transport_offset])
2015-05-15 06:27:35 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [kfree_skb_list])
2013-12-04 11:26:36 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [rxhash])
2014-06-24 18:28:08 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [u16.*rxhash],
[OVS_DEFINE([HAVE_U16_RXHASH])])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_dst(],
2010-05-14 15:44:39 -07:00
[OVS_DEFINE([HAVE_SKB_DST_ACCESSOR_FUNCS])])
2016-10-18 21:03:45 +01:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h],
2010-09-08 16:46:43 -07:00
[skb_copy_from_linear_data_offset])
2012-01-04 17:20:08 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h],
[skb_reset_tail_pointer])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_cow_head])
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_warn_if_lro],
2010-05-14 15:39:48 -07:00
[OVS_DEFINE([HAVE_SKB_WARN_LRO])])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [consume_skb])
2012-07-12 16:25:29 +09:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_frag_page])
2013-12-20 14:30:28 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_has_frag_list])
2013-12-18 10:57:33 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [__skb_fill_page_desc])
2013-03-12 11:34:29 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_reset_mac_len])
2013-07-22 10:38:13 -04:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_unclone])
2014-04-28 13:59:25 +12:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_orphan_frags])
2016-05-10 09:21:00 +01:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_get_hash(],
[OVS_DEFINE([HAVE_SKB_GET_HASH])])
2014-05-01 15:50:48 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_clear_hash])
2014-09-29 21:39:56 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [int.skb_zerocopy(],
[OVS_DEFINE([HAVE_SKB_ZEROCOPY])])
2015-08-28 10:37:08 -03:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [u8.*l4_rxhash],
[OVS_DEFINE([HAVE_L4_RXHASH])])
2015-01-07 12:55:49 +01:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_ensure_writable])
2015-01-07 12:55:49 +01:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_vlan_pop])
2017-02-06 21:04:39 +08:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [__skb_vlan_pop])
2015-01-07 12:55:49 +01:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_vlan_push])
2016-07-07 21:46:01 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_clear_hash_if_not_l4])
2016-07-17 09:52:05 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_postpush_rcsum])
2016-08-17 10:23:01 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [lco_csum])
2017-03-08 17:18:22 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_nfct])
compat: convert many more places to skb_put_zero().
Upstream commit:
commit de77b966ce8adcb4c58d50e2f087320d5479812a
Author: Johannes Berg <johannes.berg@intel.com>
Date: Fri Jun 16 14:29:19 2017 +0200
networking: convert many more places to skb_put_zero()
There were many places that my previous spatch didn't find,
as pointed out by yuan linyu in various patches.
The following spatch found many more and also removes the
now unnecessary casts:
@@
identifier p, p2;
expression len;
expression skb;
type t, t2;
@@
(
-p = skb_put(skb, len);
+p = skb_put_zero(skb, len);
|
-p = (t)skb_put(skb, len);
+p = skb_put_zero(skb, len);
)
... when != p
(
p2 = (t2)p;
-memset(p2, 0, len);
|
-memset(p, 0, len);
)
@@
type t, t2;
identifier p, p2;
expression skb;
@@
t *p;
...
(
-p = skb_put(skb, sizeof(t));
+p = skb_put_zero(skb, sizeof(t));
|
-p = (t *)skb_put(skb, sizeof(t));
+p = skb_put_zero(skb, sizeof(t));
)
... when != p
(
p2 = (t2)p;
-memset(p2, 0, sizeof(*p));
|
-memset(p, 0, sizeof(*p));
)
@@
expression skb, len;
@@
-memset(skb_put(skb, len), 0, len);
+skb_put_zero(skb, len);
Apply it to the tree (with one manual fixup to keep the
comment in vxlan.c, which spatch removed.)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Use e45a79da863c ("skbuff/mac80211: introduce and use skb_put_zero()")
as the basis for the backported function.
Upstream: de77b966ce8a ("networking: convert many more places to skb_put_zero()")
Signed-off-by: Joe Stringer <joe@ovn.org>
Acked-by: Greg Rose <gvrose8192@gmail.com>
2017-07-21 16:46:07 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [skb_put_zero])
2010-05-14 15:39:48 -07:00
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/types.h], [bool],
2010-05-14 15:39:48 -07:00
[OVS_DEFINE([HAVE_BOOL_TYPE])])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/types.h], [__wsum],
2010-09-08 10:04:47 -07:00
[OVS_DEFINE([HAVE_CSUM_TYPES])])
2013-05-13 15:53:06 -07:00
OVS_GREP_IFELSE([$KSRC/include/uapi/linux/types.h], [__wsum],
[OVS_DEFINE([HAVE_CSUM_TYPES])])
2010-05-14 15:39:48 -07:00
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/checksum.h], [csum_replace4])
OVS_GREP_IFELSE([$KSRC/include/net/checksum.h], [csum_unfold])
2010-05-14 15:39:48 -07:00
2015-12-02 23:53:40 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/dst.h], [dst_discard_sk])
2015-12-24 11:41:40 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/dst.h], [__skb_dst_copy])
2015-12-02 23:53:40 -08:00
2014-09-20 06:25:23 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [genl_has_listeners])
OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [mcgrp_offset])
2013-08-01 15:36:06 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [parallel_ops])
2015-02-03 21:53:36 +01:00
OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [netlink_has_listeners(net->genl_sock],
[OVS_DEFINE([HAVE_GENL_HAS_LISTENERS_TAKES_NET])])
2015-01-21 16:42:51 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [genlmsg_parse])
2015-03-24 16:16:18 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [genl_notify.*family],
[OVS_DEFINE([HAVE_GENL_NOTIFY_TAKES_FAMILY])])
2016-07-18 15:13:15 -07:00
OVS_FIND_PARAM_IFELSE([$KSRC/include/net/genetlink.h],
[genl_notify], [net],
[OVS_DEFINE([HAVE_GENL_NOTIFY_TAKES_NET])])
2015-03-24 16:16:18 -07:00
OVS_FIND_FIELD_IFELSE([$KSRC/include/net/genetlink.h],
[genl_multicast_group], [id])
2015-09-18 15:23:32 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/geneve.h], [geneve_hdr])
2015-03-24 16:16:18 -07:00
2013-12-22 19:43:58 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/gre.h], [gre_cisco_register])
2015-12-03 11:40:53 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/gre.h], [gre_handle_offloads])
2014-10-20 16:13:04 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/ipv6.h], [IP6_FH_F_SKIP_RH])
2015-12-03 11:40:53 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/ipv6.h], [ip6_local_out_sk])
2015-12-02 23:53:46 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/ipv6.h], [__ipv6_addr_jhash])
2015-12-02 23:53:50 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/ip6_fib.h], [rt6i.*u.dst],
[OVS_DEFINE([HAVE_RT6INFO_DST_UNION])])
2015-12-02 23:53:44 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/ip6_route.h], [ip6_frag.*sock],
[OVS_DEFINE([HAVE_IP_FRAGMENT_TAKES_SOCK])])
2016-07-17 09:52:10 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_put_64bit])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_get_be16])
2013-04-25 14:28:16 +02:00
OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_put_be16])
OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_put_be32])
OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_put_be64])
2015-09-10 06:15:32 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_put_in_addr])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_find_nested])
2014-12-03 13:02:31 +01:00
OVS_GREP_IFELSE([$KSRC/include/net/netlink.h], [nla_is_last])
2015-11-26 22:07:23 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/netlink.h], [void.*netlink_set_err],
[OVS_DEFINE([HAVE_VOID_NETLINK_SET_ERR])])
2017-04-20 18:16:46 -07:00
OVS_FIND_PARAM_IFELSE([$KSRC/include/net/netlink.h],
[nla_parse], [netlink_ext_ack],
[OVS_DEFINE([HAVE_NETLINK_EXT_ACK])])
2010-05-14 15:39:48 -07:00
2014-01-03 15:44:28 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/sctp/checksum.h], [sctp_compute_cksum])
2011-06-22 09:26:31 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/if_vlan.h], [ADD_ALL_VLANS_CMD],
Support vlan_group workaround implemented in XenServer kernels.
Some Linux network drivers support a feature called "VLAN acceleration",
associated with a data structure called a "vlan_group". A vlan_group is,
abstractly, a dictionary that maps from a VLAN ID (in the range 0...4095)
to a VLAN device, that is, a Linux network device associated with a
particular VLAN, e.g. "eth0.9" for VLAN 9 on eth0.
Some drivers that support VLAN acceleration have bugs that fall roughly
into the following categories:
* Some NICs strip VLAN tags on receive if no vlan_group is registered,
so that the tag is completely lost.
* Some drivers size their receive buffers based on whether a vlan_group
is enabled, meaning that a maximum size packet with a VLAN tag will
not fit if a vlan_group is not configured.
* On transmit some drivers expect that VLAN acceleration will be used
if it is available (which can only be done if a vlan_group is
configured). In these cases, the driver may fail to parse the packet
and correctly setup checksum offloading and/or TSO.
The correct long term solution is to fix these driver bugs. To cope until
then, we have prepared a patch to the Linux kernel network stack that works
around these problems. This commit adds support for the workaround
implemented by that patch.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
2011-03-16 14:39:17 -07:00
[OVS_DEFINE([HAVE_VLAN_BUG_WORKAROUND])])
2015-01-07 12:55:49 +01:00
OVS_GREP_IFELSE([$KSRC/include/linux/if_vlan.h], [vlan_insert_tag_set_proto])
2015-01-07 12:55:49 +01:00
OVS_GREP_IFELSE([$KSRC/include/linux/if_vlan.h], [__vlan_insert_tag])
2015-12-03 11:40:53 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/if_vlan.h], [vlan_get_protocol])
2017-02-13 10:39:12 +08:00
OVS_GREP_IFELSE([$KSRC/include/linux/if_vlan.h], [skb_vlan_tagged])
2017-02-13 10:39:14 +08:00
OVS_GREP_IFELSE([$KSRC/include/linux/if_vlan.h], [eth_type_vlan])
Support vlan_group workaround implemented in XenServer kernels.
Some Linux network drivers support a feature called "VLAN acceleration",
associated with a data structure called a "vlan_group". A vlan_group is,
abstractly, a dictionary that maps from a VLAN ID (in the range 0...4095)
to a VLAN device, that is, a Linux network device associated with a
particular VLAN, e.g. "eth0.9" for VLAN 9 on eth0.
Some drivers that support VLAN acceleration have bugs that fall roughly
into the following categories:
* Some NICs strip VLAN tags on receive if no vlan_group is registered,
so that the tag is completely lost.
* Some drivers size their receive buffers based on whether a vlan_group
is enabled, meaning that a maximum size packet with a VLAN tag will
not fit if a vlan_group is not configured.
* On transmit some drivers expect that VLAN acceleration will be used
if it is available (which can only be done if a vlan_group is
configured). In these cases, the driver may fail to parse the packet
and correctly setup checksum offloading and/or TSO.
The correct long term solution is to fix these driver bugs. To cope until
then, we have prepared a patch to the Linux kernel network stack that works
around these problems. This commit adds support for the workaround
implemented by that patch.
Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
2011-03-16 14:39:17 -07:00
2017-07-21 16:46:10 -07:00
OVS_FIND_PARAM_IFELSE([$KSRC/include/net/dst_metadata.h],
[metadata_dst_alloc], [metadata_type])
2014-06-30 13:43:25 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/u64_stats_sync.h], [u64_stats_fetch_begin_irq])
datapath: Account for "vxlan: Group Policy extension"
Upstream commit:
vxlan: Group Policy extension
Implements supports for the Group Policy VXLAN extension [0] to provide
a lightweight and simple security label mechanism across network peers
based on VXLAN. The security context and associated metadata is mapped
to/from skb->mark. This allows further mapping to a SELinux context
using SECMARK, to implement ACLs directly with nftables, iptables, OVS,
tc, etc.
The group membership is defined by the lower 16 bits of skb->mark, the
upper 16 bits are used for flags.
SELinux allows to manage label to secure local resources. However,
distributed applications require ACLs to implemented across hosts. This
is typically achieved by matching on L2-L4 fields to identify the
original sending host and process on the receiver. On top of that,
netlabel and specifically CIPSO [1] allow to map security contexts to
universal labels. However, netlabel and CIPSO are relatively complex.
This patch provides a lightweight alternative for overlay network
environments with a trusted underlay. No additional control protocol
is required.
Host 1: Host 2:
Group A Group B Group B Group A
+-----+ +-------------+ +-------+ +-----+
| lxc | | SELinux CTX | | httpd | | VM |
+--+--+ +--+----------+ +---+---+ +--+--+
\---+---/ \----+---/
| |
+---+---+ +---+---+
| vxlan | | vxlan |
+---+---+ +---+---+
+------------------------------+
Backwards compatibility:
A VXLAN-GBP socket can receive standard VXLAN frames and will assign
the default group 0x0000 to such frames. A Linux VXLAN socket will
drop VXLAN-GBP frames. The extension is therefore disabled by default
and needs to be specifically enabled:
ip link add [...] type vxlan [...] gbp
In a mixed environment with VXLAN and VXLAN-GBP sockets, the GBP socket
must run on a separate port number.
Examples:
iptables:
host1# iptables -I OUTPUT -m owner --uid-owner 101 -j MARK --set-mark 0x200
host2# iptables -I INPUT -m mark --mark 0x200 -j DROP
OVS:
# ovs-ofctl add-flow br0 'in_port=1,actions=load:0x200->NXM_NX_TUN_GBP_ID[],NORMAL'
# ovs-ofctl add-flow br0 'in_port=2,tun_gbp_id=0x200,actions=drop'
[0] https://tools.ietf.org/html/draft-smith-vxlan-group-policy
[1] http://lwn.net/Articles/204905/
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Upstream: 351149 ("vxlan: Group Policy extension")
Signed-off-by: Thomas Graf <tgraf@noironetworks.com>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
2015-02-03 21:53:35 +01:00
OVS_GREP_IFELSE([$KSRC/include/net/vxlan.h], [struct vxlan_metadata],
[OVS_DEFINE([HAVE_VXLAN_METADATA])])
2014-09-18 14:48:56 +02:00
OVS_GREP_IFELSE([$KSRC/include/net/udp.h], [udp_flow_src_port],
2015-03-24 16:16:18 -07:00
[OVS_GREP_IFELSE([$KSRC/include/net/udp.h], [inet_get_local_port_range(net],
[OVS_DEFINE([HAVE_UDP_FLOW_SRC_PORT])])])
OVS_GREP_IFELSE([$KSRC/include/net/udp.h], [udp_v4_check])
2015-12-03 11:40:53 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/udp_tunnel.h], [udp_tunnel_gro_complete])
2016-07-25 18:40:05 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/udp_tunnel.h], [sk_buff.*udp_tunnel_handle_offloads],
[OVS_DEFINE([HAVE_UDP_TUNNEL_HANDLE_OFFLOAD_RET_SKB])])
2016-07-07 21:52:24 -07:00
OVS_FIND_FIELD_IFELSE([$KSRC/include/net/udp_tunnel.h], [udp_tunnel_sock_cfg],
[gro_receive])
2015-12-03 11:40:53 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h], [ignore_df],
2014-09-18 14:48:56 +02:00
[OVS_DEFINE([HAVE_IGNORE_DF_RENAME])])
OVS_GREP_IFELSE([$KSRC/include/uapi/linux/netdevice.h], [NET_NAME_UNKNOWN],
[OVS_DEFINE([HAVE_NET_NAME_UNKNOWN])])
2013-04-25 14:28:15 +02:00
2016-07-07 21:51:17 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/sock.h], [sk_no_check_tx])
OVS_GREP_IFELSE([$KSRC/include/linux/udp.h], [no_check6_tx])
2015-08-28 10:37:11 -03:00
OVS_GREP_IFELSE([$KSRC/include/linux/utsrelease.h], [el6],
[OVS_DEFINE([HAVE_RHEL6_PER_CPU])])
2016-08-10 10:34:37 -07:00
OVS_FIND_PARAM_IFELSE([$KSRC/include/net/protocol.h],
[udp_add_offload], [net],
[OVS_DEFINE([HAVE_UDP_ADD_OFFLOAD_TAKES_NET])])
2017-04-27 16:13:12 -07:00
OVS_FIND_PARAM_IFELSE([$KSRC/include/net/netfilter/ipv6/nf_defrag_ipv6.h],
[nf_defrag_ipv6_enable], [net],
[OVS_DEFINE([HAVE_DEFRAG_ENABLE_TAKES_NET])])
2017-06-16 16:37:09 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/genetlink.h], [family_list],
[OVS_DEFINE([HAVE_GENL_FAMILY_LIST])])
datapath: Fix inconsistent teardown and release of private netdev state.
Upstream commit:
commit cf124db566e6b036b8bcbe8decbed740bdfac8c6
Author: David S. Miller <davem@davemloft.net>
Date: Mon May 8 12:52:56 2017 -0400
net: Fix inconsistent teardown and release of private netdev state.
Network devices can allocate reasources and private memory using
netdev_ops->ndo_init(). However, the release of these resources
can occur in one of two different places.
Either netdev_ops->ndo_uninit() or netdev->destructor().
The decision of which operation frees the resources depends upon
whether it is necessary for all netdev refs to be released before it
is safe to perform the freeing.
netdev_ops->ndo_uninit() presumably can occur right after the
NETDEV_UNREGISTER notifier completes and the unicast and multicast
address lists are flushed.
netdev->destructor(), on the other hand, does not run until the
netdev references all go away.
Further complicating the situation is that netdev->destructor()
almost universally does also a free_netdev().
This creates a problem for the logic in register_netdevice().
Because all callers of register_netdevice() manage the freeing
of the netdev, and invoke free_netdev(dev) if register_netdevice()
fails.
If netdev_ops->ndo_init() succeeds, but something else fails inside
of register_netdevice(), it does call ndo_ops->ndo_uninit(). But
it is not able to invoke netdev->destructor().
This is because netdev->destructor() will do a free_netdev() and
then the caller of register_netdevice() will do the same.
However, this means that the resources that would normally be released
by netdev->destructor() will not be.
Over the years drivers have added local hacks to deal with this, by
invoking their destructor parts by hand when register_netdevice()
fails.
Many drivers do not try to deal with this, and instead we have leaks.
Let's close this hole by formalizing the distinction between what
private things need to be freed up by netdev->destructor() and whether
the driver needs unregister_netdevice() to perform the free_netdev().
netdev->priv_destructor() performs all actions to free up the private
resources that used to be freed by netdev->destructor(), except for
free_netdev().
netdev->needs_free_netdev is a boolean that indicates whether
free_netdev() should be done at the end of unregister_netdevice().
Now, register_netdevice() can sanely release all resources after
ndo_ops->ndo_init() succeeds, by invoking both ndo_ops->ndo_uninit()
and netdev->priv_destructor().
And at the end of unregister_netdevice(), we invoke
netdev->priv_destructor() and optionally call free_netdev().
Signed-off-by: David S. Miller <davem@davemloft.net>
Applied the portion of the commit applicable to openvswitch.
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
Signed-off-by: Joe Stringer <joe@ovn.org>
2017-07-21 16:46:06 -07:00
OVS_FIND_FIELD_IFELSE([$KSRC/include/linux/netdevice.h], [net_device],
[needs_free_netdev],
[OVS_DEFINE([HAVE_NEEDS_FREE_NETDEV])])
2017-07-21 16:46:09 -07:00
OVS_FIND_FIELD_IFELSE([$KSRC/include/net/vxlan.h], [vxlan_dev], [cfg],
[OVS_DEFINE([HAVE_VXLAN_DEV_CFG])])
2017-07-21 16:46:04 -07:00
OVS_GREP_IFELSE([$KSRC/include/net/netfilter/nf_conntrack_helper.h],
2017-09-21 08:35:29 -07:00
[nf_conntrack_helper_put],
[OVS_DEFINE(HAVE_NF_CONNTRACK_HELPER_PUT)])
2017-10-31 17:03:41 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h],[[[[:space:]]]SKB_GSO_UDP[[[:space:]]]],
2017-09-11 14:10:54 -07:00
[OVS_DEFINE([HAVE_SKB_GSO_UDP])])
2017-09-11 14:11:02 -07:00
OVS_FIND_FIELD_IFELSE([$KSRC/include/net/rtnetlink.h], [rtnl_link_ops],
[extack],
[OVS_DEFINE([HAVE_EXT_ACK_IN_RTNL_LINKOPS])])
2017-09-11 14:11:04 -07:00
OVS_FIND_FIELD_IFELSE([$KSRC/include/linux/netfilter.h], [nf_hook_ops],
[list],
[OVS_DEFINE([HAVE_LIST_IN_NF_HOOK_OPS])])
2018-01-22 14:10:04 -05:00
OVS_GREP_IFELSE([$KSRC/include/uapi/linux/netfilter/nf_conntrack_common.h],
[IP_CT_UNTRACKED])
2018-02-07 07:30:01 -08:00
OVS_FIND_PARAM_IFELSE([$KSRC/include/linux/netdevice.h],
[netdev_master_upper_dev_link], [extack],
[OVS_DEFINE([HAVE_UPPER_DEV_LINK_EXTACK])])
2018-02-07 07:30:06 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/compiler_types.h],
[__LINUX_COMPILER_TYPES_H],
[OVS_DEFINE([HAVE_LINUX_COMPILER_TYPES_H])])
2018-02-07 07:30:10 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/timekeeping.h],
[ktime_get_ts64],
[OVS_DEFINE([HAVE_KTIME_GET_TS64])])
2018-02-07 07:49:52 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/net_namespace.h],
[EXPORT_SYMBOL_GPL(peernet2id_alloc)],
[OVS_DEFINE([HAVE_PEERNET2ID_ALLOC])])
2018-02-13 15:48:24 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/timekeeping.h],
[ktime_get_ns],
[OVS_DEFINE([HAVE_KTIME_GET_NS])])
2018-02-26 14:10:15 -08:00
OVS_GREP_IFELSE([$KSRC/include/net/inet_frag.h],
frag_percpu_counter_batch[],
[OVS_DEFINE([HAVE_FRAG_PERCPU_COUNTER_BATCH])])
2018-02-22 12:28:02 -08:00
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h],
[null_compute_pseudo],
[OVS_DEFINE([HAVE_NULL_COMPUTE_PSEUDO])])
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h],
[__skb_checksum_convert],
[OVS_DEFINE([HAVE_SKB_CHECKSUM_CONVERT])])
OVS_FIND_FIELD_IFELSE([$KSRC/include/linux/netdevice.h], [net_device],
[max_mtu],
[OVS_DEFINE([HAVE_NET_DEVICE_MAX_MTU])])
OVS_FIND_FIELD_IFELSE([$KSRC/include/net/ip6_tunnel.h], [__ip6_tnl_parm],
[erspan_ver],
[OVS_DEFINE([HAVE_IP6_TNL_PARM_ERSPAN_VER])])
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h],
[SKB_GSO_IPXIP6],
[OVS_DEFINE([HAVE_SKB_GSO_IPXIP6])])
OVS_FIND_PARAM_IFELSE([$KSRC/include/net/ipv6.h],
[ip6_make_flowlabel], [fl6],
[OVS_DEFINE([HAVE_IP6_MAKE_FLOWLABEL_FL6])])
OVS_FIND_FIELD_IFELSE([$KSRC/include/net/ipv6.h], [netns_sysctl_ipv6],
[auto_flowlabels],
[OVS_DEFINE([HAVE_NETNS_SYSCTL_IPV6_AUTO_FLOWLABELS])])
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h],
[netif_keep_dst],
[OVS_DEFINE([HAVE_NETIF_KEEP_DST])])
OVS_FIND_FIELD_IFELSE([$KSRC/include/linux/netdevice.h], [net_device_ops],
[ndo_get_iflink],
[OVS_DEFINE([HAVE_NDO_GET_IFLINK])])
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h],
[skb_set_inner_ipproto],
[OVS_DEFINE([HAVE_SKB_SET_INNER_IPPROTO])])
OVS_GREP_IFELSE([$KSRC/include/uapi/linux/if_tunnel.h],
[tunnel_encap_types],
[OVS_DEFINE([HAVE_TUNNEL_ENCAP_TYPES])])
OVS_GREP_IFELSE([$KSRC/include/uapi/linux/if_tunnel.h],
[IFLA_IPTUN_ENCAP_TYPE],
[OVS_DEFINE([HAVE_IFLA_IPTUN_ENCAP_TYPE])])
OVS_GREP_IFELSE([$KSRC/include/uapi/linux/if_tunnel.h],
[IFLA_IPTUN_COLLECT_METADATA],
[OVS_DEFINE([HAVE_IFLA_IPTUN_COLLECT_METADATA])])
2018-05-16 13:13:20 -07:00
OVS_GREP_IFELSE([$KSRC/include/uapi/linux/if_tunnel.h],
[IFLA_GRE_ENCAP_DPORT])
OVS_GREP_IFELSE([$KSRC/include/uapi/linux/if_tunnel.h],
[IFLA_GRE_COLLECT_METADATA])
OVS_GREP_IFELSE([$KSRC/include/uapi/linux/if_tunnel.h],
[IFLA_GRE_IGNORE_DF])
OVS_GREP_IFELSE([$KSRC/include/uapi/linux/if_tunnel.h],
[IFLA_GRE_FWMARK])
OVS_GREP_IFELSE([$KSRC/include/uapi/linux/if_tunnel.h],
[IFLA_GRE_ERSPAN_INDEX])
OVS_GREP_IFELSE([$KSRC/include/uapi/linux/if_tunnel.h],
[IFLA_GRE_ERSPAN_HWID])
2018-05-31 14:10:10 -07:00
OVS_GREP_IFELSE([$KSRC/include/uapi/linux/if_tunnel.h],
[IFLA_IPTUN_FWMARK])
2018-06-01 13:07:43 -07:00
OVS_FIND_FIELD_IFELSE([$KSRC/include/linux/skbuff.h], [sk_buff],
[csum_valid],
[OVS_DEFINE([HAVE_SKBUFF_CSUM_VALID])])
OVS_GREP_IFELSE([$KSRC/include/linux/skbuff.h],
[skb_checksum_simple_validate])
2018-08-13 16:00:16 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/netdevice.h],
[void.*ndo_get_stats64],
[OVS_DEFINE([HAVE_VOID_NDO_GET_STATS64])])
2018-08-16 09:52:55 -07:00
OVS_GREP_IFELSE([$KSRC/include/linux/timer.h], [init_timer_deferrable],
[OVS_DEFINE([HAVE_INIT_TIMER_DEFERRABLE])])
2015-08-28 10:37:11 -03:00
2011-06-23 17:10:00 -07:00
if cmp -s datapath/linux/kcompat.h.new \
datapath/linux/kcompat.h >/dev/null 2>&1; then
rm datapath/linux/kcompat.h.new
2009-07-08 13:19:16 -07:00
else
2011-06-23 17:10:00 -07:00
mv datapath/linux/kcompat.h.new datapath/linux/kcompat.h
2009-07-08 13:19:16 -07:00
fi
])
dnl Checks for net/if_packet.h.
AC_DEFUN([OVS_CHECK_IF_PACKET],
[AC_CHECK_HEADER([net/if_packet.h],
[HAVE_IF_PACKET=yes],
[HAVE_IF_PACKET=no])
AM_CONDITIONAL([HAVE_IF_PACKET], [test "$HAVE_IF_PACKET" = yes])
if test "$HAVE_IF_PACKET" = yes; then
AC_DEFINE([HAVE_IF_PACKET], [1],
[Define to 1 if net/if_packet.h is available.])
fi])
2012-07-25 22:51:05 +02:00
dnl Checks for net/if_dl.h.
2013-03-14 15:20:55 -07:00
dnl
2013-05-21 17:50:02 +09:00
dnl (We use this as a proxy for checking whether we're building on FreeBSD
dnl or NetBSD.)
2012-06-29 21:11:24 +00:00
AC_DEFUN([OVS_CHECK_IF_DL],
[AC_CHECK_HEADER([net/if_dl.h],
[HAVE_IF_DL=yes],
[HAVE_IF_DL=no])
AM_CONDITIONAL([HAVE_IF_DL], [test "$HAVE_IF_DL" = yes])
if test "$HAVE_IF_DL" = yes; then
AC_DEFINE([HAVE_IF_DL], [1],
[Define to 1 if net/if_dl.h is available.])
2013-03-14 15:20:55 -07:00
2013-05-21 17:50:02 +09:00
# On these platforms we use libpcap to access network devices.
2013-03-14 15:20:55 -07:00
AC_SEARCH_LIBS([pcap_open_live], [pcap])
2012-06-29 21:11:24 +00:00
fi])
2009-06-10 14:16:40 -07:00
dnl Checks for buggy strtok_r.
dnl
dnl Some versions of glibc 2.7 has a bug in strtok_r when compiling
dnl with optimization that can cause segfaults:
dnl
dnl http://sources.redhat.com/bugzilla/show_bug.cgi?id=5614.
AC_DEFUN([OVS_CHECK_STRTOK_R],
[AC_CACHE_CHECK(
[whether strtok_r macro segfaults on some inputs],
[ovs_cv_strtok_r_bug],
[AC_RUN_IFELSE(
[AC_LANG_PROGRAM([#include <stdio.h>
#include <string.h>
],
2015-04-03 15:10:57 -07:00
[[#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 8
/* Assume bug is present, because relatively minor
changes in compiler settings (e.g. optimization
level) can make it crop up. */
return 1;
#else
char string[] = ":::";
2009-06-10 14:16:40 -07:00
char *save_ptr = (char *) 0xc0ffee;
char *token1, *token2;
token1 = strtok_r(string, ":", &save_ptr);
token2 = strtok_r(NULL, ":", &save_ptr);
2010-01-25 10:32:39 -08:00
freopen ("/dev/null", "w", stdout);
2009-06-10 14:16:40 -07:00
printf ("%s %s\n", token1, token2);
return 0;
2015-04-03 15:10:57 -07:00
#endif
2009-06-10 14:16:40 -07:00
]])],
[ovs_cv_strtok_r_bug=no],
[ovs_cv_strtok_r_bug=yes],
[ovs_cv_strtok_r_bug=yes])])
if test $ovs_cv_strtok_r_bug = yes; then
AC_DEFINE([HAVE_STRTOK_R_BUG], [1],
[Define if strtok_r macro segfaults on some inputs])
fi
])
2009-07-08 13:19:16 -07:00
dnl ----------------------------------------------------------------------
dnl These macros are from GNU PSPP, with the following original license:
dnl Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
2013-06-24 12:25:48 -07:00
AC_DEFUN([_OVS_CHECK_CC_OPTION], [dnl
2016-12-05 14:28:59 -08:00
m4_define([ovs_cv_name], [ovs_cv_[]m4_translit([$1], [-= ], [__])])dnl
2009-07-08 13:19:16 -07:00
AC_CACHE_CHECK([whether $CC accepts $1], [ovs_cv_name],
[ovs_save_CFLAGS="$CFLAGS"
2013-06-24 12:25:48 -07:00
dnl Include -Werror in the compiler options, because without -Werror
dnl clang's GCC-compatible compiler driver does not return a failure
dnl exit status even though it complains about options it does not
dnl understand.
2015-04-17 17:14:38 +09:00
dnl
dnl Also, check stderr as gcc exits with status 0 for options
dnl rejected at getopt level.
dnl % touch /tmp/a.c
dnl % gcc -g -c -Werror -Qunused-arguments /tmp/a.c; echo $?
dnl gcc: unrecognized option '-Qunused-arguments'
dnl 0
dnl %
2013-06-24 12:25:48 -07:00
CFLAGS="$CFLAGS $WERROR $1"
2016-12-05 14:29:35 -08:00
AC_COMPILE_IFELSE(
[AC_LANG_SOURCE([int x;])],
[if test -s conftest.err && grep "unrecognized option" conftest.err
then
ovs_cv_name[]=no
else
ovs_cv_name[]=yes
fi],
[ovs_cv_name[]=no])
2009-07-08 13:19:16 -07:00
CFLAGS="$ovs_save_CFLAGS"])
if test $ovs_cv_name = yes; then
2009-11-18 16:27:55 -08:00
m4_if([$2], [], [:], [$2])
2009-07-08 13:19:16 -07:00
else
m4_if([$3], [], [:], [$3])
fi
])
2013-06-24 12:25:48 -07:00
dnl OVS_CHECK_WERROR
dnl
dnl Check whether the C compiler accepts -Werror.
dnl Sets $WERROR to "-Werror", if so, and otherwise to the empty string.
AC_DEFUN([OVS_CHECK_WERROR],
[WERROR=
_OVS_CHECK_CC_OPTION([-Werror], [WERROR=-Werror])])
dnl OVS_CHECK_CC_OPTION([OPTION], [ACTION-IF-ACCEPTED], [ACTION-IF-REJECTED])
dnl Check whether the given C compiler OPTION is accepted.
dnl If so, execute ACTION-IF-ACCEPTED, otherwise ACTION-IF-REJECTED.
AC_DEFUN([OVS_CHECK_CC_OPTION],
[AC_REQUIRE([OVS_CHECK_WERROR])
_OVS_CHECK_CC_OPTION([$1], [$2], [$3])])
2009-07-08 13:19:16 -07:00
dnl OVS_ENABLE_OPTION([OPTION])
dnl Check whether the given C compiler OPTION is accepted.
2009-11-19 13:25:42 -08:00
dnl If so, add it to WARNING_FLAGS.
2009-07-08 13:19:16 -07:00
dnl Example: OVS_ENABLE_OPTION([-Wdeclaration-after-statement])
AC_DEFUN([OVS_ENABLE_OPTION],
2009-11-19 13:25:42 -08:00
[OVS_CHECK_CC_OPTION([$1], [WARNING_FLAGS="$WARNING_FLAGS $1"])
AC_SUBST([WARNING_FLAGS])])
2009-11-20 09:45:26 -08:00
dnl OVS_CONDITIONAL_CC_OPTION([OPTION], [CONDITIONAL])
dnl Check whether the given C compiler OPTION is accepted.
dnl If so, enable the given Automake CONDITIONAL.
dnl Example: OVS_CONDITIONAL_CC_OPTION([-Wno-unused], [HAVE_WNO_UNUSED])
AC_DEFUN([OVS_CONDITIONAL_CC_OPTION],
[OVS_CHECK_CC_OPTION(
[$1], [ovs_have_cc_option=yes], [ovs_have_cc_option=no])
AM_CONDITIONAL([$2], [test $ovs_have_cc_option = yes])])
2009-07-08 13:19:16 -07:00
dnl ----------------------------------------------------------------------
2011-02-22 14:47:19 -08:00
dnl Check for too-old XenServer.
AC_DEFUN([OVS_CHECK_XENSERVER_VERSION],
[AC_CACHE_CHECK([XenServer release], [ovs_cv_xsversion],
[if test -e /etc/redhat-release; then
ovs_cv_xsversion=`sed -n 's/^XenServer DDK release \([[^-]]*\)-.*/\1/p' /etc/redhat-release`
fi
if test -z "$ovs_cv_xsversion"; then
ovs_cv_xsversion=none
fi])
case $ovs_cv_xsversion in
none)
;;
[[1-9]][[0-9]]* | dnl XenServer 10 or later
[[6-9]]* | dnl XenServer 6 or later
5.[[7-9]]* | dnl XenServer 5.7 or later
5.6.[[1-9]][[0-9]][[0-9]][[0-9]]* | dnl XenServer 5.6.1000 or later
5.6.[[2-9]][[0-9]][[0-9]]* | dnl XenServer 5.6.200 or later
5.6.1[[0-9]][[0-9]]) dnl Xenserver 5.6.100 or later
;;
*)
AC_MSG_ERROR([This appears to be XenServer $ovs_cv_xsversion, but only XenServer 5.6.100 or later is supported. (If you are really using a supported version of XenServer, you may override this error message by specifying 'ovs_cv_xsversion=5.6.100' on the "configure" command line.)])
;;
esac])
2011-05-06 13:00:49 -07:00
2011-07-11 13:57:58 -07:00
dnl OVS_CHECK_SPARSE_TARGET
dnl
dnl The "cgcc" script from "sparse" isn't very good at detecting the
dnl target for which the code is being built. This helps it out.
AC_DEFUN([OVS_CHECK_SPARSE_TARGET],
[AC_CACHE_CHECK(
[target hint for cgcc],
[ac_cv_sparse_target],
[AS_CASE([`$CC -dumpmachine 2>/dev/null`],
[i?86-* | athlon-*], [ac_cv_sparse_target=x86],
[x86_64-*], [ac_cv_sparse_target=x86_64],
[ac_cv_sparse_target=other])])
AS_CASE([$ac_cv_sparse_target],
[x86], [SPARSEFLAGS= CGCCFLAGS=-target=i86],
[x86_64], [SPARSEFLAGS=-m64 CGCCFLAGS=-target=x86_64],
[SPARSEFLAGS= CGCCFLAGS=])
AC_SUBST([SPARSEFLAGS])
AC_SUBST([CGCCFLAGS])])
2013-04-05 16:56:52 -07:00
dnl OVS_SPARSE_EXTRA_INCLUDES
dnl
dnl The cgcc script from "sparse" does not search gcc's default
dnl search path. Get the default search path from GCC and pass
dnl them to sparse.
AC_DEFUN([OVS_SPARSE_EXTRA_INCLUDES],
AC_SUBST([SPARSE_EXTRA_INCLUDES],
[`$CC -v -E - </dev/null 2>&1 >/dev/null | sed -n -e '/^#include.*search.*starts.*here:/,/^End.*of.*search.*list\./s/^ \(.*\)/-I \1/p' |grep -v /usr/lib | grep -x -v '\-I /usr/include' | tr \\\n ' ' `] ))
2011-05-06 13:00:49 -07:00
dnl OVS_ENABLE_SPARSE
AC_DEFUN([OVS_ENABLE_SPARSE],
2011-07-11 13:57:58 -07:00
[AC_REQUIRE([OVS_CHECK_SPARSE_TARGET])
2013-04-05 16:56:52 -07:00
AC_REQUIRE([OVS_SPARSE_EXTRA_INCLUDES])
2012-07-25 10:28:38 -07:00
: ${SPARSE=sparse}
AC_SUBST([SPARSE])
AC_CONFIG_COMMANDS_PRE(
2018-01-11 15:49:24 -08:00
[CC='$(if $(C:0=),env REAL_CC="'"$CC"'" CHECK="$(SPARSE) $(SPARSE_WERROR) -I $(top_srcdir)/include/sparse $(SPARSEFLAGS) $(SPARSE_EXTRA_INCLUDES) " cgcc $(CGCCFLAGS),'"$CC"')'])
AC_ARG_ENABLE(
[sparse],
[AC_HELP_STRING([--enable-sparse], [Run "sparse" by default])],
[], [enable_sparse=no])
AM_CONDITIONAL([ENABLE_SPARSE_BY_DEFAULT], [test $enable_sparse = yes])])
2013-08-01 09:35:56 -07:00
2017-06-26 21:55:50 -03:00
dnl OVS_CTAGS_IDENTIFIERS
dnl
dnl ctags ignores symbols with extras identifiers. This builds a list of
dnl specially handled identifiers to be ignored.
AC_DEFUN([OVS_CTAGS_IDENTIFIERS],
AC_SUBST([OVS_CTAGS_IDENTIFIERS_LIST],
2017-07-17 10:12:44 -07:00
[`printf %s '-I "'; sed -n 's/^#define \(OVS_[A-Z_]\+\)(\.\.\.)$/\1+/p' ${srcdir}/include/openvswitch/compiler.h | tr \\\n ' ' ; printf '"'`] ))
2017-06-26 21:55:50 -03:00
2013-08-01 09:35:56 -07:00
dnl OVS_PTHREAD_SET_NAME
dnl
dnl This checks for three known variants of pthreads functions for setting
dnl the name of the current thread:
dnl
dnl glibc: int pthread_setname_np(pthread_t, const char *name);
dnl NetBSD: int pthread_setname_np(pthread_t, const char *format, void *arg);
dnl FreeBSD: int pthread_set_name_np(pthread_t, const char *name);
dnl
dnl For glibc and FreeBSD, the arguments are just a thread and its name. For
dnl NetBSD, 'format' is a printf() format string and 'arg' is an argument to
dnl provide to it.
dnl
dnl This macro defines:
dnl
dnl glibc: HAVE_GLIBC_PTHREAD_SETNAME_NP
dnl NetBSD: HAVE_NETBSD_PTHREAD_SETNAME_NP
dnl FreeBSD: HAVE_PTHREAD_SET_NAME_NP
AC_DEFUN([OVS_CHECK_PTHREAD_SET_NAME],
[AC_CHECK_FUNCS([pthread_set_name_np])
if test $ac_cv_func_pthread_set_name_np != yes; then
AC_CACHE_CHECK(
[for pthread_setname_np() variant],
[ovs_cv_pthread_setname_np],
[AC_LINK_IFELSE(
2014-05-09 13:28:49 +09:00
[AC_LANG_PROGRAM([#include <pthread.h>
2013-08-01 09:35:56 -07:00
], [pthread_setname_np(pthread_self(), "name");])],
2014-05-09 13:28:49 +09:00
[ovs_cv_pthread_setname_np=glibc],
2013-08-01 09:35:56 -07:00
[AC_LINK_IFELSE(
2014-05-09 13:28:49 +09:00
[AC_LANG_PROGRAM([#include <pthread.h>
2013-08-01 09:35:56 -07:00
], [pthread_setname_np(pthread_self(), "%s", "name");])],
[ovs_cv_pthread_setname_np=netbsd],
2014-05-09 13:28:49 +09:00
[ovs_cv_pthread_setname_np=none])])])
2013-08-01 09:35:56 -07:00
case $ovs_cv_pthread_setname_np in # (
glibc)
2014-05-09 13:28:49 +09:00
AC_DEFINE(
[HAVE_GLIBC_PTHREAD_SETNAME_NP], [1],
[Define to 1 if pthread_setname_np() is available and takes 2 parameters (like glibc).])
;; # (
2013-08-01 09:35:56 -07:00
netbsd)
2014-05-09 13:28:49 +09:00
AC_DEFINE(
[HAVE_NETBSD_PTHREAD_SETNAME_NP], [1],
[Define to 1 if pthread_setname_np() is available and takes 3 parameters (like NetBSD).])
;;
2013-08-01 09:35:56 -07:00
esac
fi])
2014-01-23 15:35:22 -08:00
dnl OVS_CHECK_LINUX_HOST.
dnl
dnl Checks whether we're building for a Linux host, based on the presence of
dnl the __linux__ preprocessor symbol, and sets up an Automake conditional
dnl LINUX based on the result.
AC_DEFUN([OVS_CHECK_LINUX_HOST],
[AC_CACHE_CHECK(
[whether __linux__ is defined],
[ovs_cv_linux],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([enum { LINUX = __linux__};], [])],
[ovs_cv_linux=true],
[ovs_cv_linux=false])])
AM_CONDITIONAL([LINUX], [$ovs_cv_linux])])