aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
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/ipv6
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/ipv6')
-rw-r--r--net/ipv6/addrlabel.c8
-rw-r--r--net/ipv6/ip6mr.c4
2 files changed, 3 insertions, 9 deletions
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;