404

[ Avaa Bypassed ]




Upload:

Command:

botdev@13.59.219.20: ~ $
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Operations on the network namespace
 */
#ifndef __NET_NET_NAMESPACE_H
#define __NET_NET_NAMESPACE_H

#include <linux/atomic.h>
#include <linux/refcount.h>
#include <linux/workqueue.h>
#include <linux/list.h>
#include <linux/sysctl.h>
#include <linux/uidgid.h>

#include <net/flow.h>
#include <net/netns/core.h>
#include <net/netns/mib.h>
#include <net/netns/unix.h>
#include <net/netns/packet.h>
#include <net/netns/ipv4.h>
#include <net/netns/ipv6.h>
#include <net/netns/ieee802154_6lowpan.h>
#include <net/netns/sctp.h>
#include <net/netns/dccp.h>
#include <net/netns/netfilter.h>
#include <net/netns/x_tables.h>
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
#include <net/netns/conntrack.h>
#endif
#include <net/netns/nftables.h>
#include <net/netns/xfrm.h>
#include <net/netns/mpls.h>
#include <net/netns/can.h>
#include <linux/ns_common.h>
#include <linux/idr.h>
#include <linux/skbuff.h>

struct user_namespace;
struct proc_dir_entry;
struct net_device;
struct sock;
struct ctl_table_header;
struct net_generic;
struct sock;
struct netns_ipvs;


#define NETDEV_HASHBITS    8
#define NETDEV_HASHENTRIES (1 << NETDEV_HASHBITS)

struct net {
	refcount_t		passive;	/* To decided when the network
						 * namespace should be freed.
						 */
	atomic_t		count;		/* To decided when the network
						 *  namespace should be shut down.
						 */
	spinlock_t		rules_mod_lock;

	u32			hash_mix;
	atomic64_t		cookie_gen;

	struct list_head	list;		/* list of network namespaces */
	struct list_head	cleanup_list;	/* namespaces on death row */
	struct list_head	exit_list;	/* Use only net_mutex */

	struct user_namespace   *user_ns;	/* Owning user namespace */
	struct ucounts		*ucounts;
	spinlock_t		nsid_lock;
	struct idr		netns_ids;

	struct ns_common	ns;

	struct proc_dir_entry 	*proc_net;
	struct proc_dir_entry 	*proc_net_stat;

#ifdef CONFIG_SYSCTL
	struct ctl_table_set	sysctls;
#endif

	struct sock 		*rtnl;			/* rtnetlink socket */
	struct sock		*genl_sock;

	struct list_head 	dev_base_head;
	struct hlist_head 	*dev_name_head;
	struct hlist_head	*dev_index_head;
	unsigned int		dev_base_seq;	/* protected by rtnl_mutex */
	int			ifindex;
	unsigned int		dev_unreg_count;

	/* core fib_rules */
	struct list_head	rules_ops;

	struct list_head	fib_notifier_ops;  /* protected by net_mutex */

	struct net_device       *loopback_dev;          /* The loopback */
	struct netns_core	core;
	struct netns_mib	mib;
	struct netns_packet	packet;
	struct netns_unix	unx;
	struct netns_ipv4	ipv4;
#if IS_ENABLED(CONFIG_IPV6)
	struct netns_ipv6	ipv6;
#endif
#if IS_ENABLED(CONFIG_IEEE802154_6LOWPAN)
	struct netns_ieee802154_lowpan	ieee802154_lowpan;
#endif
#if defined(CONFIG_IP_SCTP) || defined(CONFIG_IP_SCTP_MODULE)
	struct netns_sctp	sctp;
#endif
#if defined(CONFIG_IP_DCCP) || defined(CONFIG_IP_DCCP_MODULE)
	struct netns_dccp	dccp;
#endif
#ifdef CONFIG_NETFILTER
	struct netns_nf		nf;
	struct netns_xt		xt;
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
	struct netns_ct		ct;
#endif
#if defined(CONFIG_NF_TABLES) || defined(CONFIG_NF_TABLES_MODULE)
	struct netns_nftables	nft;
#endif
#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
	struct netns_nf_frag	nf_frag;
	struct ctl_table_header *nf_frag_frags_hdr;
#endif
	struct sock		*nfnl;
	struct sock		*nfnl_stash;
#if IS_ENABLED(CONFIG_NETFILTER_NETLINK_ACCT)
	struct list_head        nfnl_acct_list;
#endif
#if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT)
	struct list_head	nfct_timeout_list;
#endif
#endif
#ifdef CONFIG_WEXT_CORE
	struct sk_buff_head	wext_nlevents;
#endif
	struct net_generic __rcu	*gen;

