Skip to content

Commit e34492d

Browse files
changbindudavem330
authored andcommitted
net: inline function get_net_ns_by_fd if NET_NS is disabled
The function get_net_ns_by_fd() could be inlined when NET_NS is not enabled. Signed-off-by: Changbin Du <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 475b92f commit e34492d

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

include/net/net_namespace.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ void net_ns_get_ownership(const struct net *net, kuid_t *uid, kgid_t *gid);
186186
void net_ns_barrier(void);
187187

188188
struct ns_common *get_net_ns(struct ns_common *ns);
189+
struct net *get_net_ns_by_fd(int fd);
189190
#else /* CONFIG_NET_NS */
190191
#include <linux/sched.h>
191192
#include <linux/nsproxy.h>
@@ -210,13 +211,17 @@ static inline struct ns_common *get_net_ns(struct ns_common *ns)
210211
{
211212
return ERR_PTR(-EINVAL);
212213
}
214+
215+
static inline struct net *get_net_ns_by_fd(int fd)
216+
{
217+
return ERR_PTR(-EINVAL);
218+
}
213219
#endif /* CONFIG_NET_NS */
214220

215221

216222
extern struct list_head net_namespace_list;
217223

218224
struct net *get_net_ns_by_pid(pid_t pid);
219-
struct net *get_net_ns_by_fd(int fd);
220225

221226
#ifdef CONFIG_SYSCTL
222227
void ipx_register_sysctl(void);

net/core/net_namespace.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -672,14 +672,8 @@ struct net *get_net_ns_by_fd(int fd)
672672
fput(file);
673673
return net;
674674
}
675-
676-
#else
677-
struct net *get_net_ns_by_fd(int fd)
678-
{
679-
return ERR_PTR(-EINVAL);
680-
}
681-
#endif
682675
EXPORT_SYMBOL_GPL(get_net_ns_by_fd);
676+
#endif
683677

684678
struct net *get_net_ns_by_pid(pid_t pid)
685679
{

0 commit comments

Comments
 (0)