aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/net_namespace.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/net_namespace.h')
-rw-r--r--include/net/net_namespace.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 3081b6ed35fe..ac8f8304094e 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -46,6 +46,18 @@ static inline struct net *get_net(struct net *net)
46 return net; 46 return net;
47} 47}
48 48
49static inline struct net *maybe_get_net(struct net *net)
50{
51 /* Used when we know struct net exists but we
52 * aren't guaranteed a previous reference count
53 * exists. If the reference count is zero this
54 * function fails and returns NULL.
55 */
56 if (!atomic_inc_not_zero(&net->count))
57 net = NULL;
58 return net;
59}
60
49static inline void put_net(struct net *net) 61static inline void put_net(struct net *net)
50{ 62{
51 if (atomic_dec_and_test(&net->count)) 63 if (atomic_dec_and_test(&net->count))