diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/proc_fs.h | 5 | ||||
-rw-r--r-- | include/net/net_namespace.h | 12 |
2 files changed, 13 insertions, 4 deletions
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h index 59646705f151..20741f668f7b 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) | |||
270 | return pde->parent->data; | 270 | return pde->parent->data; |
271 | } | 271 | } |
272 | 272 | ||
273 | static inline struct net *PROC_NET(const struct inode *inode) | 273 | struct net *get_proc_net(const struct inode *inode); |
274 | { | ||
275 | return PDE_NET(PDE(inode)); | ||
276 | } | ||
277 | 274 | ||
278 | struct proc_maps_private { | 275 | struct proc_maps_private { |
279 | struct pid *pid; | 276 | struct pid *pid; |
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 | ||
49 | static 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 | |||
49 | static inline void put_net(struct net *net) | 61 | static 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)) |