aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/proc_fs.h5
-rw-r--r--include/net/net_namespace.h12
2 files changed, 13 insertions, 4 deletions
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 59646705f15..20741f668f7 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -270,10 +270,7 @@ static inline struct net *PDE_NET(struct proc_dir_entry *pde)
return pde->parent->data;
}
-static inline struct net *PROC_NET(const struct inode *inode)
-{
- return PDE_NET(PDE(inode));
-}
+struct net *get_proc_net(const struct inode *inode);
struct proc_maps_private {
struct pid *pid;
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index 3081b6ed35f..ac8f8304094 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)
return net;
}
+static inline struct net *maybe_get_net(struct net *net)
+{
+ /* Used when we know struct net exists but we
+ * aren't guaranteed a previous reference count
+ * exists. If the reference count is zero this
+ * function fails and returns NULL.
+ */
+ if (!atomic_inc_not_zero(&net->count))
+ net = NULL;
+ return net;
+}
+
static inline void put_net(struct net *net)
{
if (atomic_dec_and_test(&net->count))