	/* Note : following structs are cache line aligned */
#ifdef CONFIG_XFRM
	struct netns_xfrm	xfrm;
#endif
#if IS_ENABLED(CONFIG_IP_VS)
	struct netns_ipvs	*ipvs;
#endif
#if IS_ENABLED(CONFIG_MPLS)
	struct netns_mpls	mpls;
#endif
#if IS_ENABLED(CONFIG_CAN)
	struct netns_can	can;
#endif
	struct sock		*diag_nlsk;
	atomic_t		fnhe_genid;
} __randomize_layout;

#include <linux/seq_file_net.h>

/* Init's network namespace */
extern struct net init_net;

#ifdef CONFIG_NET_NS
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);

void net_ns_barrier(void);

struct ns_common *get_net_ns(struct ns_common *ns);
#else /* CONFIG_NET_NS */
#include <linux/sched.h>
#include <linux/nsproxy.h>
static inline struct net *copy_net_ns(unsigned long flags,
	struct user_namespace *user_ns, struct net *old_net)
{
	if (flags & CLONE_NEWNET)
		return ERR_PTR(-EINVAL);
	return old_net;
}

static inline void net_ns_get_ownership(const struct net *net,
					kuid_t *uid, kgid_t *gid)
{
	*uid = GLOBAL_ROOT_UID;
	*gid = GLOBAL_ROOT_GID;
}

static inline void net_ns_barrier(void) {}

static inline struct ns_common *get_net_ns(struct ns_common *ns)
{
	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);
void ipx_unregister_sysctl(void);
#else
#define ipx_register_sysctl()
#define ipx_unregister_sysctl()
#endif

#ifdef CONFIG_NET_NS
void __put_net(struct net *net);

static inline struct net *get_net(struct net *net)
{
	atomic_inc(&net->count);
	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))
		__put_net(net);
}

static inline
int net_eq(const struct net *net1, const struct net *net2)
{
	return net1 == net2;
}

static inline int check_net(const struct net *net)
{
	return atomic_read(&net->count) != 0;
}

void net_drop_ns(void *);

#else

static inline struct net *get_net(struct net *net)
{
	return net;
}

static inline void put_net(struct net *net)
{
}

static inline struct net *maybe_get_net(struct net *net)
{
	return net;
}

static inline
int net_eq(const struct net *net1, const struct net *net2)
{
	return 1;
}

static inline int check_net(const struct net *net)
{
	return 1;
}

#define net_drop_ns NULL
#endif


typedef struct {
#ifdef CONFIG_NET_NS
	struct net *net;
#endif
} possible_net_t;

static inline void write_pnet(possible_net_t *pnet, struct net *net)
{
#ifdef CONFIG_NET_NS
	pnet->net = net;
#endif
}

static inline struct net *read_pnet(const possible_net_t *pnet)
{
#ifdef CONFIG_NET_NS
	return pnet->net;
#else
	return &init_net;
#endif
}

#define for_each_net(VAR)				\
	list_for_each_entry(VAR, &net_namespace_list, list)

#define for_each_net_rcu(VAR)				\
	list_for_each_entry_rcu(VAR, &net_namespace_list, list)

