aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2015-03-12 00:06:44 -0400
committerDavid S. Miller <davem@davemloft.net>2015-03-12 14:39:40 -0400
commit0c5c9fb55106333e773de8c9dd321fa8240caeb3 (patch)
treeda550b771a52ba583eb97c1ad00fffbf3ae17f73 /net
parentefd7ef1c1929d7a0329d4349252863c04d6f1729 (diff)
net: Introduce possible_net_t
Having to say > #ifdef CONFIG_NET_NS > struct net *net; > #endif in structures is a little bit wordy and a little bit error prone. Instead it is possible to say: > typedef struct { > #ifdef CONFIG_NET_NS > struct net *net; > #endif > } possible_net_t; And then in a header say: > possible_net_t net; Which is cleaner and easier to use and easier to test, as the possible_net_t is always there no matter what the compile options. Further this allows read_pnet and write_pnet to be functions in all cases which is better at catching typos. This change adds possible_net_t, updates the definitions of read_pnet and write_pnet, updates optional struct net * variables that write_pnet uses on to have the type possible_net_t, and finally fixes up the b0rked users of read_pnet and write_pnet. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-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
6 files changed, 8 insertions, 20 deletions
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;