]> granicus.if.org Git - ipset/commitdiff
Compatibility: check kernel source for list_last_entry
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Wed, 17 Dec 2014 06:44:37 +0000 (07:44 +0100)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Tue, 6 Jan 2015 07:24:32 +0000 (08:24 +0100)
list_last_entry is missing on CentOS7, reported by Ricardo Klein.

configure.ac
kernel/include/linux/netfilter/ipset/ip_set_compat.h.in

index 421227458f3b2afb7a136c298ce78b957579ab24..74bc7de7bdea1e93be453e578f1412b8e64388c0 100644 (file)
@@ -376,6 +376,16 @@ else
        AC_SUBST(HAVE_TCF_EMATCH_STRUCT_NET, undef)
 fi
 
+AC_MSG_CHECKING([kernel source for list_last_entry])
+if test -f $ksourcedir/include/linux/list.h && \
+   $GREP -q 'list_last_entry' $ksourcedir/include/linux/list.h; then
+       AC_MSG_RESULT(yes)
+       AC_SUBST(HAVE_LIST_LAST_ENTRY, define)
+else
+       AC_MSG_RESULT(no)
+       AC_SUBST(HAVE_LIST_LAST_ENTRY, 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 375a18a39eb5ea025a71d668ac575dd25211e3b6..c33de443ccb241840bd01c9325a61490e559d388 100644 (file)
@@ -40,6 +40,7 @@
 #@HAVE_XT_MTCHK_PARAM_STRUCT_NET@ HAVE_XT_MTCHK_PARAM_STRUCT_NET
 #@HAVE_TCF_EMATCH_OPS_CHANGE_ARG_NET@ HAVE_TCF_EMATCH_OPS_CHANGE_ARG_NET
 #@HAVE_TCF_EMATCH_STRUCT_NET@ HAVE_TCF_EMATCH_STRUCT_NET
+#@HAVE_LIST_LAST_ENTRY@ HAVE_LIST_LAST_ENTRY
 
 /* 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.
@@ -164,4 +165,9 @@ static inline int nla_put_net32(struct sk_buff *skb, int attrtype, __be32 value)
 }
 #endif
 
+#ifndef HAVE_LIST_LAST_ENTRY
+#define list_last_entry(ptr, type, member) \
+       list_entry((ptr)->prev, type, member)
+#endif
+
 #endif /* __IP_SET_COMPAT_H */