Commit 2f746ed2 authored by Nivedita Singhvi's avatar Nivedita Singhvi Committed by David S. Miller

[TCP]: Missing SNMP stats.

parent 12332a86
......@@ -31,6 +31,7 @@
#include <linux/percpu.h>
#include <net/checksum.h>
#include <net/sock.h>
#include <net/snmp.h>
#if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE)
#include <linux/ipv6.h>
#endif
......@@ -639,6 +640,8 @@ DECLARE_SNMP_STAT(struct tcp_mib, tcp_statistics);
#define TCP_INC_STATS_BH(field) SNMP_INC_STATS_BH(tcp_statistics, field)
#define TCP_INC_STATS_USER(field) SNMP_INC_STATS_USER(tcp_statistics, field)
#define TCP_DEC_STATS(field) SNMP_DEC_STATS(tcp_statistics, field)
#define TCP_ADD_STATS_BH(field, val) SNMP_ADD_STATS_BH(tcp_statistics, field, val)
#define TCP_ADD_STATS_USER(field, val) SNMP_ADD_STATS_USER(tcp_statistics, field, val)
extern __inline__ void tcp_put_port(struct sock *sk);
extern void tcp_inherit_port(struct sock *sk, struct sock *child);
......@@ -1398,6 +1401,9 @@ static __inline__ void tcp_set_state(struct sock *sk, int state)
break;
case TCP_CLOSE:
if (oldstate == TCP_CLOSE_WAIT || oldstate == TCP_ESTABLISHED)
TCP_INC_STATS(TcpEstabResets);
sk->prot->unhash(sk);
if (sk->prev && !(sk->userlocks&SOCK_BINDPORT_LOCK))
tcp_put_port(sk);
......@@ -1878,4 +1884,13 @@ static inline int tcp_use_frto(const struct sock *sk)
tp->snd_una + tp->snd_wnd));
}
static inline void tcp_mib_init(void)
{
/* See RFC 2012 */
TCP_ADD_STATS_USER(TcpRtoAlgorithm, 1);
TCP_ADD_STATS_USER(TcpRtoMin, TCP_RTO_MIN*1000/HZ);
TCP_ADD_STATS_USER(TcpRtoMax, TCP_RTO_MAX*1000/HZ);
TCP_ADD_STATS_USER(TcpMaxConn, -1);
}
#endif /* _TCP_H */
......@@ -1108,6 +1108,8 @@ static int __init init_ipv4_mibs(void)
}
}
(void) tcp_mib_init();
return 0;
}
......
......@@ -143,9 +143,15 @@ static int snmp_seq_show(struct seq_file *seq, void *v)
"InSegs OutSegs RetransSegs InErrs OutRsts\nTcp:");
for (i = 0;
i < offsetof(struct tcp_mib, __pad) / sizeof(unsigned long); i++)
i < offsetof(struct tcp_mib, __pad) / sizeof(unsigned long); i++) {
if (i == (offsetof(struct tcp_mib, TcpMaxConn) / sizeof(unsigned long)))
/* MaxConn field is negative, RFC 2012 */
seq_printf(seq, " %ld",
fold_field((void **) tcp_statistics, i));
else
seq_printf(seq, " %lu",
fold_field((void **) tcp_statistics, i));
}
seq_printf(seq, "\nUdp: InDatagrams NoPorts InErrors OutDatagrams\n"
"Udp:");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment