summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2015-02-11 05:09:33 +0000
committerclaudio <claudio@openbsd.org>2015-02-11 05:09:33 +0000
commitd06d9b8af58fdd7f426d82e88002bbaae8047a72 (patch)
tree50fe6d4031f7cfc2d80b0ca8e161af1945eb7baf
parentDon't rely in <sys/lock.h> bringing <sys/rwlock.h>. (diff)
downloadwireguard-openbsd-d06d9b8af58fdd7f426d82e88002bbaae8047a72.tar.xz
wireguard-openbsd-d06d9b8af58fdd7f426d82e88002bbaae8047a72.zip
Extend struct kinfo_file a bit so that netstat has all the info it needs.
OK guenther@
-rw-r--r--sys/kern/kern_sysctl.c22
-rw-r--r--sys/sys/sysctl.h7
2 files changed, 27 insertions, 2 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 39289536556..f93d7f61fbb 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sysctl.c,v 1.282 2015/02/11 04:00:05 guenther Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.283 2015/02/11 05:09:33 claudio Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@@ -88,6 +88,9 @@
#include <netinet/ip.h>
#include <netinet/in_pcb.h>
#include <netinet/ip6.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_timer.h>
+#include <netinet/tcp_var.h>
#include <netinet6/ip6_var.h>
#ifdef DDB
@@ -1102,6 +1105,15 @@ fill_file(struct kinfo_file *kf, struct file *fp, struct filedesc *fdp,
kf->inp_fport = inpcb->inp_fport;
kf->inp_faddru[0] = inpcb->inp_faddr.s_addr;
kf->inp_rtableid = inpcb->inp_rtableid;
+ if (so->so_type == SOCK_RAW)
+ kf->inp_proto = inpcb->inp_ip.ip_p;
+ if (so->so_proto->pr_protocol == IPPROTO_TCP) {
+ struct tcpcb *tcpcb = (void *)inpcb->inp_ppcb;
+ kf->t_rcv_wnd = tcpcb->rcv_wnd;
+ kf->t_snd_wnd = tcpcb->snd_wnd;
+ kf->t_snd_cwnd = tcpcb->snd_cwnd;
+ kf->t_state = tcpcb->t_state;
+ }
break;
}
case AF_INET6: {
@@ -1119,6 +1131,14 @@ fill_file(struct kinfo_file *kf, struct file *fp, struct filedesc *fdp,
kf->inp_faddru[2] = inpcb->inp_faddr6.s6_addr32[2];
kf->inp_faddru[3] = inpcb->inp_faddr6.s6_addr32[3];
kf->inp_rtableid = inpcb->inp_rtableid;
+ if (so->so_type == SOCK_RAW)
+ kf->inp_proto = inpcb->inp_ipv6.ip6_nxt;
+ if (so->so_proto->pr_protocol == IPPROTO_TCP) {
+ struct tcpcb *tcpcb = (void *)inpcb->inp_ppcb;
+ kf->t_rcv_wnd = tcpcb->rcv_wnd;
+ kf->t_snd_wnd = tcpcb->snd_wnd;
+ kf->t_state = tcpcb->t_state;
+ }
break;
}
case AF_UNIX: {
diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h
index a8004cdedea..425dfc51b62 100644
--- a/sys/sys/sysctl.h
+++ b/sys/sys/sysctl.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysctl.h,v 1.154 2015/01/13 10:07:58 mpf Exp $ */
+/* $OpenBSD: sysctl.h,v 1.155 2015/02/11 05:09:33 claudio Exp $ */
/* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */
/*
@@ -753,6 +753,11 @@ struct kinfo_file {
uint64_t unp_nextref; /* PTR: link to next connected socket */
uint64_t unp_addr; /* PTR: address of the socket address */
char unp_path[KI_UNPPATHLEN];
+ uint32_t inp_proto; /* CHAR: raw protocol id */
+ uint32_t t_state; /* SHORT: tcp state */
+ uint64_t t_rcv_wnd; /* ULONG: tcp receive window */
+ uint64_t t_snd_wnd; /* ULONG: tcp send window */
+ uint64_t t_snd_cwnd; /* ULONG: congestion-controlled win */
};
/*