Re: ipset 7.7 modules fail to build on kernel 4.19.152

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Oskar,

On Sun, 8 Nov 2020, Oskar Berggren wrote:

> > > ip_set_core.c:90:40 macro list_for_each_entry_rcu passed 4 arguments 
> > > but takes just 3 ip_set_core.c:89:2 list_for_each_entry_rcu 
> > > undeclared
> It fixes the problems listed for jhash.h, but unfortunately not for 
> ip_set_core.c.
> 
> There don't seem to be any compat layer for list_for_each_entry_rcu in
> ipset sources.
> 
> The fourth parameter to list_for_each_entry_rcu seems to appear in
> 5.4-rc1 by this commit:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=28875945ba98d1b47a8a706812b6494d165bb0a0

The backward compatibility for list_for_each_entry_rcu() with three args 
only was missing indeed, the patch below should fix it:

diff --git a/configure.ac b/configure.ac
index 1058315..7388cdd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -746,6 +746,16 @@ else
 	AC_SUBST(HAVE_SYNCHRONIZE_RCU_BH, undef)
 fi
 
+AC_MSG_CHECKING([kernel source for the fourth arg of list_for_each_entry_rcu() in rculist.h])
+if test -f $ksourcedir/include/linux/rculist.h && \
+   $GREP -q 'define list_for_each_entry_rcu(pos, head, member, cond' $ksourcedir/include/linux/rculist.h; then
+	AC_MSG_RESULT(yes)
+	AC_SUBST(HAVE_LIST_FOR_EACH_ENTRY_RCU_FOUR_ARGS, define)
+else
+	AC_MSG_RESULT(no)
+	AC_SUBST(HAVE_LIST_FOR_EACH_ENTRY_RCU_FOUR_ARGS, 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 87e0641..0bcff2c 100644
--- a/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in
+++ b/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in
@@ -56,6 +56,7 @@
 #@HAVE_LOCKDEP_NFNL_IS_HELD@ HAVE_LOCKDEP_NFNL_IS_HELD
 #@HAVE_COND_RESCHED_RCU@ HAVE_COND_RESCHED_RCU
 #@HAVE_SKB_IIF@ HAVE_SKB_IIF
+#@HAVE_LIST_FOR_EACH_ENTRY_RCU_FOUR_ARGS@ HAVE_LIST_FOR_EACH_ENTRY_RCU_FOUR_ARGS
 
 #ifdef HAVE_EXPORT_SYMBOL_GPL_IN_MODULE_H
 #include <linux/module.h>
@@ -469,6 +470,14 @@ static inline u16 nfnl_msg_type(u8 subsys, u8 msg_type)
 #define dev_get_by_index_rcu __dev_get_by_index
 #endif
 
+#ifdef HAVE_LIST_FOR_EACH_ENTRY_RCU_FOUR_ARGS
+#define list_for_each_entry_rcu_compat(pos, head, member, cond) \
+	list_for_each_entry_rcu(pos, head, member, cond)
+#else
+#define list_for_each_entry_rcu_compat(pos, head, member, cond) \
+	list_for_each_entry_rcu(pos, head, member)
+#endif
+
 /* Compiler attributes */
 #ifndef __has_attribute
 # define __has_attribute(x) __GCC4_has_attribute_##x
diff --git a/kernel/net/netfilter/ipset/ip_set_core.c b/kernel/net/netfilter/ipset/ip_set_core.c
index fb35e23..9de8289 100644
--- a/kernel/net/netfilter/ipset/ip_set_core.c
+++ b/kernel/net/netfilter/ipset/ip_set_core.c
@@ -86,8 +86,8 @@ find_set_type(const char *name, u8 family, u8 revision)
 {
 	struct ip_set_type *type;
 
-	list_for_each_entry_rcu(type, &ip_set_type_list, list,
-				lockdep_is_held(&ip_set_type_mutex))
+	list_for_each_entry_rcu_compat(type, &ip_set_type_list, list,
+				       lockdep_is_held(&ip_set_type_mutex))
 		if (STRNCMP(type->name, name) &&
 		    (type->family == family ||
 		     type->family == NFPROTO_UNSPEC) &&

I'm going to release ipset 7.8 in the next days - 7.7 was actually not 
announced yet :-).

Best regards,
Jozsef
-
E-mail  : kadlec@xxxxxxxxxxxxxxxxx, kadlecsik.jozsef@xxxxxxxxx
PGP key : https://wigner.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics
          H-1525 Budapest 114, POB. 49, Hungary



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux