diff options
Diffstat (limited to 'sys/netinet/tcp_usrreq.c')
-rw-r--r-- | sys/netinet/tcp_usrreq.c | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index af327f2bd56..310caee591b 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_usrreq.c,v 1.196 2022/08/27 20:28:01 mvs Exp $ */ +/* $OpenBSD: tcp_usrreq.c,v 1.197 2022/08/28 18:44:16 mvs Exp $ */ /* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */ /* @@ -123,6 +123,7 @@ const struct pr_usrreqs tcp_usrreqs = { .pru_shutdown = tcp_shutdown, .pru_rcvd = tcp_rcvd, .pru_send = tcp_send, + .pru_abort = tcp_abort, }; static int pr_slowhz = PR_SLOWHZ; @@ -226,13 +227,6 @@ tcp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, error = EOPNOTSUPP; break; - /* - * Abort the TCP. - */ - case PRU_ABORT: - tp = tcp_drop(tp, ECONNABORTED); - break; - case PRU_SENSE: ((struct stat *) m)->st_blksize = so->so_snd.sb_hiwat; break; @@ -963,6 +957,34 @@ out: } /* + * Abort the TCP. + */ +int +tcp_abort(struct socket *so) +{ + struct inpcb *inp; + struct tcpcb *tp, *otp = NULL; + int error; + short ostate; + + soassertlocked(so); + + if ((error = tcp_sogetpcb(so, &inp, &tp))) + return (error); + + if (so->so_options & SO_DEBUG) { + otp = tp; + ostate = tp->t_state; + } + + tp = tcp_drop(tp, ECONNABORTED); + + if (otp) + tcp_trace(TA_USER, ostate, tp, otp, NULL, PRU_ABORT, 0); + return (0); +} + +/* * Initiate (or continue) disconnect. * If embryonic state, just send reset (once). * If in ``let data drain'' option and linger null, just drop. |