diff options
author | 2018-06-11 07:40:26 +0000 | |
---|---|---|
committer | 2018-06-11 07:40:26 +0000 | |
commit | 4e64d49b299b035a80413de9c2614f79e6e7fea5 (patch) | |
tree | f474d241ee20f7f1b85fbfc9f5930139fa935848 /sys/netinet/tcp_usrreq.c | |
parent | use the correct name for the cert; ok gilles (diff) | |
download | wireguard-openbsd-4e64d49b299b035a80413de9c2614f79e6e7fea5.tar.xz wireguard-openbsd-4e64d49b299b035a80413de9c2614f79e6e7fea5.zip |
The output from tcp debug sockets was incomplete. After detach tp
was NULL and nothing was traced. So save the old tcpcb and use
that to retrieve some information. Note that otb may be freed and
must not be dereferenced. Use a heuristic for cases where the
address family is in the IP header but not provided in the PCB.
OK visa@
Diffstat (limited to 'sys/netinet/tcp_usrreq.c')
-rw-r--r-- | sys/netinet/tcp_usrreq.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 6b1e036b574..304935cd569 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_usrreq.c,v 1.168 2018/04/24 15:40:55 pirofti Exp $ */ +/* $OpenBSD: tcp_usrreq.c,v 1.169 2018/06/11 07:40:26 bluhm Exp $ */ /* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */ /* @@ -127,7 +127,7 @@ tcp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, struct mbuf *control, struct proc *p) { struct inpcb *inp; - struct tcpcb *tp = NULL; + struct tcpcb *otp = NULL, *tp = NULL; int error = 0; short ostate; @@ -172,7 +172,10 @@ tcp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, /* tp might get 0 when using socket splicing */ if (tp == NULL) return (0); - ostate = tp->t_state; + if (so->so_options & SO_DEBUG) { + otp = tp; + ostate = tp->t_state; + } switch (req) { @@ -399,8 +402,8 @@ tcp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, default: panic("tcp_usrreq"); } - if (tp && (so->so_options & SO_DEBUG)) - tcp_trace(TA_USER, ostate, tp, (caddr_t)0, req, 0); + if (otp) + tcp_trace(TA_USER, ostate, tp, otp, NULL, req, 0); return (error); } @@ -599,7 +602,7 @@ tcp_attach(struct socket *so, int proto) so->so_linger = TCP_LINGERTIME; if (so->so_options & SO_DEBUG) - tcp_trace(TA_USER, TCPS_CLOSED, tp, (caddr_t)0, PRU_ATTACH, 0); + tcp_trace(TA_USER, TCPS_CLOSED, tp, tp, NULL, PRU_ATTACH, 0); return (0); } @@ -607,7 +610,7 @@ int tcp_detach(struct socket *so) { struct inpcb *inp; - struct tcpcb *tp = NULL; + struct tcpcb *otp = NULL, *tp = NULL; int error = 0; short ostate; @@ -629,7 +632,10 @@ tcp_detach(struct socket *so) /* tp might get 0 when using socket splicing */ if (tp == NULL) return (0); - ostate = tp->t_state; + if (so->so_options & SO_DEBUG) { + otp = tp; + ostate = tp->t_state; + } /* * Detach the TCP protocol from the socket. @@ -640,8 +646,8 @@ tcp_detach(struct socket *so) */ tp = tcp_disconnect(tp); - if (tp && (so->so_options & SO_DEBUG)) - tcp_trace(TA_USER, ostate, tp, (caddr_t)0, PRU_DETACH, 0); + if (otp) + tcp_trace(TA_USER, ostate, tp, otp, NULL, PRU_DETACH, 0); return (error); } |