#ifdef CONFIG_NET_NS
#define __net_init
#define __net_exit
#define __net_initdata
#define __net_initconst
#else
#define __net_init	__init
#define __net_exit	__ref
#define __net_initdata	__initdata
#define __net_initconst	__initconst
#endif

int peernet2id_alloc(struct net *net, struct net *peer, gfp_t gfp);
int peernet2id(struct net *net, struct net *peer);
bool peernet_has_id(struct net *net, struct net *peer);
struct net *get_net_ns_by_id(struct net *net, int id);

struct pernet_operations {
	struct list_head list;
	int (*init)(struct net *net);
	void (*exit)(struct net *net);
	void (*exit_batch)(struct list_head *net_exit_list);
	unsigned int *id;
	size_t size;
};

/*
 * Use these carefully.  If you implement a network device and it
 * needs per network namespace operations use device pernet operations,
 * otherwise use pernet subsys operations.
 *
 * Network interfaces need to be removed from a dying netns _before_
 * subsys notifiers can be called, as most of the network code cleanup
 * (which is done from subsys notifiers) runs with the assumption that
 * dev_remove_pack has been called so no new packets will arrive during
 * and after the cleanup functions have been called.  dev_remove_pack
 * is not per namespace so instead the guarantee of no more packets
 * arriving in a network namespace is provided by ensuring that all
 * network devices and all sockets have left the network namespace
 * before the cleanup methods are called.
 *
 * For the longest time the ipv4 icmp code was registered as a pernet
 * device which caused kernel oops, and panics during network
 * namespace cleanup.   So please don't get this wrong.
 */
int register_pernet_subsys(struct pernet_operations *);
void unregister_pernet_subsys(struct pernet_operations *);
int register_pernet_device(struct pernet_operations *);
void unregister_pernet_device(struct pernet_operations *);

struct ctl_table;
struct ctl_table_header;

#ifdef CONFIG_SYSCTL
int net_sysctl_init(void);
struct ctl_table_header *register_net_sysctl(struct net *net, const char *path,
					     struct ctl_table *table);
void unregister_net_sysctl_table(struct ctl_table_header *header);
#else
static inline int net_sysctl_init(void) { return 0; }
static inline struct ctl_table_header *register_net_sysctl(struct net *net,
	const char *path, struct ctl_table *table)
{
	return NULL;
}
static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
{
}
#endif

static inline int rt_genid_ipv4(struct net *net)
{
	return atomic_read(&net->ipv4.rt_genid);
}

static inline void rt_genid_bump_ipv4(struct net *net)
{
	atomic_inc(&net->ipv4.rt_genid);
}

extern void (*__fib6_flush_trees)(struct net *net);
static inline void rt_genid_bump_ipv6(struct net *net)
{
	if (__fib6_flush_trees)
		__fib6_flush_trees(net);
}

#if IS_ENABLED(CONFIG_IEEE802154_6LOWPAN)
static inline struct netns_ieee802154_lowpan *
net_ieee802154_lowpan(struct net *net)
{
	return &net->ieee802154_lowpan;
}
#endif

/* For callers who don't really care about whether it's IPv4 or IPv6 */
static inline void rt_genid_bump_all(struct net *net)
{
	rt_genid_bump_ipv4(net);
	rt_genid_bump_ipv6(net);
}

static inline int fnhe_genid(struct net *net)
{
	return atomic_read(&net->fnhe_genid);
}

static inline void fnhe_genid_bump(struct net *net)
{
	atomic_inc(&net->fnhe_genid);
}

#endif /* __NET_NET_NAMESPACE_H */

Filemanager

