#define pr_fmt(fmt) …
#include <linux/workqueue.h>
#include <linux/rtnetlink.h>
#include <linux/cache.h>
#include <linux/slab.h>
#include <linux/list.h>
#include <linux/delay.h>
#include <linux/sched.h>
#include <linux/idr.h>
#include <linux/rculist.h>
#include <linux/nsproxy.h>
#include <linux/fs.h>
#include <linux/proc_ns.h>
#include <linux/file.h>
#include <linux/export.h>
#include <linux/user_namespace.h>
#include <linux/net_namespace.h>
#include <linux/sched/task.h>
#include <linux/uidgid.h>
#include <linux/cookie.h>
#include <linux/proc_fs.h>
#include <net/sock.h>
#include <net/netlink.h>
#include <net/net_namespace.h>
#include <net/netns/generic.h>
static LIST_HEAD(pernet_list);
static struct list_head *first_device = …;
LIST_HEAD(…);
EXPORT_SYMBOL_GPL(…);
DECLARE_RWSEM(…) …;
EXPORT_SYMBOL_GPL(…);
#ifdef CONFIG_KEYS
static struct key_tag init_net_key_domain = …;
#endif
struct net init_net;
EXPORT_SYMBOL(…);
static bool init_net_initialized;
DECLARE_RWSEM(…) …;
EXPORT_SYMBOL_GPL(…);
#define MIN_PERNET_OPS_ID …
#define INITIAL_NET_GEN_PTRS …
static unsigned int max_gen_ptrs = …;
DEFINE_COOKIE(…);
static struct net_generic *net_alloc_generic(void)
{ … }
static int net_assign_generic(struct net *net, unsigned int id, void *data)
{ … }
static int ops_init(const struct pernet_operations *ops, struct net *net)
{ … }
static void ops_pre_exit_list(const struct pernet_operations *ops,
struct list_head *net_exit_list)
{ … }
static void ops_exit_list(const struct pernet_operations *ops,
struct list_head *net_exit_list)
{ … }
static void ops_free_list(const struct pernet_operations *ops,
struct list_head *net_exit_list)
{ … }
static int alloc_netid(struct net *net, struct net *peer, int reqid)
{ … }
#define NET_ID_ZERO …
static int net_eq_idr(int id, void *net, void *peer)
{ … }
static int __peernet2id(const struct net *net, struct net *peer)
{ … }
static void rtnl_net_notifyid(struct net *net, int cmd, int id, u32 portid,
struct nlmsghdr *nlh, gfp_t gfp);
int peernet2id_alloc(struct net *net, struct net *peer, gfp_t gfp)
{ … }
EXPORT_SYMBOL_GPL(…);
int peernet2id(const struct net *net, struct net *peer)
{ … }
EXPORT_SYMBOL(…);
bool peernet_has_id(const struct net *net, struct net *peer)
{ … }
struct net *get_net_ns_by_id(const struct net *net, int id)
{ … }
EXPORT_SYMBOL_GPL(…);
static __net_init void preinit_net(struct net *net)
{ … }
static __net_init int setup_net(struct net *net, struct user_namespace *user_ns)
{ … }
static int __net_init net_defaults_init_net(struct net *net)
{ … }
static struct pernet_operations net_defaults_ops = …;
static __init int net_defaults_init(void)
{ … }
core_initcall(net_defaults_init);
#ifdef CONFIG_NET_NS
static struct ucounts *inc_net_namespaces(struct user_namespace *ns)
{ … }
static void dec_net_namespaces(struct ucounts *ucounts)
{ … }
static struct kmem_cache *net_cachep __ro_after_init;
static struct workqueue_struct *netns_wq;
static struct net *net_alloc(void)
{ … }
static void net_free(struct net *net)
{ … }
void net_drop_ns(void *p)
{ … }
struct net *copy_net_ns(unsigned long flags,
struct user_namespace *user_ns, struct net *old_net)
{ … }
void net_ns_get_ownership(const struct net *net, kuid_t *uid, kgid_t *gid)
{ … }
EXPORT_SYMBOL_GPL(…);
static void unhash_nsid(struct net *net, struct net *last)
{ … }
static LLIST_HEAD(cleanup_list);
static void cleanup_net(struct work_struct *work)
{ … }
void net_ns_barrier(void)
{ … }
EXPORT_SYMBOL(…);
static DECLARE_WORK(net_cleanup_work, cleanup_net);
void __put_net(struct net *net)
{ … }
EXPORT_SYMBOL_GPL(…);
struct ns_common *get_net_ns(struct ns_common *ns)
{ … }
EXPORT_SYMBOL_GPL(…);
struct net *get_net_ns_by_fd(int fd)
{ … }
EXPORT_SYMBOL_GPL(…);
#endif
struct net *get_net_ns_by_pid(pid_t pid)
{ … }
EXPORT_SYMBOL_GPL(…);
static __net_init int net_ns_net_init(struct net *net)
{ … }
static __net_exit void net_ns_net_exit(struct net *net)
{ … }
static struct pernet_operations __net_initdata net_ns_ops = …;
static const struct nla_policy rtnl_net_policy[NETNSA_MAX + 1] = …;
static int rtnl_net_newid(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{ … }
static int rtnl_net_get_size(void)
{ … }
struct net_fill_args { … };
static int rtnl_net_fill(struct sk_buff *skb, struct net_fill_args *args)
{ … }
static int rtnl_net_valid_getid_req(struct sk_buff *skb,
const struct nlmsghdr *nlh,
struct nlattr **tb,
struct netlink_ext_ack *extack)
{ … }
static int rtnl_net_getid(struct sk_buff *skb, struct nlmsghdr *nlh,
struct netlink_ext_ack *extack)
{ … }
struct rtnl_net_dump_cb { … };
static int rtnl_net_dumpid_one(int id, void *peer, void *data)
{ … }
static int rtnl_valid_dump_net_req(const struct nlmsghdr *nlh, struct sock *sk,
struct rtnl_net_dump_cb *net_cb,
struct netlink_callback *cb)
{ … }
static int rtnl_net_dumpid(struct sk_buff *skb, struct netlink_callback *cb)
{ … }
static void rtnl_net_notifyid(struct net *net, int cmd, int id, u32 portid,
struct nlmsghdr *nlh, gfp_t gfp)
{ … }
#ifdef CONFIG_NET_NS
static void __init netns_ipv4_struct_check(void)
{ … }
#endif
void __init net_ns_init(void)
{ … }
static void free_exit_list(struct pernet_operations *ops, struct list_head *net_exit_list)
{ … }
#ifdef CONFIG_NET_NS
static int __register_pernet_operations(struct list_head *list,
struct pernet_operations *ops)
{ … }
static void __unregister_pernet_operations(struct pernet_operations *ops)
{ … }
#else
static int __register_pernet_operations(struct list_head *list,
struct pernet_operations *ops)
{
if (!init_net_initialized) {
list_add_tail(&ops->list, list);
return 0;
}
return ops_init(ops, &init_net);
}
static void __unregister_pernet_operations(struct pernet_operations *ops)
{
if (!init_net_initialized) {
list_del(&ops->list);
} else {
LIST_HEAD(net_exit_list);
list_add(&init_net.exit_list, &net_exit_list);
free_exit_list(ops, &net_exit_list);
}
}
#endif
static DEFINE_IDA(net_generic_ids);
static int register_pernet_operations(struct list_head *list,
struct pernet_operations *ops)
{ … }
static void unregister_pernet_operations(struct pernet_operations *ops)
{ … }
int register_pernet_subsys(struct pernet_operations *ops)
{ … }
EXPORT_SYMBOL_GPL(…);
void unregister_pernet_subsys(struct pernet_operations *ops)
{ … }
EXPORT_SYMBOL_GPL(…);
int register_pernet_device(struct pernet_operations *ops)
{ … }
EXPORT_SYMBOL_GPL(…);
void unregister_pernet_device(struct pernet_operations *ops)
{ … }
EXPORT_SYMBOL_GPL(…);
#ifdef CONFIG_NET_NS
static struct ns_common *netns_get(struct task_struct *task)
{ … }
static inline struct net *to_net_ns(struct ns_common *ns)
{ … }
static void netns_put(struct ns_common *ns)
{ … }
static int netns_install(struct nsset *nsset, struct ns_common *ns)
{ … }
static struct user_namespace *netns_owner(struct ns_common *ns)
{ … }
const struct proc_ns_operations netns_operations = …;
#endif