summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorReyk Floeter <reyk@cvs.openbsd.org>2007-12-13 20:00:54 +0000
committerReyk Floeter <reyk@cvs.openbsd.org>2007-12-13 20:00:54 +0000
commit90654a32a12cd0e30f6adb846ff6e9e5e6682a28 (patch)
treee8f59de8c6fe04c760d9e46528cb22f1da0c1cfc /sys
parentb03a990aaf0a66e97ca7dd68b5f8b065d05e4b95 (diff)
implement sysctls to report IP, TCP, UDP, and ICMP statistics and
change netstat to use them instead of accessing kvm for it. more protocols will be added later. discussed with deraadt@ claudio@ gilles@ ok deraadt@
Diffstat (limited to 'sys')
-rw-r--r--sys/netinet/icmp_var.h7
-rw-r--r--sys/netinet/in.h11
-rw-r--r--sys/netinet/ip_icmp.c7
-rw-r--r--sys/netinet/ip_input.c7
-rw-r--r--sys/netinet/tcp_usrreq.c9
-rw-r--r--sys/netinet/tcp_var.h7
-rw-r--r--sys/netinet/udp_usrreq.c9
-rw-r--r--sys/netinet/udp_var.h7
8 files changed, 50 insertions, 14 deletions
diff --git a/sys/netinet/icmp_var.h b/sys/netinet/icmp_var.h
index b759744656a..c94acb94503 100644
--- a/sys/netinet/icmp_var.h
+++ b/sys/netinet/icmp_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: icmp_var.h,v 1.12 2004/02/15 11:16:08 markus Exp $ */
+/* $OpenBSD: icmp_var.h,v 1.13 2007/12/13 20:00:53 reyk Exp $ */
/* $NetBSD: icmp_var.h,v 1.8 1995/03/26 20:32:19 jtc Exp $ */
/*
@@ -64,7 +64,8 @@ struct icmpstat {
#define ICMPCTL_REDIRACCEPT 4 /* Accept redirects from routers */
#define ICMPCTL_REDIRTIMEOUT 5 /* Remove routes added via redirects */
#define ICMPCTL_TSTAMPREPL 6 /* allow replies to timestamp requests */
-#define ICMPCTL_MAXID 7
+#define ICMPCTL_STATS 7 /* ICMP statistics */
+#define ICMPCTL_MAXID 8
#define ICMPCTL_NAMES { \
{ 0, 0 }, \
@@ -74,6 +75,7 @@ struct icmpstat {
{ "rediraccept", CTLTYPE_INT }, \
{ "redirtimeout", CTLTYPE_INT }, \
{ "tstamprepl", CTLTYPE_INT }, \
+ { "stats", CTLTYPE_STRUCT } \
}
#define ICMPCTL_VARS { \
@@ -84,6 +86,7 @@ struct icmpstat {
&icmp_rediraccept, \
NULL, \
&icmptstamprepl, \
+ NULL \
}
#ifdef _KERNEL
diff --git a/sys/netinet/in.h b/sys/netinet/in.h
index 5cfdf0e66c2..1a2e3a98897 100644
--- a/sys/netinet/in.h
+++ b/sys/netinet/in.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: in.h,v 1.74 2007/09/18 18:56:02 markus Exp $ */
+/* $OpenBSD: in.h,v 1.75 2007/12/13 20:00:53 reyk Exp $ */
/* $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ */
/*
@@ -482,7 +482,8 @@ struct ip_mreq {
#define IPCTL_IFQUEUE 30
#define IPCTL_MFORWARDING 31
#define IPCTL_MULTIPATH 32
-#define IPCTL_MAXID 33
+#define IPCTL_STATS 33 /* IP statistics */
+#define IPCTL_MAXID 34
#define IPCTL_NAMES { \
{ 0, 0 }, \
@@ -517,7 +518,8 @@ struct ip_mreq {
{ "ipsec-comp-alg", CTLTYPE_STRING }, \
{ "ifq", CTLTYPE_NODE }, \
{ "mforwarding", CTLTYPE_INT }, \
- { "multipath", CTLTYPE_INT } \
+ { "multipath", CTLTYPE_INT }, \
+ { "stats", CTLTYPE_STRUCT } \
}
#define IPCTL_VARS { \
NULL, \
@@ -552,7 +554,8 @@ struct ip_mreq {
NULL, \
NULL, \
&ipmforwarding, \
- &ipmultipath \
+ &ipmultipath, \
+ NULL \
}
/* INET6 stuff */
diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c
index f838357521d..bd727af3b58 100644
--- a/sys/netinet/ip_icmp.c
+++ b/sys/netinet/ip_icmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_icmp.c,v 1.77 2007/11/24 12:59:28 jmc Exp $ */
+/* $OpenBSD: ip_icmp.c,v 1.78 2007/12/13 20:00:53 reyk Exp $ */
/* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */
/*
@@ -842,6 +842,11 @@ icmp_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
break;
}
+ case ICMPCTL_STATS:
+ if (newp != NULL)
+ return (EPERM);
+ return (sysctl_struct(oldp, oldlenp, newp, newlen,
+ &icmpstat, sizeof(icmpstat)));
default:
if (name[0] < ICMPCTL_MAXID)
return (sysctl_int_arr(icmpctl_vars, name, namelen,
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index c36cd44fe0e..8bbe357c553 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_input.c,v 1.154 2007/10/29 16:19:23 chl Exp $ */
+/* $OpenBSD: ip_input.c,v 1.155 2007/12/13 20:00:53 reyk Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@@ -1622,6 +1622,11 @@ ip_sysctl(name, namelen, oldp, oldlenp, newp, newlen)
case IPCTL_IFQUEUE:
return (sysctl_ifq(name + 1, namelen - 1,
oldp, oldlenp, newp, newlen, &ipintrq));
+ case IPCTL_STATS:
+ if (newp != NULL)
+ return (EPERM);
+ return (sysctl_struct(oldp, oldlenp, newp, newlen,
+ &ipstat, sizeof(ipstat)));
default:
if (name[0] < IPCTL_MAXID)
return (sysctl_int_arr(ipctl_vars, name, namelen,
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 13dd15cbc67..2e1750e00af 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_usrreq.c,v 1.94 2007/11/27 17:23:23 deraadt Exp $ */
+/* $OpenBSD: tcp_usrreq.c,v 1.95 2007/12/13 20:00:53 reyk Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/*
@@ -954,6 +954,13 @@ tcp_sysctl(name, namelen, oldp, oldlenp, newp, newlen)
}
return (0);
#endif
+
+ case TCPCTL_STATS:
+ if (newp != NULL)
+ return (EPERM);
+ return (sysctl_struct(oldp, oldlenp, newp, newlen,
+ &tcpstat, sizeof(tcpstat)));
+
default:
if (name[0] < TCPCTL_MAXID)
return (sysctl_int_arr(tcpctl_vars, name, namelen,
diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h
index ca90b1b8c5b..cf2859b19d2 100644
--- a/sys/netinet/tcp_var.h
+++ b/sys/netinet/tcp_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_var.h,v 1.83 2007/06/25 12:17:43 markus Exp $ */
+/* $OpenBSD: tcp_var.h,v 1.84 2007/12/13 20:00:53 reyk Exp $ */
/* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */
/*
@@ -494,7 +494,8 @@ struct tcpstat {
#define TCPCTL_REASS_LIMIT 18 /* max entries for tcp reass queues */
#define TCPCTL_DROP 19 /* drop tcp connection */
#define TCPCTL_SACKHOLE_LIMIT 20 /* max entries for tcp sack queues */
-#define TCPCTL_MAXID 21
+#define TCPCTL_STATS 21 /* TCP statistics */
+#define TCPCTL_MAXID 22
#define TCPCTL_NAMES { \
{ 0, 0 }, \
@@ -518,6 +519,7 @@ struct tcpstat {
{ "reasslimit", CTLTYPE_INT }, \
{ "drop", CTLTYPE_STRUCT }, \
{ "sackholelimit", CTLTYPE_INT }, \
+ { "stats", CTLTYPE_STRUCT } \
}
#define TCPCTL_VARS { \
@@ -541,6 +543,7 @@ struct tcpstat {
&tcp_do_rfc3390, \
NULL, \
NULL, \
+ NULL, \
NULL \
}
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 05ec0e1fe6f..7f4370c04b1 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udp_usrreq.c,v 1.114 2007/06/11 11:29:35 henning Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.115 2007/12/13 20:00:53 reyk Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
@@ -1236,6 +1236,13 @@ udp_sysctl(name, namelen, oldp, oldlenp, newp, newlen)
case UDPCTL_BADDYNAMIC:
return (sysctl_struct(oldp, oldlenp, newp, newlen,
baddynamicports.udp, sizeof(baddynamicports.udp)));
+
+ case UDPCTL_STATS:
+ if (newp != NULL)
+ return (EPERM);
+ return (sysctl_struct(oldp, oldlenp, newp, newlen,
+ &udpstat, sizeof(udpstat)));
+
default:
if (name[0] < UDPCTL_MAXID)
return (sysctl_int_arr(udpctl_vars, name, namelen,
diff --git a/sys/netinet/udp_var.h b/sys/netinet/udp_var.h
index 8c385683949..943711bf1e6 100644
--- a/sys/netinet/udp_var.h
+++ b/sys/netinet/udp_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: udp_var.h,v 1.16 2004/02/17 12:07:45 markus Exp $ */
+/* $OpenBSD: udp_var.h,v 1.17 2007/12/13 20:00:53 reyk Exp $ */
/* $NetBSD: udp_var.h,v 1.12 1996/02/13 23:44:41 christos Exp $ */
/*
@@ -77,7 +77,8 @@ struct udpstat {
#define UDPCTL_BADDYNAMIC 2 /* return bad dynamic port bitmap */
#define UDPCTL_RECVSPACE 3 /* receive buffer space */
#define UDPCTL_SENDSPACE 4 /* send buffer space */
-#define UDPCTL_MAXID 5
+#define UDPCTL_STATS 5 /* UDP statistics */
+#define UDPCTL_MAXID 6
#define UDPCTL_NAMES { \
{ 0, 0 }, \
@@ -85,6 +86,7 @@ struct udpstat {
{ "baddynamic", CTLTYPE_STRUCT }, \
{ "recvspace", CTLTYPE_INT }, \
{ "sendspace", CTLTYPE_INT }, \
+ { "stats", CTLTYPE_STRUCT } \
}
#define UDPCTL_VARS { \
@@ -93,6 +95,7 @@ struct udpstat {
NULL, \
&udp_recvspace, \
&udp_sendspace, \
+ NULL \
}
#ifdef _KERNEL