]> git.ipfire.org Git - thirdparty/ipset.git/commitdiff
em_ipset: Build on old kernels
authorSerhey Popovych <serhe.popovych@gmail.com>
Fri, 29 Nov 2019 09:21:32 +0000 (11:21 +0200)
committerJozsef Kadlecsik <kadlec@netfilter.org>
Mon, 9 Dec 2019 10:07:02 +0000 (11:07 +0100)
Make sure TCF_EM_IPSET defined and corresponds to current upstream value
if not defined in target kernel. You need iproute2 version that supports
em_ipset to communicate correctly. Include ip_set_compat.h after
pkt_cls.h to prevent TCF_EM_IPSET redefine error.

Detect skb->iif => skb->skb_iif rename after commit 8964be4a9a5c ("net:
rename skb->iif to skb->skb_iif").

Add dev_get_by_index_rcu() define pointing to __dev_get_by_index() to
build on RHEL6 kernels with explicit note that this may not work on all
architectures.

Always build em_ipset regardless of CONFIG_NET_EMATCH_IPSET option.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Jozsef Kadlecsik <kadlec@netfilter.org>
configure.ac
kernel/include/linux/netfilter/ipset/ip_set_compat.h.in
kernel/net/sched/Kbuild
kernel/net/sched/em_ipset.c

index 17ba18431c7a911e7866c64a0ff158c9975d4736..e3ddcce08e8aeddfc228bcedcedd5c236097c127 100644 (file)
@@ -554,6 +554,17 @@ else
        fi
 fi
 
+AC_MSG_CHECKING([kernel source for iif to skb_iif rename in struct sk_buff])
+if test -f $ksourcedir/include/linux/skbuff.h && \
+   $AWK '/^struct sk_buff {/,/^};$/' $ksourcedir/include/linux/skbuff.h | \
+   $GREP -q 'skb_iif'; then
+       AC_MSG_RESULT(yes)
+       AC_SUBST(HAVE_SKB_IIF, define)
+else
+       AC_MSG_RESULT(no)
+       AC_SUBST(HAVE_SKB_IIF, undef)
+fi
+
 AC_MSG_CHECKING([kernel source for struct net in struct xt_action_param])
 if test -f $ksourcedir/include/linux/netfilter/x_tables.h && \
    $AWK '/^struct xt_action_param /,/^}/' $ksourcedir/include/linux/netfilter/x_tables.h | \
index 92d815e15a6b8825e7a717007a3a7718a1f6c995..d71c3fdd39f5f275e3ada8812453471721050795 100644 (file)
@@ -51,6 +51,7 @@
 #@HAVE_SYNCHRONIZE_RCU_BH@ HAVE_SYNCHRONIZE_RCU_BH
 #@HAVE_LOCKDEP_NFNL_IS_HELD@ HAVE_LOCKDEP_NFNL_IS_HELD
 #@HAVE_COND_RESCHED_RCU@ HAVE_COND_RESCHED_RCU
+#@HAVE_SKB_IIF@ HAVE_SKB_IIF
 
 #ifdef HAVE_EXPORT_SYMBOL_GPL_IN_MODULE_H
 #include <linux/module.h>
@@ -430,5 +431,21 @@ static inline u16 nfnl_msg_type(u8 subsys, u8 msg_type)
 #define SIZE_MAX       (~(size_t)0)
 #endif
 
+#ifndef TCF_EM_IPSET
+#define TCF_EM_IPSET 8
+#endif
+
+#ifndef HAVE_SKB_IIF
+#define skb_iif iif
+#endif
+
+#ifndef HAVE_DEV_GET_BY_INDEX_RCU
+/* This should not be considered RCU-safe on all architectures.
+ * You probably should consider upgrading your kernel in case of
+ * kernel crashes including em_ipset and this function call.
+ */
+#define dev_get_by_index_rcu __dev_get_by_index
+#endif
+
 #endif /* IP_SET_COMPAT_HEADERS */
 #endif /* __IP_SET_COMPAT_H */
index 6d8e8d6b54dbdc137fc480b38a33671890d73156..e93476c1977474bff7165e0e1eb0a664cc54936f 100644 (file)
@@ -1,4 +1,4 @@
 NOSTDINC_FLAGS += -I$(KDIR)/include
 EXTRA_CFLAGS := -DCONFIG_IP_SET_MAX=$(IP_SET_MAX)
 
-obj-$(CONFIG_NET_EMATCH_IPSET) += em_ipset.o
+obj-m += em_ipset.o
index bd9566f46e528c185bf7900cec5ed13dc1672a15..96fd4a3f3e3eda97db80c6f7c2bbf0ff74582f8b 100644 (file)
 #include <linux/string.h>
 #include <linux/skbuff.h>
 #include <linux/netfilter/xt_set.h>
-#include <linux/netfilter/ipset/ip_set_compat.h>
 #include <linux/ipv6.h>
 #include <net/ip.h>
 #include <net/pkt_cls.h>
+#include <linux/netfilter/ipset/ip_set_compat.h>
 
 #ifdef HAVE_TCF_EMATCH_OPS_CHANGE_ARG_NET
 static int em_ipset_change(struct net *net, void *data, int data_len,