]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: port to ns_ref_*() helpers
authorChristian Brauner <brauner@kernel.org>
Thu, 18 Sep 2025 10:11:57 +0000 (12:11 +0200)
committerChristian Brauner <brauner@kernel.org>
Fri, 19 Sep 2025 14:22:38 +0000 (16:22 +0200)
Stop accessing ns.count directly.

Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Christian Brauner <brauner@kernel.org>
include/net/net_namespace.h

index fd090ceb80bf48133b4a8efe6c4f596fa17409fa..3e7c825e5810462689cb1d9d293184638e38a191 100644 (file)
@@ -270,7 +270,7 @@ static inline struct net *to_net_ns(struct ns_common *ns)
 /* Try using get_net_track() instead */
 static inline struct net *get_net(struct net *net)
 {
-       refcount_inc(&net->ns.count);
+       ns_ref_inc(net);
        return net;
 }
 
@@ -281,7 +281,7 @@ static inline struct net *maybe_get_net(struct net *net)
         * exists.  If the reference count is zero this
         * function fails and returns NULL.
         */
-       if (!refcount_inc_not_zero(&net->ns.count))
+       if (!ns_ref_get(net))
                net = NULL;
        return net;
 }
@@ -289,7 +289,7 @@ static inline struct net *maybe_get_net(struct net *net)
 /* Try using put_net_track() instead */
 static inline void put_net(struct net *net)
 {
-       if (refcount_dec_and_test(&net->ns.count))
+       if (ns_ref_put(net))
                __put_net(net);
 }
 
@@ -301,7 +301,7 @@ int net_eq(const struct net *net1, const struct net *net2)
 
 static inline int check_net(const struct net *net)
 {
-       return refcount_read(&net->ns.count) != 0;
+       return ns_ref_read(net) != 0;
 }
 
 void net_drop_ns(void *);