From a89c8ae3a9bdf3183da941f35222ecbac0fc7ccf Mon Sep 17 00:00:00 2001 From: bluhm Date: Mon, 22 Jan 2018 20:27:28 +0000 Subject: [PATCH] Bring back the detach messages in trpt(8) for tcp debugging. They got lost with the pr_detach conversion. While there, remove some dead code. OK mpi@ --- sys/netinet/tcp_usrreq.c | 26 +++++++++++--------------- sys/sys/protosw.h | 3 ++- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index cc2b23e0661..c534f0eb2b7 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_usrreq.c,v 1.163 2018/01/09 15:14:23 mpi Exp $ */ +/* $OpenBSD: tcp_usrreq.c,v 1.164 2018/01/22 20:27:28 bluhm Exp $ */ /* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */ /* @@ -170,9 +170,8 @@ tcp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, if (inp) { tp = intotcpcb(inp); /* tp might get 0 when using socket splicing */ - if (tp == NULL) { + if (tp == NULL) return (0); - } #ifdef KPROF tcp_acounts[tp->t_state][req]++; #endif @@ -628,21 +627,16 @@ tcp_detach(struct socket *so) error = so->so_error; if (error == 0) error = EINVAL; - return (error); } - if (inp) { - tp = intotcpcb(inp); - /* tp might get 0 when using socket splicing */ - if (tp == NULL) { - return (0); - } + tp = intotcpcb(inp); + /* tp might get 0 when using socket splicing */ + if (tp == NULL) + return (0); #ifdef KPROF - tcp_acounts[tp->t_state][req]++; + tcp_acounts[tp->t_state][req]++; #endif - ostate = tp->t_state; - } else - ostate = 0; + ostate = tp->t_state; /* * Detach the TCP protocol from the socket. @@ -651,8 +645,10 @@ tcp_detach(struct socket *so) * which may finish later; embryonic TCB's can just * be discarded here. */ - tcp_disconnect(tp); + tp = tcp_disconnect(tp); + if (tp && (so->so_options & SO_DEBUG)) + tcp_trace(TA_USER, ostate, tp, (caddr_t)0, PRU_DETACH, 0); return (error); } diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h index 5683bfa9f81..dac57277d7a 100644 --- a/sys/sys/protosw.h +++ b/sys/sys/protosw.h @@ -1,4 +1,4 @@ -/* $OpenBSD: protosw.h,v 1.28 2017/11/23 13:45:46 mpi Exp $ */ +/* $OpenBSD: protosw.h,v 1.29 2018/01/22 20:27:28 bluhm Exp $ */ /* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */ /*- @@ -121,6 +121,7 @@ struct protosw { * A non-zero return from usrreq gives an * UNIX error number which should be passed to higher level software. */ +#define PRU_DETACH 1 /* detach protocol from up */ #define PRU_BIND 2 /* bind socket to address */ #define PRU_LISTEN 3 /* listen for connection */ #define PRU_CONNECT 4 /* establish connection to peer */ -- 2.20.1