From: Jozsef Kadlecsik Date: Thu, 19 Dec 2024 09:54:23 +0000 (+0100) Subject: Handle "netfilter: ipset: Fix for recursive locking warning" patch for backward compa... X-Git-Tag: v7.24~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=210e4491798d6fa0e7ea4a8e74307db8809d6cfe;p=thirdparty%2Fipset.git Handle "netfilter: ipset: Fix for recursive locking warning" patch for backward compatibility Signed-off-by: Jozsef Kadlecsik --- diff --git a/configure.ac b/configure.ac index 57c65e9..e3dc662 100644 --- a/configure.ac +++ b/configure.ac @@ -909,6 +909,16 @@ else AC_SUBST(HAVE_RCUPDATE_WAIT_H, undef) fi +AC_MSG_CHECKING([kernel source for lockdep_set_class in lockdep.h]) +if test -f $ksourcedir/include/linux/lockdep.h && \ + $GREP -q 'define lockdep_set_class' $ksourcedir/include/linux/lockdep.h; then + AC_MSG_RESULT(yes) + AC_SUBST(HAVE_LOCKDEP_SET_CLASS, define) +else + AC_MSG_RESULT(no) + AC_SUBST(HAVE_LOCKDEP_SET_CLASS, 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 3a0e0b4..32a8348 100644 --- a/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in +++ b/kernel/include/linux/netfilter/ipset/ip_set_compat.h.in @@ -71,6 +71,7 @@ #@HAVE_NLMSG_UNICAST@ HAVE_NLMSG_UNICAST #@HAVE_NF_BRIDGE_GET_PYSINDEV_NET@ HAVE_NF_BRIDGE_GET_PYSINDEV_NET #@HAVE_RCUPDATE_WAIT_H@ HAVE_RCUPDATE_WAIT_H +#@HAVE_LOCKDEP_SET_CLASS@ HAVE_LOCKDEP_SET_CLASS #ifdef HAVE_EXPORT_SYMBOL_GPL_IN_MODULE_H #include diff --git a/kernel/net/netfilter/ipset/ip_set_list_set.c b/kernel/net/netfilter/ipset/ip_set_list_set.c index b286a62..0162e1d 100644 --- a/kernel/net/netfilter/ipset/ip_set_list_set.c +++ b/kernel/net/netfilter/ipset/ip_set_list_set.c @@ -615,7 +615,9 @@ init_list_set(struct net *net, struct ip_set *set, u32 size) return true; } +#ifdef HAVE_LOCKDEP_SET_CLASS static struct lock_class_key list_set_lockdep_key; +#endif static int list_set_create(struct net *net, struct ip_set *set, struct nlattr *tb[], @@ -633,7 +635,9 @@ list_set_create(struct net *net, struct ip_set *set, struct nlattr *tb[], if (size < IP_SET_LIST_MIN_SIZE) size = IP_SET_LIST_MIN_SIZE; +#ifdef HAVE_LOCKDEP_SET_CLASS lockdep_set_class(&set->lock, &list_set_lockdep_key); +#endif set->variant = &set_variant; set->dsize = ip_set_elem_len(set, tb, sizeof(struct set_elem), __alignof__(struct set_elem));