]> git.ipfire.org Git - thirdparty/ipset.git/commitdiff
Correct workaround in patch "Fix calling ip_set() macro at dumping"
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Tue, 30 Oct 2018 21:30:30 +0000 (22:30 +0100)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Tue, 30 Oct 2018 21:30:30 +0000 (22:30 +0100)
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

index e99dda987ec41d3159ef995eeb98135d60e2d928..c2e32eeb7a1343758268707e3c14c28d1a1527fb 100644 (file)
@@ -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);