aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/netdevice.h8
-rw-r--r--include/net/cfg80211.h4
-rw-r--r--include/net/genetlink.h4
-rw-r--r--include/net/inet_hashtables.h4
-rw-r--r--include/net/ip_vs.h8
-rw-r--r--include/net/neighbour.h8
-rw-r--r--include/net/net_namespace.h23
-rw-r--r--include/net/netfilter/nf_conntrack.h5
-rw-r--r--include/net/sock.h4
-rw-r--r--include/net/xfrm.h8
-rw-r--r--net/9p/trans_fd.c4
-rw-r--r--net/ipv4/ipmr.c4
-rw-r--r--net/ipv6/addrlabel.c8
-rw-r--r--net/ipv6/ip6mr.c4
-rw-r--r--net/openvswitch/datapath.h4
-rw-r--r--net/packet/internal.h4
16 files changed, 37 insertions, 67 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index cede40d9cac9..ddab1a2a07a0 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1721,9 +1721,7 @@ struct net_device {
1721 struct netpoll_info __rcu *npinfo; 1721 struct netpoll_info __rcu *npinfo;
1722#endif 1722#endif
1723 1723
1724#ifdef CONFIG_NET_NS 1724 possible_net_t nd_net;
1725 struct net *nd_net;
1726#endif
1727 1725
1728 /* mid-layer private */ 1726 /* mid-layer private */
1729 union { 1727 union {
@@ -1863,9 +1861,7 @@ struct net *dev_net(const struct net_device *dev)
1863static inline 1861static inline
1864void dev_net_set(struct net_device *dev, struct net *net) 1862void dev_net_set(struct net_device *dev, struct net *net)
1865{ 1863{
1866#ifdef CONFIG_NET_NS 1864 write_pnet(&dev->nd_net, net);
1867 dev->nd_net = net;
1868#endif
1869} 1865}
1870 1866
1871static inline bool netdev_uses_dsa(struct net_device *dev) 1867static inline bool netdev_uses_dsa(struct net_device *dev)
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 64e09e1e8099..f977abec07f6 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -3183,10 +3183,8 @@ struct wiphy {
3183 const struct ieee80211_ht_cap *ht_capa_mod_mask; 3183 const struct ieee80211_ht_cap *ht_capa_mod_mask;
3184 const struct ieee80211_vht_cap *vht_capa_mod_mask; 3184 const struct ieee80211_vht_cap *vht_capa_mod_mask;
3185 3185
3186#ifdef CONFIG_NET_NS
3187 /* the network namespace this phy lives in currently */ 3186 /* the network namespace this phy lives in currently */
3188 struct net *_net; 3187 possible_net_t _net;
3189#endif
3190 3188
3191#ifdef CONFIG_CFG80211_WEXT 3189#ifdef CONFIG_CFG80211_WEXT
3192 const struct iw_handler_def *wext; 3190 const struct iw_handler_def *wext;
diff --git a/include/net/genetlink.h b/include/net/genetlink.h
index 0574abd3db86..a9af1cc8c1bc 100644
--- a/include/net/genetlink.h
+++ b/include/net/genetlink.h
@@ -92,9 +92,7 @@ struct genl_info {
92 struct genlmsghdr * genlhdr; 92 struct genlmsghdr * genlhdr;
93 void * userhdr; 93 void * userhdr;
94 struct nlattr ** attrs; 94 struct nlattr ** attrs;
95#ifdef CONFIG_NET_NS 95 possible_net_t _net;
96 struct net * _net;
97#endif
98 void * user_ptr[2]; 96 void * user_ptr[2];
99 struct sock * dst_sk; 97 struct sock * dst_sk;
100}; 98};
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h
index dd1950a7e273..bcd64756e5fe 100644
--- a/include/net/inet_hashtables.h
+++ b/include/net/inet_hashtables.h
@@ -76,9 +76,7 @@ struct inet_ehash_bucket {
76 * ports are created in O(1) time? I thought so. ;-) -DaveM 76 * ports are created in O(1) time? I thought so. ;-) -DaveM
77 */ 77 */
78struct inet_bind_bucket { 78struct inet_bind_bucket {
79#ifdef CONFIG_NET_NS 79 possible_net_t ib_net;
80 struct net *ib_net;
81#endif
82 unsigned short port; 80 unsigned short port;
83 signed char fastreuse; 81 signed char fastreuse;
84 signed char fastreuseport; 82 signed char fastreuseport;
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 20fd23398537..4e3731ee4eac 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -47,13 +47,13 @@ static inline struct net *skb_net(const struct sk_buff *skb)
47 * Start with the most likely hit 47 * Start with the most likely hit
48 * End with BUG 48 * End with BUG
49 */ 49 */
50 if (likely(skb->dev && skb->dev->nd_net)) 50 if (likely(skb->dev && dev_net(skb->dev)))
51 return dev_net(skb->dev); 51 return dev_net(skb->dev);
52 if (skb_dst(skb) && skb_dst(skb)->dev) 52 if (skb_dst(skb) && skb_dst(skb)->dev)
53 return dev_net(skb_dst(skb)->dev); 53 return dev_net(skb_dst(skb)->dev);
54 WARN(skb->sk, "Maybe skb_sknet should be used in %s() at line:%d\n", 54 WARN(skb->sk, "Maybe skb_sknet should be used in %s() at line:%d\n",
55 __func__, __LINE__); 55 __func__, __LINE__);
56 if (likely(skb->sk && skb->sk->sk_net)) 56 if (likely(skb->sk && sock_net(skb->sk)))
57 return sock_net(skb->sk); 57 return sock_net(skb->sk);
58 pr_err("There is no net ptr to find in the skb in %s() line:%d\n", 58 pr_err("There is no net ptr to find in the skb in %s() line:%d\n",
59 __func__, __LINE__); 59 __func__, __LINE__);
@@ -71,11 +71,11 @@ static inline struct net *skb_sknet(const struct sk_buff *skb)
71#ifdef CONFIG_NET_NS 71#ifdef CONFIG_NET_NS
72#ifdef CONFIG_IP_VS_DEBUG 72#ifdef CONFIG_IP_VS_DEBUG
73 /* Start with the most likely hit */ 73 /* Start with the most likely hit */
74 if (likely(skb->sk && skb->sk->sk_net)) 74 if (likely(skb->sk && sock_net(skb->sk)))
75 return sock_net(skb->sk); 75 return sock_net(skb->sk);
76 WARN(skb->dev, "Maybe skb_net should be used instead in %s() line:%d\n", 76 WARN(skb->dev, "Maybe skb_net should be used instead in %s() line:%d\n",
77 __func__, __LINE__); 77 __func__, __LINE__);
78 if (likely(skb->dev && skb->dev->nd_net)) 78 if (likely(skb->dev && dev_net(skb->dev)))
79 return dev_net(skb->dev); 79 return dev_net(skb->dev);
80 pr_err("There is no net ptr to find in the skb in %s() line:%d\n", 80 pr_err("There is no net ptr to find in the skb in %s() line:%d\n",
81 __func__, __LINE__); 81 __func__, __LINE__);
diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index d48b8ec8b5f4..e7bdf5170802 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -65,9 +65,7 @@ enum {
65}; 65};
66 66
67struct neigh_parms { 67struct neigh_parms {
68#ifdef CONFIG_NET_NS 68 possible_net_t net;
69 struct net *net;
70#endif
71 struct net_device *dev; 69 struct net_device *dev;
72 struct list_head list; 70 struct list_head list;
73 int (*neigh_setup)(struct neighbour *); 71 int (*neigh_setup)(struct neighbour *);
@@ -167,9 +165,7 @@ struct neigh_ops {
167 165
168struct pneigh_entry { 166struct pneigh_entry {
169 struct pneigh_entry *next; 167 struct pneigh_entry *next;
170#ifdef CONFIG_NET_NS 168 possible_net_t net;
171 struct net *net;
172#endif
173 struct net_device *dev; 169 struct net_device *dev;
174 u8 flags; 170 u8 flags;
175 u8 key[0]; 171 u8 key[0];
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
index fab51ceeabf3..f733656404de 100644
--- a/include/net/net_namespace.h
+++ b/include/net/net_namespace.h
@@ -231,24 +231,27 @@ int net_eq(const struct net *net1, const struct net *net2)
231#endif 231#endif
232 232
233 233
234typedef struct {
234#ifdef CONFIG_NET_NS 235#ifdef CONFIG_NET_NS
236 struct net *net;
237#endif
238} possible_net_t;
235 239
236static inline void write_pnet(struct net **pnet, struct net *net) 240static inline void write_pnet(possible_net_t *pnet, struct net *net)
237{ 241{
238 *pnet = net; 242#ifdef CONFIG_NET_NS
243 pnet->net = net;
244#endif
239} 245}
240 246
241static inline struct net *read_pnet(struct net * const *pnet) 247static inline struct net *read_pnet(const possible_net_t *pnet)
242{ 248{
243 return *pnet; 249#ifdef CONFIG_NET_NS
244} 250 return pnet->net;
245
246#else 251#else
247 252 return &init_net;
248#define write_pnet(pnet, net) do { (void)(net);} while (0)
249#define read_pnet(pnet) (&init_net)
250
251#endif 253#endif
254}
252 255
253#define for_each_net(VAR) \ 256#define for_each_net(VAR) \
254 list_for_each_entry(VAR, &net_namespace_list, list) 257 list_for_each_entry(VAR, &net_namespace_list, list)
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index 74f271a172dd..095433b8a8b0 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -95,9 +95,8 @@ struct nf_conn {
95 /* Timer function; drops refcnt when it goes off. */ 95 /* Timer function; drops refcnt when it goes off. */
96 struct timer_list timeout; 96 struct timer_list timeout;
97 97
98#ifdef CONFIG_NET_NS 98 possible_net_t ct_net;
99 struct net *ct_net; 99
100#endif
101 /* all members below initialized via memset */ 100 /* all members below initialized via memset */
102 u8 __nfct_init_offset[0]; 101 u8 __nfct_init_offset[0];
103 102
diff --git a/include/net/sock.h b/include/net/sock.h
index 95b2c1c220f9..9411c3421dd3 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -190,9 +190,7 @@ struct sock_common {
190 struct hlist_nulls_node skc_portaddr_node; 190 struct hlist_nulls_node skc_portaddr_node;
191 }; 191 };
192 struct proto *skc_prot; 192 struct proto *skc_prot;
193#ifdef CONFIG_NET_NS 193 possible_net_t skc_net;
194 struct net *skc_net;
195#endif
196 194
197#if IS_ENABLED(CONFIG_IPV6) 195#if IS_ENABLED(CONFIG_IPV6)
198 struct in6_addr skc_v6_daddr; 196 struct in6_addr skc_v6_daddr;
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index dc4865e90fe4..d0ac7d7be8a7 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -126,9 +126,7 @@ struct xfrm_state_walk {
126 126
127/* Full description of state of transformer. */ 127/* Full description of state of transformer. */
128struct xfrm_state { 128struct xfrm_state {
129#ifdef CONFIG_NET_NS 129 possible_net_t xs_net;
130 struct net *xs_net;
131#endif
132 union { 130 union {
133 struct hlist_node gclist; 131 struct hlist_node gclist;
134 struct hlist_node bydst; 132 struct hlist_node bydst;
@@ -522,9 +520,7 @@ struct xfrm_policy_queue {
522}; 520};
523 521
524struct xfrm_policy { 522struct xfrm_policy {
525#ifdef CONFIG_NET_NS 523 possible_net_t xp_net;
526 struct net *xp_net;
527#endif
528 struct hlist_node bydst; 524 struct hlist_node bydst;
529 struct hlist_node byidx; 525 struct hlist_node byidx;
530 526
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index 80d08f6664cb..3e3d82d8ff70 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -940,7 +940,7 @@ p9_fd_create_tcp(struct p9_client *client, const char *addr, char *args)
940 sin_server.sin_family = AF_INET; 940 sin_server.sin_family = AF_INET;
941 sin_server.sin_addr.s_addr = in_aton(addr); 941 sin_server.sin_addr.s_addr = in_aton(addr);
942 sin_server.sin_port = htons(opts.port); 942 sin_server.sin_port = htons(opts.port);
943 err = __sock_create(read_pnet(&current->nsproxy->net_ns), PF_INET, 943 err = __sock_create(current->nsproxy->net_ns, PF_INET,
944 SOCK_STREAM, IPPROTO_TCP, &csocket, 1); 944 SOCK_STREAM, IPPROTO_TCP, &csocket, 1);
945 if (err) { 945 if (err) {
946 pr_err("%s (%d): problem creating socket\n", 946 pr_err("%s (%d): problem creating socket\n",
@@ -988,7 +988,7 @@ p9_fd_create_unix(struct p9_client *client, const char *addr, char *args)
988 988
989 sun_server.sun_family = PF_UNIX; 989 sun_server.sun_family = PF_UNIX;
990 strcpy(sun_server.sun_path, addr); 990 strcpy(sun_server.sun_path, addr);
991 err = __sock_create(read_pnet(&current->nsproxy->net_ns), PF_UNIX, 991 err = __sock_create(current->nsproxy->net_ns, PF_UNIX,
992 SOCK_STREAM, 0, &csocket, 1); 992 SOCK_STREAM, 0, &csocket, 1);
993 if (err < 0) { 993 if (err < 0) {
994 pr_err("%s (%d): problem creating socket\n", 994 pr_err("%s (%d): problem creating socket\n",
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index 9d78427652d2..5b188832800f 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -73,9 +73,7 @@
73 73
74struct mr_table { 74struct mr_table {
75 struct list_head list; 75 struct list_head list;
76#ifdef CONFIG_NET_NS 76 possible_net_t net;
77 struct net *net;
78#endif
79 u32 id; 77 u32 id;
80 struct sock __rcu *mroute_sk; 78 struct sock __rcu *mroute_sk;
81 struct timer_list ipmr_expire_timer; 79 struct timer_list ipmr_expire_timer;
diff --git a/net/ipv6/addrlabel.c b/net/ipv6/addrlabel.c
index 59c793040498..3cc50e2d3bf5 100644
--- a/net/ipv6/addrlabel.c
+++ b/net/ipv6/addrlabel.c
@@ -29,9 +29,7 @@
29 * Policy Table 29 * Policy Table
30 */ 30 */
31struct ip6addrlbl_entry { 31struct ip6addrlbl_entry {
32#ifdef CONFIG_NET_NS 32 possible_net_t lbl_net;
33 struct net *lbl_net;
34#endif
35 struct in6_addr prefix; 33 struct in6_addr prefix;
36 int prefixlen; 34 int prefixlen;
37 int ifindex; 35 int ifindex;
@@ -237,9 +235,7 @@ static struct ip6addrlbl_entry *ip6addrlbl_alloc(struct net *net,
237 newp->addrtype = addrtype; 235 newp->addrtype = addrtype;
238 newp->label = label; 236 newp->label = label;
239 INIT_HLIST_NODE(&newp->list); 237 INIT_HLIST_NODE(&newp->list);
240#ifdef CONFIG_NET_NS 238 write_pnet(&newp->lbl_net, net);
241 newp->lbl_net = net;
242#endif
243 atomic_set(&newp->refcnt, 1); 239 atomic_set(&newp->refcnt, 1);
244 return newp; 240 return newp;
245} 241}
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index 34b682617f50..4b9315aa273e 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -56,9 +56,7 @@
56 56
57struct mr6_table { 57struct mr6_table {
58 struct list_head list; 58 struct list_head list;
59#ifdef CONFIG_NET_NS 59 possible_net_t net;
60 struct net *net;
61#endif
62 u32 id; 60 u32 id;
63 struct sock *mroute6_sk; 61 struct sock *mroute6_sk;
64 struct timer_list ipmr_expire_timer; 62 struct timer_list ipmr_expire_timer;
diff --git a/net/openvswitch/datapath.h b/net/openvswitch/datapath.h
index 3ece94563079..4ec4a480b147 100644
--- a/net/openvswitch/datapath.h
+++ b/net/openvswitch/datapath.h
@@ -84,10 +84,8 @@ struct datapath {
84 /* Stats. */ 84 /* Stats. */
85 struct dp_stats_percpu __percpu *stats_percpu; 85 struct dp_stats_percpu __percpu *stats_percpu;
86 86
87#ifdef CONFIG_NET_NS
88 /* Network namespace ref. */ 87 /* Network namespace ref. */
89 struct net *net; 88 possible_net_t net;
90#endif
91 89
92 u32 user_features; 90 u32 user_features;
93}; 91};
diff --git a/net/packet/internal.h b/net/packet/internal.h
index cdddf6a30399..fe6e20caea1d 100644
--- a/net/packet/internal.h
+++ b/net/packet/internal.h
@@ -74,9 +74,7 @@ extern struct mutex fanout_mutex;
74#define PACKET_FANOUT_MAX 256 74#define PACKET_FANOUT_MAX 256
75 75
76struct packet_fanout { 76struct packet_fanout {
77#ifdef CONFIG_NET_NS 77 possible_net_t net;
78 struct net *net;
79#endif
80 unsigned int num_members; 78 unsigned int num_members;
81 u16 id; 79 u16 id;
82 u8 type; 80 u8 type;