Name Type Size Permission Actions
9p Folder 0755
bluetooth Folder 0755
caif Folder 0755
iucv Folder 0755
netfilter Folder 0755
netns Folder 0755
nfc Folder 0755
phonet Folder 0755
sctp Folder 0755
tc_act Folder 0755
6lowpan.h File 10.03 KB 0644
Space.h File 1.15 KB 0644
act_api.h File 6.38 KB 0644
addrconf.h File 12.63 KB 0644
af_ieee802154.h File 1.55 KB 0644
af_rxrpc.h File 2.79 KB 0644
af_unix.h File 2.22 KB 0644
af_vsock.h File 7.21 KB 0644
ah.h File 382 B 0644
arp.h File 2 KB 0644
atmclip.h File 1.48 KB 0644
ax25.h File 15.02 KB 0644
ax88796.h File 998 B 0644
bond_3ad.h File 9.79 KB 0644
bond_alb.h File 6.6 KB 0644
bond_options.h File 3.92 KB 0644
bonding.h File 19.1 KB 0644
busy_poll.h File 3.8 KB 0644
calipso.h File 2.15 KB 0644
cfg80211-wext.h File 1.95 KB 0644
cfg80211.h File 221.24 KB 0644
cfg802154.h File 10.89 KB 0644
checksum.h File 4.76 KB 0644
cipso_ipv4.h File 8.2 KB 0644
cls_cgroup.h File 2.15 KB 0644
codel.h File 5.65 KB 0644
codel_impl.h File 7.98 KB 0644
codel_qdisc.h File 2.9 KB 0644
compat.h File 2.11 KB 0644
datalink.h File 619 B 0644
dcbevent.h File 1.26 KB 0644
dcbnl.h File 4.2 KB 0644
devlink.h File 13.25 KB 0644
dn.h File 6.88 KB 0644
dn_dev.h File 5.36 KB 0644
dn_fib.h File 3.98 KB 0644
dn_neigh.h File 968 B 0644
dn_nsp.h File 5.83 KB 0644
dn_route.h File 4.36 KB 0644
dsa.h File 13.94 KB 0644
dsfield.h File 1.11 KB 0644
dst.h File 13.48 KB 0644
dst_cache.h File 2.53 KB 0644
dst_metadata.h File 5.39 KB 0644
dst_ops.h File 2 KB 0644
erspan.h File 2.11 KB 0644
esp.h File 877 B 0644
ethoc.h File 538 B 0644
fib_notifier.h File 1.29 KB 0644
fib_rules.h File 4.18 KB 0644
firewire.h File 636 B 0644
flow.h File 6.16 KB 0644
flow_dissector.h File 7.55 KB 0644
fou.h File 549 B 0644
fq.h File 2.67 KB 0644
fq_impl.h File 6.9 KB 0644
garp.h File 2.62 KB 0644
gen_stats.h File 2.34 KB 0644
genetlink.h File 11.3 KB 0644
geneve.h File 1.67 KB 0644
gre.h File 2.99 KB 0644
gro_cells.h File 443 B 0644
gtp.h File 633 B 0644
gue.h File 3.23 KB 0644
hwbm.h File 937 B 0644
icmp.h File 2.01 KB 0644
ieee80211_radiotap.h File 6.63 KB 0644
ieee802154_netdev.h File 9.14 KB 0644
if_inet6.h File 6.13 KB 0644
ife.h File 1.06 KB 0644
ila.h File 498 B 0644
inet6_connection_sock.h File 976 B 0644
inet6_hashtables.h File 3.7 KB 0644
inet_common.h File 1.89 KB 0644
inet_connection_sock.h File 10.48 KB 0644
inet_ecn.h File 6.02 KB 0644
inet_frag.h File 4.51 KB 0644
inet_hashtables.h File 12.91 KB 0644
inet_sock.h File 8.25 KB 0644
inet_timewait_sock.h File 3.82 KB 0644
inetpeer.h File 3.29 KB 0644
ip.h File 18.51 KB 0644
ip6_checksum.h File 2.89 KB 0644
ip6_fib.h File 10.04 KB 0644
ip6_route.h File 7.63 KB 0644
ip6_tunnel.h File 4.72 KB 0644
ip_fib.h File 10.72 KB 0644
ip_tunnels.h File 13.61 KB 0644
ip_vs.h File 46.78 KB 0644
ipcomp.h File 659 B 0644
ipconfig.h File 811 B 0644
ipv6.h File 29.97 KB 0644
ipv6_frag.h File 2.54 KB 0644
ipx.h File 4.4 KB 0644
iw_handler.h File 20.91 KB 0644
kcm.h File 4.96 KB 0644
l3mdev.h File 5.86 KB 0644
lapb.h File 4.75 KB 0644
lib80211.h File 3.92 KB 0644
llc.h File 4.41 KB 0644
llc_c_ac.h File 9.31 KB 0644
llc_c_ev.h File 10.68 KB 0644
llc_c_st.h File 1.72 KB 0644
llc_conn.h File 4.06 KB 0644
llc_if.h File 2.16 KB 0644
llc_pdu.h File 14.44 KB 0644
llc_s_ac.h File 1.55 KB 0644
llc_s_ev.h File 2.2 KB 0644
llc_s_st.h File 947 B 0644
llc_sap.h File 1.08 KB 0644
lwtunnel.h File 5.84 KB 0644
mac80211.h File 230.36 KB 0644
mac802154.h File 15.27 KB 0644
mip6.h File 1.58 KB 0644
mld.h File 2.8 KB 0644
mpls.h File 932 B 0644
mpls_iptunnel.h File 827 B 0644
mrp.h File 3.03 KB 0644
ncsi.h File 1.92 KB 0644
ndisc.h File 13.77 KB 0644
neighbour.h File 15.06 KB 0644
net_namespace.h File 10.08 KB 0644
net_ratelimit.h File 220 B 0644
netevent.h File 910 B 0644
netlabel.h File 20.74 KB 0644
netlink.h File 40.39 KB 0644
netprio_cgroup.h File 1.24 KB 0644
netrom.h File 7.68 KB 0644
nexthop.h File 865 B 0644
nl802154.h File 12.09 KB 0644
nsh.h File 12.31 KB 0644
p8022.h File 447 B 0644
ping.h File 3.45 KB 0644
pkt_cls.h File 17.34 KB 0644
pkt_sched.h File 4.05 KB 0644
pptp.h File 557 B 0644
protocol.h File 4.08 KB 0644
psample.h File 860 B 0644
psnap.h File 351 B 0644
raw.h File 2.07 KB 0644
rawv6.h File 854 B 0644
red.h File 10.45 KB 0644
regulatory.h File 10.12 KB 0644
request_sock.h File 6.46 KB 0644
rose.h File 7.62 KB 0644
route.h File 10.02 KB 0644
rtnetlink.h File 6.13 KB 0644
sch_generic.h File 23.3 KB 0644
scm.h File 3.5 KB 0644
secure_seq.h File 855 B 0644
seg6.h File 1.66 KB 0644
seg6_hmac.h File 1.65 KB 0644
slhc_vj.h File 6.67 KB 0644
smc.h File 440 B 0644
snmp.h File 5.23 KB 0644
sock.h File 69.75 KB 0644
sock_reuseport.h File 863 B 0644
stp.h File 383 B 0644
strparser.h File 3.75 KB 0644
switchdev.h File 6.52 KB 0644
tcp.h File 62.8 KB 0644
tcp_states.h File 1.26 KB 0644
timewait_sock.h File 1.11 KB 0644
tipc.h File 2.34 KB 0644
tls.h File 7.12 KB 0644
transp_v6.h File 2.08 KB 0644
tso.h File 515 B 0644
tun_proto.h File 988 B 0644
udp.h File 12.82 KB 0644
udp_tunnel.h File 5.12 KB 0644
udplite.h File 3.83 KB 0644
vsock_addr.h File 1.05 KB 0644
vxlan.h File 10.43 KB 0644
wext.h File 1.51 KB 0644
wimax.h File 19.97 KB 0644
x25.h File 9.43 KB 0644
x25device.h File 387 B 0644
xfrm.h File 53.72 KB 0644