diff --git a/compat.h b/compat.h index 8461c3d..dffc9e3 100644 --- a/compat.h +++ b/compat.h @@ -746,9 +746,10 @@ unsigned long long strtoul(const char *cp, char **endp, unsigned int base) return result; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,12,0) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,12,0)) \ + || ((LINUX_VERSION_CODE >= KERNEL_VERSION(5,10,220)) && (LINUX_VERSION_CODE < KERNEL_VERSION(5,11,0))) /* - * find_module() is unexported in v5.12: + * find_module() is unexported in v5.12 (backported to 5.10.220): * 089049f6c9956 ("module: unexport find_module and module_mutex") * and module_mutex is replaced with RCU in * a006050575745 ("module: use RCU to synchronize find_module") @@ -773,13 +774,14 @@ struct module *find_module(const char *name) /* Copy from 294f69e662d1 ("compiler_attributes.h: Add 'fallthrough' pseudo * keyword for switch/case use") */ -#ifndef fallthrough -# if defined __has_attribute && __has_attribute(__fallthrough__) +#if !defined(fallthrough) && defined(__has_attribute) +# if __has_attribute(__fallthrough__) # define fallthrough __attribute__((__fallthrough__)) -# else -# define fallthrough do {} while (0) /* fallthrough */ # endif #endif +#ifndef fallthrough +# define fallthrough do {} while (0) /* fallthrough */ +#endif #ifndef HAVE_NF_CT_EVENT_NOTIFIER_CT_EVENT /* diff --git a/configure b/configure index 66ced00..ae8a579 100755 --- a/configure +++ b/configure @@ -6,6 +6,7 @@ PATH=$PATH:/bin:/usr/bin:/usr/sbin:/sbin:/usr/local/sbin case "$1" in --from-dkms-conf*) KDKMS=`echo "$1" | sed 's/[^=]*.//'` + KDIR="$KDKMS" # restore options from existing Makefile, if present if [ -e Makefile ]; then set -- `sed -n 's/^CARGS = \(.*\)/\1/p' Makefile` @@ -348,7 +349,7 @@ do --disable-snmp-a*) SKIPSNMP=1 ;; --disable-net-snmp*) SKIPSNMP=1 ;; --disable-dkms*) SKIPDKMS=1 ;; - --from-dkms-conf*) ;; + --from-dkms-conf*) SKIPDKMS=1 ;; --make) echo called from make; CARGS=`echo $CARGS | sed s/--make//g` ;; -Werror) KOPTS="$KOPTS -Werror" ;; --help|-h) show_help ;; @@ -614,7 +615,7 @@ dkms_check() { echo Yes. DKMSINSTALL=dinstall test "$FROMDKMSCONF" && return - if dkms status | grep ^ipt-netflow, >/dev/null; then + if dkms status ipt-netflow | grep ^ipt-netflow/ >/dev/null; then echo "! You are already have module installed via DKMS" echo "! it will be uninstalled on 'make install' and" echo "! current version of module installed afterwards." diff --git a/dkms.conf b/dkms.conf index 808e158..7968b38 100644 --- a/dkms.conf +++ b/dkms.conf @@ -2,6 +2,10 @@ PACKAGE_NAME="ipt-netflow" pushd `dirname $BASH_SOURCE` PACKAGE_VERSION=`./version.sh` popd + +# skb_reset_mac_len() was introduced in v3.0-rc3 +BUILD_EXCLUSIVE_KERNEL_MIN="3" + BUILT_MODULE_NAME[0]=ipt_NETFLOW DEST_MODULE_LOCATION[0]=/kernel/extra STRIP[0]=no diff --git a/gen_compat_def b/gen_compat_def index a9cb95e..e9d4e76 100755 --- a/gen_compat_def +++ b/gen_compat_def @@ -64,7 +64,7 @@ kbuild_test_symbol() { echo -n "Test function $* " >&2 kbuild_test_compile ${1^^} $1 ${2-} <<-EOF #include - ${2:+#include <$2>} + ${3:-${2:+#include <$2>}} MODULE_LICENSE("GPL"); void *test = $1; EOF @@ -121,7 +121,12 @@ kbuild_test_symbol nf_bridge_info_get linux/netfilter_bridge.h # Stumbled on 5.9 kbuild_test_struct vlan_dev_priv linux/if_vlan.h # Kernel version check broken by centos8 -kbuild_test_symbol put_unaligned_be24 asm/unaligned.h +kbuild_test_symbol put_unaligned_be24 '???/unaligned.h' '#include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,12,0) +#include +#else +#include +#endif' # totalram_pages changed from atomic to inline function. kbuild_test_symbol totalram_pages linux/mm.h kbuild_test_ref totalram_pages linux/mm.h diff --git a/ipt_NETFLOW.c b/ipt_NETFLOW.c index eee8074..bbd2c9b 100644 --- a/ipt_NETFLOW.c +++ b/ipt_NETFLOW.c @@ -68,12 +68,17 @@ # include #endif #include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,12,0) +#include +#else #include +#endif #ifdef HAVE_LLIST /* llist.h is officially defined since linux 3.1, * but centos6 have it backported on its 2.6.32.el6 */ # include #endif +#include #include "compat.h" #include "ipt_NETFLOW.h" #include "murmur3.h" @@ -4881,6 +4886,8 @@ static void parse_l2_header(const struct sk_buff *skb, struct ipt_netflow_tuple && !(vlan->flags & VLAN_FLAG_REORDER_HDR) # if LINUX_VERSION_CODE >= KERNEL_VERSION(4,3,0) && !netif_is_macvlan_port(vlan_dev) +# endif +# if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0) && !netif_is_bridge_port(vlan_dev) # endif ))