proc.c (bba9525520b6028ecbe7486e13216e9ede8636be) proc.c (3617d9496cd92dcca4d0893191d95554590d8d9f)
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * This file implements the various access functions for the
7 * PROC file system. It is mainly used for debugging and
8 * statistics.

--- 63 unchanged lines hidden (view full) ---

72 seq_printf(seq, "RAW: inuse %d\n",
73 sock_prot_inuse_get(net, &raw_prot));
74 seq_printf(seq, "FRAG: inuse %u memory %lu\n",
75 atomic_read(&net->ipv4.frags.rhashtable.nelems),
76 frag_mem_limit(&net->ipv4.frags));
77 return 0;
78}
79
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * This file implements the various access functions for the
7 * PROC file system. It is mainly used for debugging and
8 * statistics.

--- 63 unchanged lines hidden (view full) ---

72 seq_printf(seq, "RAW: inuse %d\n",
73 sock_prot_inuse_get(net, &raw_prot));
74 seq_printf(seq, "FRAG: inuse %u memory %lu\n",
75 atomic_read(&net->ipv4.frags.rhashtable.nelems),
76 frag_mem_limit(&net->ipv4.frags));
77 return 0;
78}
79
80static int sockstat_seq_open(struct inode *inode, struct file *file)
81{
82 return single_open_net(inode, file, sockstat_seq_show);
83}
84
85static const struct file_operations sockstat_seq_fops = {
86 .open = sockstat_seq_open,
87 .read = seq_read,
88 .llseek = seq_lseek,
89 .release = single_release_net,
90};
91
92/* snmp items */
93static const struct snmp_mib snmp4_ipstats_list[] = {
94 SNMP_MIB_ITEM("InReceives", IPSTATS_MIB_INPKTS),
95 SNMP_MIB_ITEM("InHdrErrors", IPSTATS_MIB_INHDRERRORS),
96 SNMP_MIB_ITEM("InAddrErrors", IPSTATS_MIB_INADDRERRORS),
97 SNMP_MIB_ITEM("ForwDatagrams", IPSTATS_MIB_OUTFORWDATAGRAMS),
98 SNMP_MIB_ITEM("InUnknownProtos", IPSTATS_MIB_INUNKNOWNPROTOS),
99 SNMP_MIB_ITEM("InDiscards", IPSTATS_MIB_INDISCARDS),

--- 355 unchanged lines hidden (view full) ---

455 icmp_put(seq); /* RFC 2011 compatibility */
456 icmpmsg_put(seq);
457
458 snmp_seq_show_tcp_udp(seq, v);
459
460 return 0;
461}
462
80/* snmp items */
81static const struct snmp_mib snmp4_ipstats_list[] = {
82 SNMP_MIB_ITEM("InReceives", IPSTATS_MIB_INPKTS),
83 SNMP_MIB_ITEM("InHdrErrors", IPSTATS_MIB_INHDRERRORS),
84 SNMP_MIB_ITEM("InAddrErrors", IPSTATS_MIB_INADDRERRORS),
85 SNMP_MIB_ITEM("ForwDatagrams", IPSTATS_MIB_OUTFORWDATAGRAMS),
86 SNMP_MIB_ITEM("InUnknownProtos", IPSTATS_MIB_INUNKNOWNPROTOS),
87 SNMP_MIB_ITEM("InDiscards", IPSTATS_MIB_INDISCARDS),

--- 355 unchanged lines hidden (view full) ---

443 icmp_put(seq); /* RFC 2011 compatibility */
444 icmpmsg_put(seq);
445
446 snmp_seq_show_tcp_udp(seq, v);
447
448 return 0;
449}
450
463static int snmp_seq_open(struct inode *inode, struct file *file)
464{
465 return single_open_net(inode, file, snmp_seq_show);
466}
467
468static const struct file_operations snmp_seq_fops = {
469 .open = snmp_seq_open,
470 .read = seq_read,
471 .llseek = seq_lseek,
472 .release = single_release_net,
473};
474
475
476
477/*
478 * Output /proc/net/netstat
479 */
480static int netstat_seq_show(struct seq_file *seq, void *v)
481{
482 int i;
483 struct net *net = seq->private;
484

--- 17 unchanged lines hidden (view full) ---

502 snmp_fold_field64(net->mib.ip_statistics,
503 snmp4_ipextstats_list[i].entry,
504 offsetof(struct ipstats_mib, syncp)));
505
506 seq_putc(seq, '\n');
507 return 0;
508}
509
451/*
452 * Output /proc/net/netstat
453 */
454static int netstat_seq_show(struct seq_file *seq, void *v)
455{
456 int i;
457 struct net *net = seq->private;
458

--- 17 unchanged lines hidden (view full) ---

476 snmp_fold_field64(net->mib.ip_statistics,
477 snmp4_ipextstats_list[i].entry,
478 offsetof(struct ipstats_mib, syncp)));
479
480 seq_putc(seq, '\n');
481 return 0;
482}
483
510static int netstat_seq_open(struct inode *inode, struct file *file)
511{
512 return single_open_net(inode, file, netstat_seq_show);
513}
514
515static const struct file_operations netstat_seq_fops = {
516 .open = netstat_seq_open,
517 .read = seq_read,
518 .llseek = seq_lseek,
519 .release = single_release_net,
520};
521
522static __net_init int ip_proc_init_net(struct net *net)
523{
484static __net_init int ip_proc_init_net(struct net *net)
485{
524 if (!proc_create("sockstat", 0444, net->proc_net,
525 &sockstat_seq_fops))
486 if (!proc_create_net_single("sockstat", 0444, net->proc_net,
487 sockstat_seq_show, NULL))
526 goto out_sockstat;
488 goto out_sockstat;
527 if (!proc_create("netstat", 0444, net->proc_net, &netstat_seq_fops))
489 if (!proc_create_net_single("netstat", 0444, net->proc_net,
490 netstat_seq_show, NULL))
528 goto out_netstat;
491 goto out_netstat;
529 if (!proc_create("snmp", 0444, net->proc_net, &snmp_seq_fops))
492 if (!proc_create_net_single("snmp", 0444, net->proc_net, snmp_seq_show,
493 NULL))
530 goto out_snmp;
531
532 return 0;
533
534out_snmp:
535 remove_proc_entry("netstat", net->proc_net);
536out_netstat:
537 remove_proc_entry("sockstat", net->proc_net);

--- 20 unchanged lines hidden ---
494 goto out_snmp;
495
496 return 0;
497
498out_snmp:
499 remove_proc_entry("netstat", net->proc_net);
500out_netstat:
501 remove_proc_entry("sockstat", net->proc_net);

--- 20 unchanged lines hidden ---