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.
6 * This file implements the various access functions for the
7 * PROC file system. This is very similar to the IPv4 version,
8 * except it reports the sockets in the INET6 address family.
10 * Version: $Id: proc.c,v 1.15 2000/07/07 22:29:42 davem Exp $
12 * Authors: David S. Miller (davem@caip.rutgers.edu)
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
19 #include <linux/sched.h>
20 #include <linux/socket.h>
21 #include <linux/net.h>
22 #include <linux/in6.h>
23 #include <linux/stddef.h>
26 #include <net/transp_v6.h>
29 static int fold_prot_inuse(struct proto
*proto
)
34 for (cpu
=0; cpu
<smp_num_cpus
; cpu
++)
35 res
+= proto
->stats
[cpu_logical_map(cpu
)].inuse
;
40 int afinet6_get_info(char *buffer
, char **start
, off_t offset
, int length
, int dummy
)
43 len
+= sprintf(buffer
+len
, "TCP6: inuse %d\n",
44 fold_prot_inuse(&tcpv6_prot
));
45 len
+= sprintf(buffer
+len
, "UDP6: inuse %d\n",
46 fold_prot_inuse(&udpv6_prot
));
47 len
+= sprintf(buffer
+len
, "RAW6: inuse %d\n",
48 fold_prot_inuse(&rawv6_prot
));
49 len
+= sprintf(buffer
+len
, "FRAG6: inuse %d memory %d\n",
50 ip6_frag_nqueues
, atomic_read(&ip6_frag_mem
));
51 *start
= buffer
+ offset
;
65 /* ipv6 mib according to draft-ietf-ipngwg-ipv6-mib-04 */
66 #define SNMP6_GEN(x) { #x , &ipv6_statistics[0].x, sizeof(struct ipv6_mib)/sizeof(unsigned long) }
67 SNMP6_GEN(Ip6InReceives
),
68 SNMP6_GEN(Ip6InHdrErrors
),
69 SNMP6_GEN(Ip6InTooBigErrors
),
70 SNMP6_GEN(Ip6InNoRoutes
),
71 SNMP6_GEN(Ip6InAddrErrors
),
72 SNMP6_GEN(Ip6InUnknownProtos
),
73 SNMP6_GEN(Ip6InTruncatedPkts
),
74 SNMP6_GEN(Ip6InDiscards
),
75 SNMP6_GEN(Ip6InDelivers
),
76 SNMP6_GEN(Ip6OutForwDatagrams
),
77 SNMP6_GEN(Ip6OutRequests
),
78 SNMP6_GEN(Ip6OutDiscards
),
79 SNMP6_GEN(Ip6OutNoRoutes
),
80 SNMP6_GEN(Ip6ReasmTimeout
),
81 SNMP6_GEN(Ip6ReasmReqds
),
82 SNMP6_GEN(Ip6ReasmOKs
),
83 SNMP6_GEN(Ip6ReasmFails
),
84 SNMP6_GEN(Ip6FragOKs
),
85 SNMP6_GEN(Ip6FragFails
),
86 SNMP6_GEN(Ip6FragCreates
),
87 SNMP6_GEN(Ip6InMcastPkts
),
88 SNMP6_GEN(Ip6OutMcastPkts
),
90 /* icmpv6 mib according to draft-ietf-ipngwg-ipv6-icmp-mib-02
92 Exceptions: {In|Out}AdminProhibs are removed, because I see
93 no good reasons to account them separately
94 of another dest.unreachs.
95 OutErrs is zero identically.
97 OutRouterAdvertisements too.
98 OutGroupMembQueries too.
100 #define SNMP6_GEN(x) { #x , &icmpv6_statistics[0].x, sizeof(struct icmpv6_mib)/sizeof(unsigned long) }
101 SNMP6_GEN(Icmp6InMsgs
),
102 SNMP6_GEN(Icmp6InErrors
),
103 SNMP6_GEN(Icmp6InDestUnreachs
),
104 SNMP6_GEN(Icmp6InPktTooBigs
),
105 SNMP6_GEN(Icmp6InTimeExcds
),
106 SNMP6_GEN(Icmp6InParmProblems
),
107 SNMP6_GEN(Icmp6InEchos
),
108 SNMP6_GEN(Icmp6InEchoReplies
),
109 SNMP6_GEN(Icmp6InGroupMembQueries
),
110 SNMP6_GEN(Icmp6InGroupMembResponses
),
111 SNMP6_GEN(Icmp6InGroupMembReductions
),
112 SNMP6_GEN(Icmp6InRouterSolicits
),
113 SNMP6_GEN(Icmp6InRouterAdvertisements
),
114 SNMP6_GEN(Icmp6InNeighborSolicits
),
115 SNMP6_GEN(Icmp6InNeighborAdvertisements
),
116 SNMP6_GEN(Icmp6InRedirects
),
117 SNMP6_GEN(Icmp6OutMsgs
),
118 SNMP6_GEN(Icmp6OutDestUnreachs
),
119 SNMP6_GEN(Icmp6OutPktTooBigs
),
120 SNMP6_GEN(Icmp6OutTimeExcds
),
121 SNMP6_GEN(Icmp6OutParmProblems
),
122 SNMP6_GEN(Icmp6OutEchoReplies
),
123 SNMP6_GEN(Icmp6OutRouterSolicits
),
124 SNMP6_GEN(Icmp6OutNeighborSolicits
),
125 SNMP6_GEN(Icmp6OutNeighborAdvertisements
),
126 SNMP6_GEN(Icmp6OutRedirects
),
127 SNMP6_GEN(Icmp6OutGroupMembResponses
),
128 SNMP6_GEN(Icmp6OutGroupMembReductions
),
130 #define SNMP6_GEN(x) { "Udp6" #x , &udp_stats_in6[0].Udp##x, sizeof(struct udp_mib)/sizeof(unsigned long) }
131 SNMP6_GEN(InDatagrams
),
134 SNMP6_GEN(OutDatagrams
)
138 static unsigned long fold_field(unsigned long *ptr
, int size
)
140 unsigned long res
= 0;
143 for (i
=0; i
<smp_num_cpus
; i
++) {
144 res
+= ptr
[2*cpu_logical_map(i
)*size
];
145 res
+= ptr
[(2*cpu_logical_map(i
)+1)*size
];
151 int afinet6_get_snmp(char *buffer
, char **start
, off_t offset
, int length
)
156 for (i
=0; i
<sizeof(snmp6_list
)/sizeof(snmp6_list
[0]); i
++)
157 len
+= sprintf(buffer
+len
, "%-32s\t%ld\n", snmp6_list
[i
].name
,
158 fold_field(snmp6_list
[i
].ptr
, snmp6_list
[i
].mibsize
));
167 *start
= buffer
+ offset
;