aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/sock.h7
-rw-r--r--include/net/udp.h2
-rw-r--r--net/core/sock.c4
-rw-r--r--net/ipv4/inet_hashtables.c8
-rw-r--r--net/ipv4/inet_timewait_sock.c2
-rw-r--r--net/ipv4/proc.c11
-rw-r--r--net/ipv4/raw.c4
-rw-r--r--net/ipv4/udp.c2
-rw-r--r--net/ipv6/inet6_hashtables.c4
-rw-r--r--net/ipv6/ipv6_sockglue.c10
-rw-r--r--net/ipv6/proc.c8
11 files changed, 34 insertions, 28 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index 2a3344f666aa..f4fdd101c9a2 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -635,10 +635,11 @@ static inline void sk_refcnt_debug_release(const struct sock *sk)
635 635
636#ifdef CONFIG_PROC_FS 636#ifdef CONFIG_PROC_FS
637/* Called with local bh disabled */ 637/* Called with local bh disabled */
638extern void sock_prot_inuse_add(struct proto *prot, int inc); 638extern void sock_prot_inuse_add(struct net *net, struct proto *prot, int inc);
639extern int sock_prot_inuse_get(struct proto *proto); 639extern int sock_prot_inuse_get(struct net *net, struct proto *proto);
640#else 640#else
641static void inline sock_prot_inuse_add(struct proto *prot, int inc) 641static void inline sock_prot_inuse_add(struct net *net, struct proto *prot,
642 int inc)
642{ 643{
643} 644}
644#endif 645#endif
diff --git a/include/net/udp.h b/include/net/udp.h
index 24a41fa31641..3e55a99b0ba3 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -115,7 +115,7 @@ static inline void udp_lib_unhash(struct sock *sk)
115 write_lock_bh(&udp_hash_lock); 115 write_lock_bh(&udp_hash_lock);
116 if (sk_del_node_init(sk)) { 116 if (sk_del_node_init(sk)) {
117 inet_sk(sk)->num = 0; 117 inet_sk(sk)->num = 0;
118 sock_prot_inuse_add(sk->sk_prot, -1); 118 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
119 } 119 }
120 write_unlock_bh(&udp_hash_lock); 120 write_unlock_bh(&udp_hash_lock);
121} 121}
diff --git a/net/core/sock.c b/net/core/sock.c
index c1ae56eb96ec..6f36ab91bb59 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1949,13 +1949,13 @@ struct prot_inuse {
1949static DECLARE_BITMAP(proto_inuse_idx, PROTO_INUSE_NR); 1949static DECLARE_BITMAP(proto_inuse_idx, PROTO_INUSE_NR);
1950static DEFINE_PER_CPU(struct prot_inuse, prot_inuse); 1950static DEFINE_PER_CPU(struct prot_inuse, prot_inuse);
1951 1951
1952void sock_prot_inuse_add(struct proto *prot, int val) 1952void sock_prot_inuse_add(struct net *net, struct proto *prot, int val)
1953{ 1953{
1954 __get_cpu_var(prot_inuse).val[prot->inuse_idx] += val; 1954 __get_cpu_var(prot_inuse).val[prot->inuse_idx] += val;
1955} 1955}
1956EXPORT_SYMBOL_GPL(sock_prot_inuse_add); 1956EXPORT_SYMBOL_GPL(sock_prot_inuse_add);
1957 1957
1958int sock_prot_inuse_get(struct proto *prot) 1958int sock_prot_inuse_get(struct net *net, struct proto *prot)
1959{ 1959{
1960 int cpu, idx = prot->inuse_idx; 1960 int cpu, idx = prot->inuse_idx;
1961 int res = 0; 1961 int res = 0;
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index 1b6ff513c75d..32ca2f8b581c 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -288,7 +288,7 @@ unique:
288 sk->sk_hash = hash; 288 sk->sk_hash = hash;
289 BUG_TRAP(sk_unhashed(sk)); 289 BUG_TRAP(sk_unhashed(sk));
290 __sk_add_node(sk, &head->chain); 290 __sk_add_node(sk, &head->chain);
291 sock_prot_inuse_add(sk->sk_prot, 1); 291 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
292 write_unlock(lock); 292 write_unlock(lock);
293 293
294 if (twp) { 294 if (twp) {
@@ -332,7 +332,7 @@ void __inet_hash_nolisten(struct sock *sk)
332 332
333 write_lock(lock); 333 write_lock(lock);
334 __sk_add_node(sk, list); 334 __sk_add_node(sk, list);
335 sock_prot_inuse_add(sk->sk_prot, 1); 335 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
336 write_unlock(lock); 336 write_unlock(lock);
337} 337}
338EXPORT_SYMBOL_GPL(__inet_hash_nolisten); 338EXPORT_SYMBOL_GPL(__inet_hash_nolisten);
@@ -354,7 +354,7 @@ static void __inet_hash(struct sock *sk)
354 354
355 inet_listen_wlock(hashinfo); 355 inet_listen_wlock(hashinfo);
356 __sk_add_node(sk, list); 356 __sk_add_node(sk, list);
357 sock_prot_inuse_add(sk->sk_prot, 1); 357 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
358 write_unlock(lock); 358 write_unlock(lock);
359 wake_up(&hashinfo->lhash_wait); 359 wake_up(&hashinfo->lhash_wait);
360} 360}
@@ -387,7 +387,7 @@ void inet_unhash(struct sock *sk)
387 } 387 }
388 388
389 if (__sk_del_node_init(sk)) 389 if (__sk_del_node_init(sk))
390 sock_prot_inuse_add(sk->sk_prot, -1); 390 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
391 write_unlock_bh(lock); 391 write_unlock_bh(lock);
392out: 392out:
393 if (sk->sk_state == TCP_LISTEN) 393 if (sk->sk_state == TCP_LISTEN)
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c
index f12bc24de46f..a74137866fbc 100644
--- a/net/ipv4/inet_timewait_sock.c
+++ b/net/ipv4/inet_timewait_sock.c
@@ -91,7 +91,7 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk,
91 91
92 /* Step 2: Remove SK from established hash. */ 92 /* Step 2: Remove SK from established hash. */
93 if (__sk_del_node_init(sk)) 93 if (__sk_del_node_init(sk))
94 sock_prot_inuse_add(sk->sk_prot, -1); 94 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
95 95
96 /* Step 3: Hash TW into TIMEWAIT chain. */ 96 /* Step 3: Hash TW into TIMEWAIT chain. */
97 inet_twsk_add_node(tw, &ehead->twchain); 97 inet_twsk_add_node(tw, &ehead->twchain);
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
index d63474c6b400..8156c26f9337 100644
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -53,14 +53,17 @@ static int sockstat_seq_show(struct seq_file *seq, void *v)
53{ 53{
54 socket_seq_show(seq); 54 socket_seq_show(seq);
55 seq_printf(seq, "TCP: inuse %d orphan %d tw %d alloc %d mem %d\n", 55 seq_printf(seq, "TCP: inuse %d orphan %d tw %d alloc %d mem %d\n",
56 sock_prot_inuse_get(&tcp_prot), 56 sock_prot_inuse_get(&init_net, &tcp_prot),
57 atomic_read(&tcp_orphan_count), 57 atomic_read(&tcp_orphan_count),
58 tcp_death_row.tw_count, atomic_read(&tcp_sockets_allocated), 58 tcp_death_row.tw_count, atomic_read(&tcp_sockets_allocated),
59 atomic_read(&tcp_memory_allocated)); 59 atomic_read(&tcp_memory_allocated));
60 seq_printf(seq, "UDP: inuse %d mem %d\n", sock_prot_inuse_get(&udp_prot), 60 seq_printf(seq, "UDP: inuse %d mem %d\n",
61 sock_prot_inuse_get(&init_net, &udp_prot),
61 atomic_read(&udp_memory_allocated)); 62 atomic_read(&udp_memory_allocated));
62 seq_printf(seq, "UDPLITE: inuse %d\n", sock_prot_inuse_get(&udplite_prot)); 63 seq_printf(seq, "UDPLITE: inuse %d\n",
63 seq_printf(seq, "RAW: inuse %d\n", sock_prot_inuse_get(&raw_prot)); 64 sock_prot_inuse_get(&init_net, &udplite_prot));
65 seq_printf(seq, "RAW: inuse %d\n",
66 sock_prot_inuse_get(&init_net, &raw_prot));
64 seq_printf(seq, "FRAG: inuse %d memory %d\n", 67 seq_printf(seq, "FRAG: inuse %d memory %d\n",
65 ip_frag_nqueues(&init_net), ip_frag_mem(&init_net)); 68 ip_frag_nqueues(&init_net), ip_frag_mem(&init_net));
66 return 0; 69 return 0;
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
index 349205048557..11d7f753a820 100644
--- a/net/ipv4/raw.c
+++ b/net/ipv4/raw.c
@@ -93,7 +93,7 @@ void raw_hash_sk(struct sock *sk)
93 93
94 write_lock_bh(&h->lock); 94 write_lock_bh(&h->lock);
95 sk_add_node(sk, head); 95 sk_add_node(sk, head);
96 sock_prot_inuse_add(sk->sk_prot, 1); 96 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
97 write_unlock_bh(&h->lock); 97 write_unlock_bh(&h->lock);
98} 98}
99EXPORT_SYMBOL_GPL(raw_hash_sk); 99EXPORT_SYMBOL_GPL(raw_hash_sk);
@@ -104,7 +104,7 @@ void raw_unhash_sk(struct sock *sk)
104 104
105 write_lock_bh(&h->lock); 105 write_lock_bh(&h->lock);
106 if (sk_del_node_init(sk)) 106 if (sk_del_node_init(sk))
107 sock_prot_inuse_add(sk->sk_prot, -1); 107 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
108 write_unlock_bh(&h->lock); 108 write_unlock_bh(&h->lock);
109} 109}
110EXPORT_SYMBOL_GPL(raw_unhash_sk); 110EXPORT_SYMBOL_GPL(raw_unhash_sk);
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 9143645f9a1b..03bd70697481 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -231,7 +231,7 @@ gotit:
231 if (sk_unhashed(sk)) { 231 if (sk_unhashed(sk)) {
232 head = &udptable[snum & (UDP_HTABLE_SIZE - 1)]; 232 head = &udptable[snum & (UDP_HTABLE_SIZE - 1)];
233 sk_add_node(sk, head); 233 sk_add_node(sk, head);
234 sock_prot_inuse_add(sk->sk_prot, 1); 234 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
235 } 235 }
236 error = 0; 236 error = 0;
237fail: 237fail:
diff --git a/net/ipv6/inet6_hashtables.c b/net/ipv6/inet6_hashtables.c
index 340c7d42b83a..580014aea4d6 100644
--- a/net/ipv6/inet6_hashtables.c
+++ b/net/ipv6/inet6_hashtables.c
@@ -43,7 +43,7 @@ void __inet6_hash(struct sock *sk)
43 } 43 }
44 44
45 __sk_add_node(sk, list); 45 __sk_add_node(sk, list);
46 sock_prot_inuse_add(sk->sk_prot, 1); 46 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
47 write_unlock(lock); 47 write_unlock(lock);
48} 48}
49EXPORT_SYMBOL(__inet6_hash); 49EXPORT_SYMBOL(__inet6_hash);
@@ -204,7 +204,7 @@ unique:
204 BUG_TRAP(sk_unhashed(sk)); 204 BUG_TRAP(sk_unhashed(sk));
205 __sk_add_node(sk, &head->chain); 205 __sk_add_node(sk, &head->chain);
206 sk->sk_hash = hash; 206 sk->sk_hash = hash;
207 sock_prot_inuse_add(sk->sk_prot, 1); 207 sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
208 write_unlock(lock); 208 write_unlock(lock);
209 209
210 if (twp != NULL) { 210 if (twp != NULL) {
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index d3d93d752e10..4195ac92345e 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -155,10 +155,11 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
155 155
156 if (sk->sk_protocol == IPPROTO_TCP) { 156 if (sk->sk_protocol == IPPROTO_TCP) {
157 struct inet_connection_sock *icsk = inet_csk(sk); 157 struct inet_connection_sock *icsk = inet_csk(sk);
158 struct net *net = sock_net(sk);
158 159
159 local_bh_disable(); 160 local_bh_disable();
160 sock_prot_inuse_add(sk->sk_prot, -1); 161 sock_prot_inuse_add(net, sk->sk_prot, -1);
161 sock_prot_inuse_add(&tcp_prot, 1); 162 sock_prot_inuse_add(net, &tcp_prot, 1);
162 local_bh_enable(); 163 local_bh_enable();
163 sk->sk_prot = &tcp_prot; 164 sk->sk_prot = &tcp_prot;
164 icsk->icsk_af_ops = &ipv4_specific; 165 icsk->icsk_af_ops = &ipv4_specific;
@@ -167,12 +168,13 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname,
167 tcp_sync_mss(sk, icsk->icsk_pmtu_cookie); 168 tcp_sync_mss(sk, icsk->icsk_pmtu_cookie);
168 } else { 169 } else {
169 struct proto *prot = &udp_prot; 170 struct proto *prot = &udp_prot;
171 struct net *net = sock_net(sk);
170 172
171 if (sk->sk_protocol == IPPROTO_UDPLITE) 173 if (sk->sk_protocol == IPPROTO_UDPLITE)
172 prot = &udplite_prot; 174 prot = &udplite_prot;
173 local_bh_disable(); 175 local_bh_disable();
174 sock_prot_inuse_add(sk->sk_prot, -1); 176 sock_prot_inuse_add(net, sk->sk_prot, -1);
175 sock_prot_inuse_add(prot, 1); 177 sock_prot_inuse_add(net, prot, 1);
176 local_bh_enable(); 178 local_bh_enable();
177 sk->sk_prot = prot; 179 sk->sk_prot = prot;
178 sk->sk_socket->ops = &inet_dgram_ops; 180 sk->sk_socket->ops = &inet_dgram_ops;
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c
index 364dc332532c..4b9d5a905725 100644
--- a/net/ipv6/proc.c
+++ b/net/ipv6/proc.c
@@ -36,13 +36,13 @@ static struct proc_dir_entry *proc_net_devsnmp6;
36static int sockstat6_seq_show(struct seq_file *seq, void *v) 36static int sockstat6_seq_show(struct seq_file *seq, void *v)
37{ 37{
38 seq_printf(seq, "TCP6: inuse %d\n", 38 seq_printf(seq, "TCP6: inuse %d\n",
39 sock_prot_inuse_get(&tcpv6_prot)); 39 sock_prot_inuse_get(&init_net, &tcpv6_prot));
40 seq_printf(seq, "UDP6: inuse %d\n", 40 seq_printf(seq, "UDP6: inuse %d\n",
41 sock_prot_inuse_get(&udpv6_prot)); 41 sock_prot_inuse_get(&init_net, &udpv6_prot));
42 seq_printf(seq, "UDPLITE6: inuse %d\n", 42 seq_printf(seq, "UDPLITE6: inuse %d\n",
43 sock_prot_inuse_get(&udplitev6_prot)); 43 sock_prot_inuse_get(&init_net, &udplitev6_prot));
44 seq_printf(seq, "RAW6: inuse %d\n", 44 seq_printf(seq, "RAW6: inuse %d\n",
45 sock_prot_inuse_get(&rawv6_prot)); 45 sock_prot_inuse_get(&init_net, &rawv6_prot));
46 seq_printf(seq, "FRAG6: inuse %d memory %d\n", 46 seq_printf(seq, "FRAG6: inuse %d memory %d\n",
47 ip6_frag_nqueues(&init_net), ip6_frag_mem(&init_net)); 47 ip6_frag_nqueues(&init_net), ip6_frag_mem(&init_net));
48 return 0; 48 return 0;