aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/Makefile4
-rw-r--r--net/ipv4/af_inet.c40
-rw-r--r--net/ipv4/proc.c68
3 files changed, 56 insertions, 56 deletions
diff --git a/net/ipv4/Makefile b/net/ipv4/Makefile
index 3bd25f56f5da..4ff6c151d7f3 100644
--- a/net/ipv4/Makefile
+++ b/net/ipv4/Makefile
@@ -10,11 +10,11 @@ obj-y := route.o inetpeer.o protocol.o \
10 tcp_minisocks.o tcp_cong.o \ 10 tcp_minisocks.o tcp_cong.o \
11 datagram.o raw.o udp.o udplite.o \ 11 datagram.o raw.o udp.o udplite.o \
12 arp.o icmp.o devinet.o af_inet.o igmp.o \ 12 arp.o icmp.o devinet.o af_inet.o igmp.o \
13 sysctl_net_ipv4.o fib_frontend.o fib_semantics.o \ 13 sysctl_net_ipv4.o fib_frontend.o fib_semantics.o
14 proc.o
15 14
16obj-$(CONFIG_IP_FIB_HASH) += fib_hash.o 15obj-$(CONFIG_IP_FIB_HASH) += fib_hash.o
17obj-$(CONFIG_IP_FIB_TRIE) += fib_trie.o 16obj-$(CONFIG_IP_FIB_TRIE) += fib_trie.o
17obj-$(CONFIG_PROC_FS) += proc.o
18obj-$(CONFIG_IP_MULTIPLE_TABLES) += fib_rules.o 18obj-$(CONFIG_IP_MULTIPLE_TABLES) += fib_rules.o
19obj-$(CONFIG_IP_MROUTE) += ipmr.o 19obj-$(CONFIG_IP_MROUTE) += ipmr.o
20obj-$(CONFIG_NET_IPIP) += ipip.o 20obj-$(CONFIG_NET_IPIP) += ipip.o
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index a33ca7e7e8f8..16aae8ef5555 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1219,6 +1219,46 @@ out:
1219 return segs; 1219 return segs;
1220} 1220}
1221 1221
1222unsigned long snmp_fold_field(void *mib[], int offt)
1223{
1224 unsigned long res = 0;
1225 int i;
1226
1227 for_each_possible_cpu(i) {
1228 res += *(((unsigned long *) per_cpu_ptr(mib[0], i)) + offt);
1229 res += *(((unsigned long *) per_cpu_ptr(mib[1], i)) + offt);
1230 }
1231 return res;
1232}
1233EXPORT_SYMBOL_GPL(snmp_fold_field);
1234
1235int snmp_mib_init(void *ptr[2], size_t mibsize, size_t mibalign)
1236{
1237 BUG_ON(ptr == NULL);
1238 ptr[0] = __alloc_percpu(mibsize);
1239 if (!ptr[0])
1240 goto err0;
1241 ptr[1] = __alloc_percpu(mibsize);
1242 if (!ptr[1])
1243 goto err1;
1244 return 0;
1245err1:
1246 free_percpu(ptr[0]);
1247 ptr[0] = NULL;
1248err0:
1249 return -ENOMEM;
1250}
1251EXPORT_SYMBOL_GPL(snmp_mib_init);
1252
1253void snmp_mib_free(void *ptr[2])
1254{
1255 BUG_ON(ptr == NULL);
1256 free_percpu(ptr[0]);
1257 free_percpu(ptr[1]);
1258 ptr[0] = ptr[1] = NULL;
1259}
1260EXPORT_SYMBOL_GPL(snmp_mib_free);
1261
1222#ifdef CONFIG_IP_MULTICAST 1262#ifdef CONFIG_IP_MULTICAST
1223static struct net_protocol igmp_protocol = { 1263static struct net_protocol igmp_protocol = {
1224 .handler = igmp_rcv, 1264 .handler = igmp_rcv,
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
49static int fold_prot_inuse(struct proto *proto) 48static 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
91static unsigned long
92fold_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 */
105static const struct snmp_mib snmp4_ipstats_list[] = { 91static 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
396int 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;
406err1:
407 free_percpu(ptr[0]);
408 ptr[0] = NULL;
409err0:
410 return -ENOMEM;
411}
412
413void 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