1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 25f256becSEric W. Biederman /* 35f256becSEric W. Biederman * Operations on the network namespace 45f256becSEric W. Biederman */ 55f256becSEric W. Biederman #ifndef __NET_NET_NAMESPACE_H 65f256becSEric W. Biederman #define __NET_NET_NAMESPACE_H 75f256becSEric W. Biederman 860063497SArun Sharma #include <linux/atomic.h> 9c122e14dSReshetova, Elena #include <linux/refcount.h> 105f256becSEric W. Biederman #include <linux/workqueue.h> 115f256becSEric W. Biederman #include <linux/list.h> 12bee95250SDavid S. Miller #include <linux/sysctl.h> 135f256becSEric W. Biederman 146a662719SCong Wang #include <net/flow.h> 158efa6e93SPavel Emelyanov #include <net/netns/core.h> 16852566f5SPavel Emelyanov #include <net/netns/mib.h> 17a0a53c8bSDenis V. Lunev #include <net/netns/unix.h> 182aaef4e4SDenis V. Lunev #include <net/netns/packet.h> 198afd351cSPavel Emelyanov #include <net/netns/ipv4.h> 20b0f159dbSDaniel Lezcano #include <net/netns/ipv6.h> 21633fc86fSAlexander Aring #include <net/netns/ieee802154_6lowpan.h> 224db67e80SEric W. Biederman #include <net/netns/sctp.h> 2367019cc9SPavel Emelyanov #include <net/netns/dccp.h> 24f3c1a44aSGao feng #include <net/netns/netfilter.h> 258d870052SAlexey Dobriyan #include <net/netns/x_tables.h> 26dfdb8d79SAlexey Dobriyan #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 27dfdb8d79SAlexey Dobriyan #include <net/netns/conntrack.h> 28dfdb8d79SAlexey Dobriyan #endif 2999633ab2SPablo Neira Ayuso #include <net/netns/nftables.h> 30d62ddc21SAlexey Dobriyan #include <net/netns/xfrm.h> 310189197fSEric W. Biederman #include <net/netns/mpls.h> 328e8cda6dSMario Kicherer #include <net/netns/can.h> 33435d5f4bSAl Viro #include <linux/ns_common.h> 3404c52decSPablo Neira Ayuso #include <linux/idr.h> 3504c52decSPablo Neira Ayuso #include <linux/skbuff.h> 36a0a53c8bSDenis V. Lunev 37038e7332SEric W. Biederman struct user_namespace; 38457c4cbcSEric W. Biederman struct proc_dir_entry; 392774c7abSEric W. Biederman struct net_device; 4097c53cacSDenis V. Lunev struct sock; 411597fbc0SPavel Emelyanov struct ctl_table_header; 42dec827d1SPavel Emelyanov struct net_generic; 4394e5e308SChristian Brauner struct uevent_sock; 442553d064SJulian Anastasov struct netns_ipvs; 451597fbc0SPavel Emelyanov 467c28bd0bSEric Dumazet 477c28bd0bSEric Dumazet #define NETDEV_HASHBITS 8 487c28bd0bSEric Dumazet #define NETDEV_HASHENTRIES (1 << NETDEV_HASHBITS) 497c28bd0bSEric Dumazet 505f256becSEric W. Biederman struct net { 51c122e14dSReshetova, Elena refcount_t passive; /* To decided when the network 525f256becSEric W. Biederman * namespace should be freed. 535f256becSEric W. Biederman */ 54273c28bcSKirill Tkhai refcount_t count; /* To decided when the network 55a685e089SAl Viro * namespace should be shut down. 56a685e089SAl Viro */ 578e602ce2SEric Dumazet spinlock_t rules_mod_lock; 588e602ce2SEric Dumazet 5933cf7c90SEric Dumazet atomic64_t cookie_gen; 6033cf7c90SEric Dumazet 615f256becSEric W. Biederman struct list_head list; /* list of network namespaces */ 6219efbd93SKirill Tkhai struct list_head exit_list; /* To linked to call pernet exit 634420bf21SKirill Tkhai * methods on dead net ( 644420bf21SKirill Tkhai * pernet_ops_rwsem read locked), 654420bf21SKirill Tkhai * or to unregister pernet ops 664420bf21SKirill Tkhai * (pernet_ops_rwsem write locked). 6719efbd93SKirill Tkhai */ 6865b7b5b9SKirill Tkhai struct llist_node cleanup_list; /* namespaces on death row */ 6965b7b5b9SKirill Tkhai 70038e7332SEric W. Biederman struct user_namespace *user_ns; /* Owning user namespace */ 7170328660SEric W. Biederman struct ucounts *ucounts; 72de133464SWANG Cong spinlock_t nsid_lock; 730c7aecd4SNicolas Dichtel struct idr netns_ids; 74038e7332SEric W. Biederman 75435d5f4bSAl Viro struct ns_common ns; 7698f842e6SEric W. Biederman 77457c4cbcSEric W. Biederman struct proc_dir_entry *proc_net; 78457c4cbcSEric W. Biederman struct proc_dir_entry *proc_net_stat; 79881d966bSEric W. Biederman 8073455092SAl Viro #ifdef CONFIG_SYSCTL 8173455092SAl Viro struct ctl_table_set sysctls; 8273455092SAl Viro #endif 8395bdfccbSEric W. Biederman 848e602ce2SEric Dumazet struct sock *rtnl; /* rtnetlink socket */ 858e602ce2SEric Dumazet struct sock *genl_sock; 862774c7abSEric W. Biederman 8794e5e308SChristian Brauner struct uevent_sock *uevent_sock; /* uevent socket */ 8894e5e308SChristian Brauner 89881d966bSEric W. Biederman struct list_head dev_base_head; 90881d966bSEric W. Biederman struct hlist_head *dev_name_head; 91881d966bSEric W. Biederman struct hlist_head *dev_index_head; 924e985adaSThomas Graf unsigned int dev_base_seq; /* protected by rtnl_mutex */ 93aa79e66eSPavel Emelyanov int ifindex; 9450624c93SEric W. Biederman unsigned int dev_unreg_count; 9597c53cacSDenis V. Lunev 965fd30ee7SDenis V. Lunev /* core fib_rules */ 975fd30ee7SDenis V. Lunev struct list_head rules_ops; 985fd30ee7SDenis V. Lunev 994420bf21SKirill Tkhai struct list_head fib_notifier_ops; /* Populated by 1004420bf21SKirill Tkhai * register_pernet_subsys() 1014420bf21SKirill Tkhai */ 1028e602ce2SEric Dumazet struct net_device *loopback_dev; /* The loopback */ 1038efa6e93SPavel Emelyanov struct netns_core core; 104852566f5SPavel Emelyanov struct netns_mib mib; 1052aaef4e4SDenis V. Lunev struct netns_packet packet; 106a0a53c8bSDenis V. Lunev struct netns_unix unx; 1078afd351cSPavel Emelyanov struct netns_ipv4 ipv4; 108dfd56b8bSEric Dumazet #if IS_ENABLED(CONFIG_IPV6) 109b0f159dbSDaniel Lezcano struct netns_ipv6 ipv6; 110b0f159dbSDaniel Lezcano #endif 111633fc86fSAlexander Aring #if IS_ENABLED(CONFIG_IEEE802154_6LOWPAN) 112633fc86fSAlexander Aring struct netns_ieee802154_lowpan ieee802154_lowpan; 113633fc86fSAlexander Aring #endif 1144db67e80SEric W. Biederman #if defined(CONFIG_IP_SCTP) || defined(CONFIG_IP_SCTP_MODULE) 1154db67e80SEric W. Biederman struct netns_sctp sctp; 1164db67e80SEric W. Biederman #endif 11767019cc9SPavel Emelyanov #if defined(CONFIG_IP_DCCP) || defined(CONFIG_IP_DCCP_MODULE) 11867019cc9SPavel Emelyanov struct netns_dccp dccp; 11967019cc9SPavel Emelyanov #endif 1208d870052SAlexey Dobriyan #ifdef CONFIG_NETFILTER 121f3c1a44aSGao feng struct netns_nf nf; 1228d870052SAlexey Dobriyan struct netns_xt xt; 123dfdb8d79SAlexey Dobriyan #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) 124dfdb8d79SAlexey Dobriyan struct netns_ct ct; 125dfdb8d79SAlexey Dobriyan #endif 12699633ab2SPablo Neira Ayuso #if defined(CONFIG_NF_TABLES) || defined(CONFIG_NF_TABLES_MODULE) 12799633ab2SPablo Neira Ayuso struct netns_nftables nft; 12899633ab2SPablo Neira Ayuso #endif 129c038a767SAmerigo Wang #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6) 130c038a767SAmerigo Wang struct netns_nf_frag nf_frag; 131c038a767SAmerigo Wang #endif 132cd8c20b6SAlexey Dobriyan struct sock *nfnl; 133cd8c20b6SAlexey Dobriyan struct sock *nfnl_stash; 1343499abb2SAndreas Schultz #if IS_ENABLED(CONFIG_NETFILTER_NETLINK_ACCT) 1353499abb2SAndreas Schultz struct list_head nfnl_acct_list; 1363499abb2SAndreas Schultz #endif 13719576c94SPablo Neira #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) 13819576c94SPablo Neira struct list_head nfct_timeout_list; 13919576c94SPablo Neira #endif 1408d870052SAlexey Dobriyan #endif 1413d23e349SJohannes Berg #ifdef CONFIG_WEXT_CORE 142b333b3d2SJohannes Berg struct sk_buff_head wext_nlevents; 143b333b3d2SJohannes Berg #endif 1441c87733dSEric Dumazet struct net_generic __rcu *gen; 1458e602ce2SEric Dumazet 1468e602ce2SEric Dumazet /* Note : following structs are cache line aligned */ 1478e602ce2SEric Dumazet #ifdef CONFIG_XFRM 1488e602ce2SEric Dumazet struct netns_xfrm xfrm; 1498e602ce2SEric Dumazet #endif 1508b4d14d8SJunweiZhang #if IS_ENABLED(CONFIG_IP_VS) 15161b1ab45SHans Schillstrom struct netns_ipvs *ipvs; 1528b4d14d8SJunweiZhang #endif 1530189197fSEric W. Biederman #if IS_ENABLED(CONFIG_MPLS) 1540189197fSEric W. Biederman struct netns_mpls mpls; 1550189197fSEric W. Biederman #endif 1568e8cda6dSMario Kicherer #if IS_ENABLED(CONFIG_CAN) 1578e8cda6dSMario Kicherer struct netns_can can; 1588e8cda6dSMario Kicherer #endif 15951d7cccfSAndrey Vagin struct sock *diag_nlsk; 1605aad1de5STimo Teräs atomic_t fnhe_genid; 1613859a271SKees Cook } __randomize_layout; 1625f256becSEric W. Biederman 163c0f39322SDenis V. Lunev #include <linux/seq_file_net.h> 164c0f39322SDenis V. Lunev 1654fabcd71SDaniel Lezcano /* Init's network namespace */ 1665f256becSEric W. Biederman extern struct net init_net; 167a4aa834aSDenis V. Lunev 168d727abcbSEric W. Biederman #ifdef CONFIG_NET_NS 169e67e16eaSJoe Perches struct net *copy_net_ns(unsigned long flags, struct user_namespace *user_ns, 170e67e16eaSJoe Perches struct net *old_net); 171225c0a01SDenis V. Lunev 1727866cc57SFlorian Westphal void net_ns_barrier(void); 173d727abcbSEric W. Biederman #else /* CONFIG_NET_NS */ 174d727abcbSEric W. Biederman #include <linux/sched.h> 175d727abcbSEric W. Biederman #include <linux/nsproxy.h> 176038e7332SEric W. Biederman static inline struct net *copy_net_ns(unsigned long flags, 177038e7332SEric W. Biederman struct user_namespace *user_ns, struct net *old_net) 1789dd776b6SEric W. Biederman { 179d727abcbSEric W. Biederman if (flags & CLONE_NEWNET) 180d727abcbSEric W. Biederman return ERR_PTR(-EINVAL); 181d727abcbSEric W. Biederman return old_net; 1829dd776b6SEric W. Biederman } 1837866cc57SFlorian Westphal 1847866cc57SFlorian Westphal static inline void net_ns_barrier(void) {} 185d727abcbSEric W. Biederman #endif /* CONFIG_NET_NS */ 186225c0a01SDenis V. Lunev 187225c0a01SDenis V. Lunev 188225c0a01SDenis V. Lunev extern struct list_head net_namespace_list; 1899dd776b6SEric W. Biederman 190e67e16eaSJoe Perches struct net *get_net_ns_by_pid(pid_t pid); 1910f5258cdSStefan Hajnoczi struct net *get_net_ns_by_fd(int fd); 19230ffee84SJohannes Berg 193535d3ae9SRashika Kheria #ifdef CONFIG_SYSCTL 194535d3ae9SRashika Kheria void ipx_register_sysctl(void); 195535d3ae9SRashika Kheria void ipx_unregister_sysctl(void); 196535d3ae9SRashika Kheria #else 197535d3ae9SRashika Kheria #define ipx_register_sysctl() 198535d3ae9SRashika Kheria #define ipx_unregister_sysctl() 199535d3ae9SRashika Kheria #endif 200535d3ae9SRashika Kheria 201d4655795SPavel Emelyanov #ifdef CONFIG_NET_NS 202e67e16eaSJoe Perches void __put_net(struct net *net); 2035f256becSEric W. Biederman 2045f256becSEric W. Biederman static inline struct net *get_net(struct net *net) 2055f256becSEric W. Biederman { 206273c28bcSKirill Tkhai refcount_inc(&net->count); 2075f256becSEric W. Biederman return net; 2085f256becSEric W. Biederman } 2095f256becSEric W. Biederman 210077130c0SEric W. Biederman static inline struct net *maybe_get_net(struct net *net) 211077130c0SEric W. Biederman { 212077130c0SEric W. Biederman /* Used when we know struct net exists but we 213077130c0SEric W. Biederman * aren't guaranteed a previous reference count 214077130c0SEric W. Biederman * exists. If the reference count is zero this 215077130c0SEric W. Biederman * function fails and returns NULL. 216077130c0SEric W. Biederman */ 217273c28bcSKirill Tkhai if (!refcount_inc_not_zero(&net->count)) 218077130c0SEric W. Biederman net = NULL; 219077130c0SEric W. Biederman return net; 220077130c0SEric W. Biederman } 221077130c0SEric W. Biederman 2225f256becSEric W. Biederman static inline void put_net(struct net *net) 2235f256becSEric W. Biederman { 224273c28bcSKirill Tkhai if (refcount_dec_and_test(&net->count)) 2255f256becSEric W. Biederman __put_net(net); 2265f256becSEric W. Biederman } 2275f256becSEric W. Biederman 228878628fbSYOSHIFUJI Hideaki static inline 229878628fbSYOSHIFUJI Hideaki int net_eq(const struct net *net1, const struct net *net2) 230878628fbSYOSHIFUJI Hideaki { 231878628fbSYOSHIFUJI Hideaki return net1 == net2; 232878628fbSYOSHIFUJI Hideaki } 233a685e089SAl Viro 2344ee806d5SDan Streetman static inline int check_net(const struct net *net) 2354ee806d5SDan Streetman { 2363e3ab9ccSDavid S. Miller return refcount_read(&net->count) != 0; 2374ee806d5SDan Streetman } 2384ee806d5SDan Streetman 239e67e16eaSJoe Perches void net_drop_ns(void *); 240a685e089SAl Viro 241d4655795SPavel Emelyanov #else 242b9f75f45SEric W. Biederman 243d4655795SPavel Emelyanov static inline struct net *get_net(struct net *net) 244d4655795SPavel Emelyanov { 245d4655795SPavel Emelyanov return net; 246d4655795SPavel Emelyanov } 247d4655795SPavel Emelyanov 248d4655795SPavel Emelyanov static inline void put_net(struct net *net) 249d4655795SPavel Emelyanov { 250d4655795SPavel Emelyanov } 251d4655795SPavel Emelyanov 252d4655795SPavel Emelyanov static inline struct net *maybe_get_net(struct net *net) 253d4655795SPavel Emelyanov { 254d4655795SPavel Emelyanov return net; 255d4655795SPavel Emelyanov } 256878628fbSYOSHIFUJI Hideaki 257878628fbSYOSHIFUJI Hideaki static inline 258878628fbSYOSHIFUJI Hideaki int net_eq(const struct net *net1, const struct net *net2) 259878628fbSYOSHIFUJI Hideaki { 260878628fbSYOSHIFUJI Hideaki return 1; 261878628fbSYOSHIFUJI Hideaki } 262a685e089SAl Viro 2634ee806d5SDan Streetman static inline int check_net(const struct net *net) 2644ee806d5SDan Streetman { 2654ee806d5SDan Streetman return 1; 2664ee806d5SDan Streetman } 2674ee806d5SDan Streetman 268a685e089SAl Viro #define net_drop_ns NULL 269d4655795SPavel Emelyanov #endif 2705f256becSEric W. Biederman 2715d1e4468SDenis V. Lunev 2720c5c9fb5SEric W. Biederman typedef struct { 2738f424b5fSEric Dumazet #ifdef CONFIG_NET_NS 2740c5c9fb5SEric W. Biederman struct net *net; 2758f424b5fSEric Dumazet #endif 2760c5c9fb5SEric W. Biederman } possible_net_t; 2770c5c9fb5SEric W. Biederman 2780c5c9fb5SEric W. Biederman static inline void write_pnet(possible_net_t *pnet, struct net *net) 2790c5c9fb5SEric W. Biederman { 2800c5c9fb5SEric W. Biederman #ifdef CONFIG_NET_NS 2810c5c9fb5SEric W. Biederman pnet->net = net; 2820c5c9fb5SEric W. Biederman #endif 2830c5c9fb5SEric W. Biederman } 2840c5c9fb5SEric W. Biederman 2850c5c9fb5SEric W. Biederman static inline struct net *read_pnet(const possible_net_t *pnet) 2860c5c9fb5SEric W. Biederman { 2870c5c9fb5SEric W. Biederman #ifdef CONFIG_NET_NS 2880c5c9fb5SEric W. Biederman return pnet->net; 2890c5c9fb5SEric W. Biederman #else 2900c5c9fb5SEric W. Biederman return &init_net; 2910c5c9fb5SEric W. Biederman #endif 2920c5c9fb5SEric W. Biederman } 2935d1e4468SDenis V. Lunev 294f0b07bb1SKirill Tkhai /* Protected by net_rwsem */ 2955f256becSEric W. Biederman #define for_each_net(VAR) \ 2965f256becSEric W. Biederman list_for_each_entry(VAR, &net_namespace_list, list) 2975f256becSEric W. Biederman 29811a28d37SJohannes Berg #define for_each_net_rcu(VAR) \ 29911a28d37SJohannes Berg list_for_each_entry_rcu(VAR, &net_namespace_list, list) 30011a28d37SJohannes Berg 3014665079cSPavel Emelyanov #ifdef CONFIG_NET_NS 3024665079cSPavel Emelyanov #define __net_init 3034665079cSPavel Emelyanov #define __net_exit 304022cbae6SDenis V. Lunev #define __net_initdata 30504a6f82cSAndi Kleen #define __net_initconst 3064665079cSPavel Emelyanov #else 3074665079cSPavel Emelyanov #define __net_init __init 308bd721ea7SFabian Frederick #define __net_exit __ref 309022cbae6SDenis V. Lunev #define __net_initdata __initdata 31004a6f82cSAndi Kleen #define __net_initconst __initconst 3114665079cSPavel Emelyanov #endif 3125f256becSEric W. Biederman 3137a0877d4SNicolas Dichtel int peernet2id_alloc(struct net *net, struct net *peer); 31459324cf3SNicolas Dichtel int peernet2id(struct net *net, struct net *peer); 31559324cf3SNicolas Dichtel bool peernet_has_id(struct net *net, struct net *peer); 3160c7aecd4SNicolas Dichtel struct net *get_net_ns_by_id(struct net *net, int id); 3170c7aecd4SNicolas Dichtel 3185f256becSEric W. Biederman struct pernet_operations { 3195f256becSEric W. Biederman struct list_head list; 3206056415dSKirill Tkhai /* 3216056415dSKirill Tkhai * Below methods are called without any exclusive locks. 3226056415dSKirill Tkhai * More than one net may be constructed and destructed 3236056415dSKirill Tkhai * in parallel on several cpus. Every pernet_operations 3246056415dSKirill Tkhai * have to keep in mind all other pernet_operations and 3256056415dSKirill Tkhai * to introduce a locking, if they share common resources. 3266056415dSKirill Tkhai * 3278518e9bbSKirill Tkhai * The only time they are called with exclusive lock is 3288518e9bbSKirill Tkhai * from register_pernet_subsys(), unregister_pernet_subsys() 3298518e9bbSKirill Tkhai * register_pernet_device() and unregister_pernet_device(). 3308518e9bbSKirill Tkhai * 3316056415dSKirill Tkhai * Exit methods using blocking RCU primitives, such as 3326056415dSKirill Tkhai * synchronize_rcu(), should be implemented via exit_batch. 3336056415dSKirill Tkhai * Then, destruction of a group of net requires single 3346056415dSKirill Tkhai * synchronize_rcu() related to these pernet_operations, 3356056415dSKirill Tkhai * instead of separate synchronize_rcu() for every net. 3366056415dSKirill Tkhai * Please, avoid synchronize_rcu() at all, where it's possible. 3376056415dSKirill Tkhai */ 3385f256becSEric W. Biederman int (*init)(struct net *net); 3395f256becSEric W. Biederman void (*exit)(struct net *net); 34072ad937aSEric W. Biederman void (*exit_batch)(struct list_head *net_exit_list); 341c7d03a00SAlexey Dobriyan unsigned int *id; 342f875bae0SEric W. Biederman size_t size; 3435f256becSEric W. Biederman }; 3445f256becSEric W. Biederman 34517edde52SEric W. Biederman /* 34617edde52SEric W. Biederman * Use these carefully. If you implement a network device and it 34717edde52SEric W. Biederman * needs per network namespace operations use device pernet operations, 34817edde52SEric W. Biederman * otherwise use pernet subsys operations. 34917edde52SEric W. Biederman * 3504edf547bSJohannes Berg * Network interfaces need to be removed from a dying netns _before_ 3514edf547bSJohannes Berg * subsys notifiers can be called, as most of the network code cleanup 3524edf547bSJohannes Berg * (which is done from subsys notifiers) runs with the assumption that 3534edf547bSJohannes Berg * dev_remove_pack has been called so no new packets will arrive during 3544edf547bSJohannes Berg * and after the cleanup functions have been called. dev_remove_pack 3554edf547bSJohannes Berg * is not per namespace so instead the guarantee of no more packets 3564edf547bSJohannes Berg * arriving in a network namespace is provided by ensuring that all 3574edf547bSJohannes Berg * network devices and all sockets have left the network namespace 3584edf547bSJohannes Berg * before the cleanup methods are called. 35917edde52SEric W. Biederman * 36017edde52SEric W. Biederman * For the longest time the ipv4 icmp code was registered as a pernet 36117edde52SEric W. Biederman * device which caused kernel oops, and panics during network 36217edde52SEric W. Biederman * namespace cleanup. So please don't get this wrong. 36317edde52SEric W. Biederman */ 364e67e16eaSJoe Perches int register_pernet_subsys(struct pernet_operations *); 365e67e16eaSJoe Perches void unregister_pernet_subsys(struct pernet_operations *); 366e67e16eaSJoe Perches int register_pernet_device(struct pernet_operations *); 367e67e16eaSJoe Perches void unregister_pernet_device(struct pernet_operations *); 368f875bae0SEric W. Biederman 36995bdfccbSEric W. Biederman struct ctl_table; 37095bdfccbSEric W. Biederman struct ctl_table_header; 371d62c612eSPavel Emelyanov 3722ca794e5SEric W. Biederman #ifdef CONFIG_SYSCTL 373e67e16eaSJoe Perches int net_sysctl_init(void); 374e67e16eaSJoe Perches struct ctl_table_header *register_net_sysctl(struct net *net, const char *path, 375e67e16eaSJoe Perches struct ctl_table *table); 376e67e16eaSJoe Perches void unregister_net_sysctl_table(struct ctl_table_header *header); 37748c74958SEric W. Biederman #else 37848c74958SEric W. Biederman static inline int net_sysctl_init(void) { return 0; } 37948c74958SEric W. Biederman static inline struct ctl_table_header *register_net_sysctl(struct net *net, 38048c74958SEric W. Biederman const char *path, struct ctl_table *table) 38148c74958SEric W. Biederman { 38248c74958SEric W. Biederman return NULL; 38348c74958SEric W. Biederman } 38448c74958SEric W. Biederman static inline void unregister_net_sysctl_table(struct ctl_table_header *header) 38548c74958SEric W. Biederman { 38648c74958SEric W. Biederman } 38748c74958SEric W. Biederman #endif 38848c74958SEric W. Biederman 389ca4c3fc2Sfan.du static inline int rt_genid_ipv4(struct net *net) 390b42664f8SNicolas Dichtel { 391ca4c3fc2Sfan.du return atomic_read(&net->ipv4.rt_genid); 392b42664f8SNicolas Dichtel } 393b42664f8SNicolas Dichtel 394ca4c3fc2Sfan.du static inline void rt_genid_bump_ipv4(struct net *net) 395b42664f8SNicolas Dichtel { 396ca4c3fc2Sfan.du atomic_inc(&net->ipv4.rt_genid); 397ca4c3fc2Sfan.du } 398ca4c3fc2Sfan.du 399705f1c86SHannes Frederic Sowa extern void (*__fib6_flush_trees)(struct net *net); 400ca4c3fc2Sfan.du static inline void rt_genid_bump_ipv6(struct net *net) 401ca4c3fc2Sfan.du { 402705f1c86SHannes Frederic Sowa if (__fib6_flush_trees) 403705f1c86SHannes Frederic Sowa __fib6_flush_trees(net); 404ca4c3fc2Sfan.du } 405ca4c3fc2Sfan.du 406599018a7SLuis R. Rodriguez #if IS_ENABLED(CONFIG_IEEE802154_6LOWPAN) 407599018a7SLuis R. Rodriguez static inline struct netns_ieee802154_lowpan * 408599018a7SLuis R. Rodriguez net_ieee802154_lowpan(struct net *net) 409599018a7SLuis R. Rodriguez { 410599018a7SLuis R. Rodriguez return &net->ieee802154_lowpan; 411599018a7SLuis R. Rodriguez } 412599018a7SLuis R. Rodriguez #endif 413599018a7SLuis R. Rodriguez 414ca4c3fc2Sfan.du /* For callers who don't really care about whether it's IPv4 or IPv6 */ 415ca4c3fc2Sfan.du static inline void rt_genid_bump_all(struct net *net) 416ca4c3fc2Sfan.du { 417ca4c3fc2Sfan.du rt_genid_bump_ipv4(net); 418ca4c3fc2Sfan.du rt_genid_bump_ipv6(net); 419b42664f8SNicolas Dichtel } 42095bdfccbSEric W. Biederman 4215aad1de5STimo Teräs static inline int fnhe_genid(struct net *net) 4225aad1de5STimo Teräs { 4235aad1de5STimo Teräs return atomic_read(&net->fnhe_genid); 4245aad1de5STimo Teräs } 4255aad1de5STimo Teräs 4265aad1de5STimo Teräs static inline void fnhe_genid_bump(struct net *net) 4275aad1de5STimo Teräs { 4285aad1de5STimo Teräs atomic_inc(&net->fnhe_genid); 4295aad1de5STimo Teräs } 4305aad1de5STimo Teräs 4315f256becSEric W. Biederman #endif /* __NET_NET_NAMESPACE_H */ 432