From 3ee3e5ad6e6eb06f13297dd67054325a9af6926a Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Mon, 3 Nov 2014 18:35:28 +0100 Subject: Kernel API changes in em_ipset.c, support both old and new ones --- configure.ac | 22 ++++++++++++++++++++++ .../linux/netfilter/ipset/ip_set_compat.h.in | 2 ++ kernel/net/sched/em_ipset.c | 16 ++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/configure.ac b/configure.ac index 10529af..8e5c270 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in b/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in index d38197c..9809e2a 100644 --- a/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in +++ b/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in @@ -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. diff --git a/kernel/net/sched/em_ipset.c b/kernel/net/sched/em_ipset.c index 527aeb7..2729d7e 100644 --- a/kernel/net/sched/em_ipset.c +++ b/kernel/net/sched/em_ipset.c @@ -15,16 +15,24 @@ #include #include #include +#include #include #include #include +#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); } } -- cgit v1.2.3