]> granicus.if.org Git - ipset/commitdiff
Kernel API changes in em_ipset.c, support both old and new ones
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Mon, 3 Nov 2014 17:35:28 +0000 (18:35 +0100)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Mon, 3 Nov 2014 17:35:28 +0000 (18:35 +0100)
configure.ac
kernel/include/linux/netfilter/ipset/ip_set_compat.h.in
kernel/net/sched/em_ipset.c

index 10529af961044699a260d0426128835207a5f1ef..8e5c2704515ff36e52feb208d568441355b58970 100644 (file)
@@ -333,6 +333,28 @@ else
        AC_SUBST(HAVE_KVFREE, undef)
 fi
 
+AC_MSG_CHECKING([kernel source for struct net in the change function of tcf_ematch_ops])
+if test -f $ksourcedir/include/net/pkt_cls.h && \
+   $AWK '/^struct tcf_ematch_ops / {for(i=1; i<=5; i++) {getline; print}}' $ksourcedir/include/net/pkt_cls.h | \
+   $GREP -q '\*change..struct net \*net'; then
+       AC_MSG_RESULT(yes)
+       AC_SUBST(HAVE_TCF_EMATCH_OPS_CHANGE_ARG_NET, define)
+else
+       AC_MSG_RESULT(no)
+       AC_SUBST(HAVE_TCF_EMATCH_OPS_CHANGE_ARG_NET, undef)
+fi
+
+AC_MSG_CHECKING([kernel source for struct net in struct tcf_ematch])
+if test -f $ksourcedir/include/net/pkt_cls.h && \
+   $AWK '/^struct tcf_ematch_ops / {for(i=1; i<=7; i++) {getline; print}}' $ksourcedir/include/net/pkt_cls.h | \
+   $GREP -q 'struct net'; then
+       AC_MSG_RESULT(yes)
+       AC_SUBST(HAVE_TCF_EMATCH_STRUCT_NET, define)
+else
+       AC_MSG_RESULT(no)
+       AC_SUBST(HAVE_TCF_EMATCH_STRUCT_NET, undef)
+fi
+
 AC_MSG_CHECKING([kernel source for struct net_generic])
 if test -f $ksourcedir/include/net/netns/generic.h && \
    $GREP -q 'struct net_generic' $ksourcedir/include/net/netns/generic.h; then
index d38197c886ecf49d8b78eaba201e563fc926d96f..9809e2a6bab0a086b4eff7ccabee3a4c36ec6b9b 100644 (file)
@@ -36,6 +36,8 @@
 #@HAVE_USER_NS_IN_STRUCT_NET@ HAVE_USER_NS_IN_STRUCT_NET
 #@HAVE_RBTREE_POSTORDER_FOR_EACH_ENTRY_SAFE@ HAVE_RBTREE_POSTORDER_FOR_EACH_ENTRY_SAFE
 #@HAVE_KVFREE@ HAVE_KVFREE
+#@HAVE_TCF_EMATCH_OPS_CHANGE_ARG_NET@ HAVE_TCF_EMATCH_OPS_CHANGE_ARG_NET
+#@HAVE_TCF_EMATCH_STRUCT_NET@ HAVE_TCF_EMATCH_STRUCT_NET
 
 /* Not everything could be moved here. Compatibility stuffs can be found in
  * xt_set.c, ip_set_core.c, ip_set_getport.c, pfxlen.c too.
index 527aeb7a3ff0b3b558873d0c7d93fc2c26e100b8..2729d7e2e32dd0da612e7f18bf012f879abda2f6 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>
 
+#ifdef HAVE_TCF_EMATCH_OPS_CHANGE_ARG_NET
+static int em_ipset_change(struct net *net, void *data, int data_len,
+                          struct tcf_ematch *em)
+#else
 static int em_ipset_change(struct tcf_proto *tp, void *data, int data_len,
                           struct tcf_ematch *em)
+#endif
 {
        struct xt_set_info *set = data;
        ip_set_id_t index;
+#ifndef HAVE_TCF_EMATCH_OPS_CHANGE_ARG_NET
        struct net *net = dev_net(qdisc_dev(tp->q));
+#endif
 
        if (data_len != sizeof(*set))
                return -EINVAL;
@@ -42,11 +50,19 @@ static int em_ipset_change(struct tcf_proto *tp, void *data, int data_len,
        return -ENOMEM;
 }
 
+#ifdef HAVE_TCF_EMATCH_STRUCT_NET
+static void em_ipset_destroy(struct tcf_ematch *em)
+#else
 static void em_ipset_destroy(struct tcf_proto *p, struct tcf_ematch *em)
+#endif
 {
        const struct xt_set_info *set = (const void *) em->data;
        if (set) {
+#ifdef HAVE_TCF_EMATCH_STRUCT_NET
+               ip_set_nfnl_put(em->net, set->index);
+#else
                ip_set_nfnl_put(dev_net(qdisc_dev(p->q)), set->index);
+#endif
                kfree((void *) em->data);
        }
 }