summaryrefslogtreecommitdiff
path: root/sys/netinet/tcp_usrreq.c
diff options
context:
space:
mode:
authorVitaliy Makkoveev <mvs@cvs.openbsd.org>2022-08-22 21:18:49 +0000
committerVitaliy Makkoveev <mvs@cvs.openbsd.org>2022-08-22 21:18:49 +0000
commit8e852484aff4ad877e571db3827ed28736400f94 (patch)
treef5075eab5a27a8d5567a8ec8600754a7fbae39b5 /sys/netinet/tcp_usrreq.c
parentef80f24a1a93275231aab19c91bffd558c518d42 (diff)
Move PRU_SHUTDOWN request to (*pru_shutdown)().
ok bluhm@
Diffstat (limited to 'sys/netinet/tcp_usrreq.c')
-rw-r--r--sys/netinet/tcp_usrreq.c50
1 files changed, 37 insertions, 13 deletions
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index b1542ce376e..e99ed008f9b 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_usrreq.c,v 1.193 2022/08/22 13:23:07 mvs Exp $ */
+/* $OpenBSD: tcp_usrreq.c,v 1.194 2022/08/22 21:18:48 mvs Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/*
@@ -120,6 +120,7 @@ const struct pr_usrreqs tcp_usrreqs = {
.pru_connect = tcp_connect,
.pru_accept = tcp_accept,
.pru_disconnect = tcp_disconnect,
+ .pru_shutdown = tcp_shutdown,
};
static int pr_slowhz = PR_SLOWHZ;
@@ -224,18 +225,6 @@ tcp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
break;
/*
- * Mark the connection as being incapable of further output.
- */
- case PRU_SHUTDOWN:
- if (so->so_state & SS_CANTSENDMORE)
- break;
- socantsendmore(so);
- tp = tcp_usrclosed(tp);
- if (tp)
- error = tcp_output(tp);
- break;
-
- /*
* After a receive, possibly send window update to peer.
*/
case PRU_RCVD:
@@ -891,6 +880,41 @@ tcp_disconnect(struct socket *so)
}
/*
+ * Mark the connection as being incapable of further output.
+ */
+int
+tcp_shutdown(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;
+ }
+
+ if (so->so_state & SS_CANTSENDMORE)
+ goto out;
+
+ socantsendmore(so);
+ tp = tcp_usrclosed(tp);
+ if (tp)
+ error = tcp_output(tp);
+
+out:
+ if (otp)
+ tcp_trace(TA_USER, ostate, tp, otp, NULL, PRU_SHUTDOWN, 0);
+ return (error);
+}
+
+/*
* Initiate (or continue) disconnect.
* If embryonic state, just send reset (once).
* If in ``let data drain'' option and linger null, just drop.