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. It is mainly used for debugging and
10 * Version: $Id: proc.c,v 1.36 1999/07/02 11:26:34 davem Exp $
12 * Authors: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
13 * Gerald J. Heim, <heim@peanuts.informatik.uni-tuebingen.de>
14 * Fred Baumgarten, <dc6iq@insu1.etec.uni-karlsruhe.de>
15 * Erik Schoenfelder, <schoenfr@ibr.cs.tu-bs.de>
18 * Alan Cox : UDP sockets show the rxqueue/txqueue
19 * using hint flag for the netinfo.
20 * Pauline Middelink : identd support
21 * Alan Cox : Make /proc safer.
22 * Erik Schoenfelder : /proc/net/snmp
23 * Alan Cox : Handle dead sockets properly.
24 * Gerhard Koerting : Show both timers
25 * Alan Cox : Allow inode to be NULL (kernel socket)
26 * Andi Kleen : Add support for open_requests and
27 * split functions for more readibility.
28 * Andi Kleen : Add support for /proc/net/netstat
30 * This program is free software; you can redistribute it and/or
31 * modify it under the terms of the GNU General Public License
32 * as published by the Free Software Foundation; either version
33 * 2 of the License, or (at your option) any later version.
35 #include <asm/system.h>
36 #include <linux/sched.h>
37 #include <linux/socket.h>
38 #include <linux/net.h>
41 #include <linux/param.h>
42 #include <linux/inet.h>
43 #include <linux/netdevice.h>
46 #include <net/protocol.h>
49 #include <linux/skbuff.h>
54 * Report socket allocation statistics [mea@utu.fi]
56 int afinet_get_info(char *buffer
, char **start
, off_t offset
, int length
, int dummy
)
58 /* From net/socket.c */
59 extern int socket_get_info(char *, char **, off_t
, int);
61 int len
= socket_get_info(buffer
,start
,offset
,length
);
63 len
+= sprintf(buffer
+len
,"TCP: inuse %d highest %d\n",
64 tcp_prot
.inuse
, tcp_prot
.highestinuse
);
65 len
+= sprintf(buffer
+len
,"UDP: inuse %d highest %d\n",
66 udp_prot
.inuse
, udp_prot
.highestinuse
);
67 len
+= sprintf(buffer
+len
,"RAW: inuse %d highest %d\n",
68 raw_prot
.inuse
, raw_prot
.highestinuse
);
74 *start
= buffer
+ offset
;
85 * Called from the PROCfs module. This outputs /proc/net/snmp.
88 int snmp_get_info(char *buffer
, char **start
, off_t offset
, int length
, int dummy
)
90 extern struct tcp_mib tcp_statistics
;
91 extern struct udp_mib udp_statistics
;
94 extern unsigned long tcp_rx_miss, tcp_rx_hit1,tcp_rx_hit2;
97 len
= sprintf (buffer
,
98 "Ip: Forwarding DefaultTTL InReceives InHdrErrors InAddrErrors ForwDatagrams InUnknownProtos InDiscards InDelivers OutRequests OutDiscards OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs ReasmFails FragOKs FragFails FragCreates\n"
99 "Ip: %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
100 ip_statistics
.IpForwarding
, ip_statistics
.IpDefaultTTL
,
101 ip_statistics
.IpInReceives
, ip_statistics
.IpInHdrErrors
,
102 ip_statistics
.IpInAddrErrors
, ip_statistics
.IpForwDatagrams
,
103 ip_statistics
.IpInUnknownProtos
, ip_statistics
.IpInDiscards
,
104 ip_statistics
.IpInDelivers
, ip_statistics
.IpOutRequests
,
105 ip_statistics
.IpOutDiscards
, ip_statistics
.IpOutNoRoutes
,
106 ip_statistics
.IpReasmTimeout
, ip_statistics
.IpReasmReqds
,
107 ip_statistics
.IpReasmOKs
, ip_statistics
.IpReasmFails
,
108 ip_statistics
.IpFragOKs
, ip_statistics
.IpFragFails
,
109 ip_statistics
.IpFragCreates
);
111 len
+= sprintf (buffer
+ len
,
112 "Icmp: InMsgs InErrors InDestUnreachs InTimeExcds InParmProbs InSrcQuenchs InRedirects InEchos InEchoReps InTimestamps InTimestampReps InAddrMasks InAddrMaskReps OutMsgs OutErrors OutDestUnreachs OutTimeExcds OutParmProbs OutSrcQuenchs OutRedirects OutEchos OutEchoReps OutTimestamps OutTimestampReps OutAddrMasks OutAddrMaskReps\n"
113 "Icmp: %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
114 icmp_statistics
.IcmpInMsgs
, icmp_statistics
.IcmpInErrors
,
115 icmp_statistics
.IcmpInDestUnreachs
, icmp_statistics
.IcmpInTimeExcds
,
116 icmp_statistics
.IcmpInParmProbs
, icmp_statistics
.IcmpInSrcQuenchs
,
117 icmp_statistics
.IcmpInRedirects
, icmp_statistics
.IcmpInEchos
,
118 icmp_statistics
.IcmpInEchoReps
, icmp_statistics
.IcmpInTimestamps
,
119 icmp_statistics
.IcmpInTimestampReps
, icmp_statistics
.IcmpInAddrMasks
,
120 icmp_statistics
.IcmpInAddrMaskReps
, icmp_statistics
.IcmpOutMsgs
,
121 icmp_statistics
.IcmpOutErrors
, icmp_statistics
.IcmpOutDestUnreachs
,
122 icmp_statistics
.IcmpOutTimeExcds
, icmp_statistics
.IcmpOutParmProbs
,
123 icmp_statistics
.IcmpOutSrcQuenchs
, icmp_statistics
.IcmpOutRedirects
,
124 icmp_statistics
.IcmpOutEchos
, icmp_statistics
.IcmpOutEchoReps
,
125 icmp_statistics
.IcmpOutTimestamps
, icmp_statistics
.IcmpOutTimestampReps
,
126 icmp_statistics
.IcmpOutAddrMasks
, icmp_statistics
.IcmpOutAddrMaskReps
);
128 len
+= sprintf (buffer
+ len
,
129 "Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts\n"
130 "Tcp: %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
131 tcp_statistics
.TcpRtoAlgorithm
, tcp_statistics
.TcpRtoMin
,
132 tcp_statistics
.TcpRtoMax
, tcp_statistics
.TcpMaxConn
,
133 tcp_statistics
.TcpActiveOpens
, tcp_statistics
.TcpPassiveOpens
,
134 tcp_statistics
.TcpAttemptFails
, tcp_statistics
.TcpEstabResets
,
135 tcp_statistics
.TcpCurrEstab
, tcp_statistics
.TcpInSegs
,
136 tcp_statistics
.TcpOutSegs
, tcp_statistics
.TcpRetransSegs
,
137 tcp_statistics
.TcpInErrs
, tcp_statistics
.TcpOutRsts
);
139 len
+= sprintf (buffer
+ len
,
140 "Udp: InDatagrams NoPorts InErrors OutDatagrams\nUdp: %lu %lu %lu %lu\n",
141 udp_statistics
.UdpInDatagrams
, udp_statistics
.UdpNoPorts
,
142 udp_statistics
.UdpInErrors
, udp_statistics
.UdpOutDatagrams
);
144 len += sprintf( buffer + len,
145 "TCP fast path RX: H2: %ul H1: %ul L: %ul\n",
146 tcp_rx_hit2,tcp_rx_hit1,tcp_rx_miss);
154 *start
= buffer
+ offset
;
164 * Output /proc/net/netstat
167 int netstat_get_info(char *buffer
, char **start
, off_t offset
, int length
, int dummy
)
169 extern struct linux_mib net_statistics
;
172 len
= sprintf(buffer
,
173 "TcpExt: SyncookiesSent SyncookiesRecv SyncookiesFailed"
174 " EmbryonicRsts PruneCalled RcvPruned OfoPruned"
175 " OutOfWindowIcmps LockDroppedIcmps\n"
176 "TcpExt: %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
177 net_statistics
.SyncookiesSent
,
178 net_statistics
.SyncookiesRecv
,
179 net_statistics
.SyncookiesFailed
,
180 net_statistics
.EmbryonicRsts
,
181 net_statistics
.PruneCalled
,
182 net_statistics
.RcvPruned
,
183 net_statistics
.OfoPruned
,
184 net_statistics
.OutOfWindowIcmps
,
185 net_statistics
.LockDroppedIcmps
);
192 *start
= buffer
+ offset
;