diff options
Diffstat (limited to 'net/ipv4/proc.c')
-rw-r--r-- | net/ipv4/proc.c | 68 |
1 files changed, 14 insertions, 54 deletions
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index a236154591fa..37ab5802ca08 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c | |||
@@ -45,7 +45,6 @@ | |||
45 | #include <net/sock.h> | 45 | #include <net/sock.h> |
46 | #include <net/raw.h> | 46 | #include <net/raw.h> |
47 | 47 | ||
48 | #ifdef CONFIG_PROC_FS | ||
49 | static int fold_prot_inuse(struct proto *proto) | 48 | static int fold_prot_inuse(struct proto *proto) |
50 | { | 49 | { |
51 | int res = 0; | 50 | int res = 0; |
@@ -88,19 +87,6 @@ static const struct file_operations sockstat_seq_fops = { | |||
88 | .release = single_release, | 87 | .release = single_release, |
89 | }; | 88 | }; |
90 | 89 | ||
91 | static unsigned long | ||
92 | fold_field(void *mib[], int offt) | ||
93 | { | ||
94 | unsigned long res = 0; | ||
95 | int i; | ||
96 | |||
97 | for_each_possible_cpu(i) { | ||
98 | res += *(((unsigned long *) per_cpu_ptr(mib[0], i)) + offt); | ||
99 | res += *(((unsigned long *) per_cpu_ptr(mib[1], i)) + offt); | ||
100 | } | ||
101 | return res; | ||
102 | } | ||
103 | |||
104 | /* snmp items */ | 90 | /* snmp items */ |
105 | static const struct snmp_mib snmp4_ipstats_list[] = { | 91 | static const struct snmp_mib snmp4_ipstats_list[] = { |
106 | SNMP_MIB_ITEM("InReceives", IPSTATS_MIB_INRECEIVES), | 92 | SNMP_MIB_ITEM("InReceives", IPSTATS_MIB_INRECEIVES), |
@@ -267,8 +253,8 @@ static int snmp_seq_show(struct seq_file *seq, void *v) | |||
267 | 253 | ||
268 | for (i = 0; snmp4_ipstats_list[i].name != NULL; i++) | 254 | for (i = 0; snmp4_ipstats_list[i].name != NULL; i++) |
269 | seq_printf(seq, " %lu", | 255 | seq_printf(seq, " %lu", |
270 | fold_field((void **) ip_statistics, | 256 | snmp_fold_field((void **)ip_statistics, |
271 | snmp4_ipstats_list[i].entry)); | 257 | snmp4_ipstats_list[i].entry)); |
272 | 258 | ||
273 | seq_puts(seq, "\nIcmp:"); | 259 | seq_puts(seq, "\nIcmp:"); |
274 | for (i = 0; snmp4_icmp_list[i].name != NULL; i++) | 260 | for (i = 0; snmp4_icmp_list[i].name != NULL; i++) |
@@ -277,8 +263,8 @@ static int snmp_seq_show(struct seq_file *seq, void *v) | |||
277 | seq_puts(seq, "\nIcmp:"); | 263 | seq_puts(seq, "\nIcmp:"); |
278 | for (i = 0; snmp4_icmp_list[i].name != NULL; i++) | 264 | for (i = 0; snmp4_icmp_list[i].name != NULL; i++) |
279 | seq_printf(seq, " %lu", | 265 | seq_printf(seq, " %lu", |
280 | fold_field((void **) icmp_statistics, | 266 | snmp_fold_field((void **)icmp_statistics, |
281 | snmp4_icmp_list[i].entry)); | 267 | snmp4_icmp_list[i].entry)); |
282 | 268 | ||
283 | seq_puts(seq, "\nTcp:"); | 269 | seq_puts(seq, "\nTcp:"); |
284 | for (i = 0; snmp4_tcp_list[i].name != NULL; i++) | 270 | for (i = 0; snmp4_tcp_list[i].name != NULL; i++) |
@@ -289,12 +275,12 @@ static int snmp_seq_show(struct seq_file *seq, void *v) | |||
289 | /* MaxConn field is signed, RFC 2012 */ | 275 | /* MaxConn field is signed, RFC 2012 */ |
290 | if (snmp4_tcp_list[i].entry == TCP_MIB_MAXCONN) | 276 | if (snmp4_tcp_list[i].entry == TCP_MIB_MAXCONN) |
291 | seq_printf(seq, " %ld", | 277 | seq_printf(seq, " %ld", |
292 | fold_field((void **) tcp_statistics, | 278 | snmp_fold_field((void **)tcp_statistics, |
293 | snmp4_tcp_list[i].entry)); | 279 | snmp4_tcp_list[i].entry)); |
294 | else | 280 | else |
295 | seq_printf(seq, " %lu", | 281 | seq_printf(seq, " %lu", |
296 | fold_field((void **) tcp_statistics, | 282 | snmp_fold_field((void **)tcp_statistics, |
297 | snmp4_tcp_list[i].entry)); | 283 | snmp4_tcp_list[i].entry)); |
298 | } | 284 | } |
299 | 285 | ||
300 | seq_puts(seq, "\nUdp:"); | 286 | seq_puts(seq, "\nUdp:"); |
@@ -304,8 +290,8 @@ static int snmp_seq_show(struct seq_file *seq, void *v) | |||
304 | seq_puts(seq, "\nUdp:"); | 290 | seq_puts(seq, "\nUdp:"); |
305 | for (i = 0; snmp4_udp_list[i].name != NULL; i++) | 291 | for (i = 0; snmp4_udp_list[i].name != NULL; i++) |
306 | seq_printf(seq, " %lu", | 292 | seq_printf(seq, " %lu", |
307 | fold_field((void **) udp_statistics, | 293 | snmp_fold_field((void **)udp_statistics, |
308 | snmp4_udp_list[i].entry)); | 294 | snmp4_udp_list[i].entry)); |
309 | 295 | ||
310 | /* the UDP and UDP-Lite MIBs are the same */ | 296 | /* the UDP and UDP-Lite MIBs are the same */ |
311 | seq_puts(seq, "\nUdpLite:"); | 297 | seq_puts(seq, "\nUdpLite:"); |
@@ -315,8 +301,8 @@ static int snmp_seq_show(struct seq_file *seq, void *v) | |||
315 | seq_puts(seq, "\nUdpLite:"); | 301 | seq_puts(seq, "\nUdpLite:"); |
316 | for (i = 0; snmp4_udp_list[i].name != NULL; i++) | 302 | for (i = 0; snmp4_udp_list[i].name != NULL; i++) |
317 | seq_printf(seq, " %lu", | 303 | seq_printf(seq, " %lu", |
318 | fold_field((void **) udplite_statistics, | 304 | snmp_fold_field((void **)udplite_statistics, |
319 | snmp4_udp_list[i].entry) ); | 305 | snmp4_udp_list[i].entry)); |
320 | 306 | ||
321 | seq_putc(seq, '\n'); | 307 | seq_putc(seq, '\n'); |
322 | return 0; | 308 | return 0; |
@@ -349,8 +335,8 @@ static int netstat_seq_show(struct seq_file *seq, void *v) | |||
349 | seq_puts(seq, "\nTcpExt:"); | 335 | seq_puts(seq, "\nTcpExt:"); |
350 | for (i = 0; snmp4_net_list[i].name != NULL; i++) | 336 | for (i = 0; snmp4_net_list[i].name != NULL; i++) |
351 | seq_printf(seq, " %lu", | 337 | seq_printf(seq, " %lu", |
352 | fold_field((void **) net_statistics, | 338 | snmp_fold_field((void **)net_statistics, |
353 | snmp4_net_list[i].entry)); | 339 | snmp4_net_list[i].entry)); |
354 | 340 | ||
355 | seq_putc(seq, '\n'); | 341 | seq_putc(seq, '\n'); |
356 | return 0; | 342 | return 0; |
@@ -391,30 +377,4 @@ out_netstat: | |||
391 | rc = -ENOMEM; | 377 | rc = -ENOMEM; |
392 | goto out; | 378 | goto out; |
393 | } | 379 | } |
394 | #endif | ||
395 | |||
396 | int snmp_mib_init(void *ptr[2], size_t mibsize, size_t mibalign) | ||
397 | { | ||
398 | BUG_ON(ptr == NULL); | ||
399 | ptr[0] = __alloc_percpu(mibsize); | ||
400 | if (!ptr[0]) | ||
401 | goto err0; | ||
402 | ptr[1] = __alloc_percpu(mibsize); | ||
403 | if (!ptr[1]) | ||
404 | goto err1; | ||
405 | return 0; | ||
406 | err1: | ||
407 | free_percpu(ptr[0]); | ||
408 | ptr[0] = NULL; | ||
409 | err0: | ||
410 | return -ENOMEM; | ||
411 | } | ||
412 | |||
413 | void snmp_mib_free(void *ptr[2]) | ||
414 | { | ||
415 | BUG_ON(ptr == NULL); | ||
416 | free_percpu(ptr[0]); | ||
417 | free_percpu(ptr[1]); | ||
418 | ptr[0] = ptr[1] = NULL; | ||
419 | } | ||
420 | 380 | ||