Skip to content

Commit

Permalink
net: inline function get_net_ns_by_fd if NET_NS is disabled
Browse files Browse the repository at this point in the history
The function get_net_ns_by_fd() could be inlined when NET_NS is not
enabled.

Signed-off-by: Changbin Du <changbin.du@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Changbin Du authored and David S. Miller committed Jun 15, 2021
1 parent 475b92f commit e34492d
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 6 additions & 1 deletion include/net/net_namespace.h
Original file line number Diff line number Diff line change
@@ -186,6 +186,7 @@ void net_ns_get_ownership(const struct net *net, kuid_t *uid, kgid_t *gid);
void net_ns_barrier(void);

struct ns_common *get_net_ns(struct ns_common *ns);
struct net *get_net_ns_by_fd(int fd);
#else /* CONFIG_NET_NS */
#include <linux/sched.h>
#include <linux/nsproxy.h>
@@ -210,13 +211,17 @@ static inline struct ns_common *get_net_ns(struct ns_common *ns)
{
return ERR_PTR(-EINVAL);
}

static inline struct net *get_net_ns_by_fd(int fd)
{
return ERR_PTR(-EINVAL);
}
#endif /* CONFIG_NET_NS */


extern struct list_head net_namespace_list;

struct net *get_net_ns_by_pid(pid_t pid);
struct net *get_net_ns_by_fd(int fd);

#ifdef CONFIG_SYSCTL
void ipx_register_sysctl(void);
8 changes: 1 addition & 7 deletions net/core/net_namespace.c
Original file line number Diff line number Diff line change
@@ -672,14 +672,8 @@ struct net *get_net_ns_by_fd(int fd)
fput(file);
return net;
}

#else
struct net *get_net_ns_by_fd(int fd)
{
return ERR_PTR(-EINVAL);
}
#endif
EXPORT_SYMBOL_GPL(get_net_ns_by_fd);
#endif

struct net *get_net_ns_by_pid(pid_t pid)
{

0 comments on commit e34492d

Please sign in to comment.