From 7d6e460d9373bc8614b7e33da5b720503d803cb5 Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Tue, 30 Oct 2018 22:30:30 +0100 Subject: Correct workaround in patch "Fix calling ip_set() macro at dumping" As Pablo pointed out, in order to fix the bogus warnings, there's no need for the non-useful rcu_read_lock/unlock dancing. Call rcu_dereference_raw() instead, the ref_netlink protects the set. --- kernel/net/netfilter/ipset/ip_set_core.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'kernel') diff --git a/kernel/net/netfilter/ipset/ip_set_core.c b/kernel/net/netfilter/ipset/ip_set_core.c index e99dda9..c2e32ee 100644 --- a/kernel/net/netfilter/ipset/ip_set_core.c +++ b/kernel/net/netfilter/ipset/ip_set_core.c @@ -62,19 +62,8 @@ MODULE_ALIAS_NFNL_SUBSYS(NFNL_SUBSYS_IPSET); lockdep_is_held(&ip_set_ref_lock)) #define ip_set(inst, id) \ ip_set_dereference((inst)->ip_set_list)[id] - -/* When the nfnl mutex is not held (dumping): */ -static inline -struct ip_set * ip_set_no_mutex(struct ip_set_net *inst, ip_set_id_t id) -{ - struct ip_set *set; - - rcu_read_lock(); - set = rcu_dereference((inst)->ip_set_list)[id]; - rcu_read_unlock(); - - return set; -} +#define ip_set_ref_netlink(inst,id) \ + rcu_dereference_raw((inst)->ip_set_list)[id] /* The set types are implemented in modules and registered set types * can be found in ip_set_type_list. Adding/deleting types is @@ -1283,7 +1272,7 @@ ip_set_dump_done(struct netlink_callback *cb) struct ip_set_net *inst = (struct ip_set_net *)cb->args[IPSET_CB_NET]; ip_set_id_t index = (ip_set_id_t)cb->args[IPSET_CB_INDEX]; - struct ip_set *set = ip_set_no_mutex(inst, index); + struct ip_set *set = ip_set_ref_netlink(inst, index); if (set->variant->uref) set->variant->uref(set, cb, false); @@ -1477,7 +1466,7 @@ next_set: release_refcount: /* If there was an error or set is done, release set */ if (ret || !cb->args[IPSET_CB_ARG0]) { - set = ip_set_no_mutex(inst, index); + set = ip_set_ref_netlink(inst, index); if (set->variant->uref) set->variant->uref(set, cb, false); pr_debug("release set %s\n", set->name); -- cgit v1.2.3