summaryrefslogtreecommitdiff
path: root/sys/netinet/tcp_usrreq.c
diff options
context:
space:
mode:
authorVitaliy Makkoveev <mvs@cvs.openbsd.org>2022-08-21 17:30:22 +0000
committerVitaliy Makkoveev <mvs@cvs.openbsd.org>2022-08-21 17:30:22 +0000
commit9045daea072a1c0ebf4e5bf7cfe83a8cc3f84800 (patch)
tree79e848082c394250cd93c80c4e0461eba71f89fc /sys/netinet/tcp_usrreq.c
parent766be663b1d7c26a6839928ba8f80e7e18fc020b (diff)
Move PRU_LISTEN request to (*pru_listen)() handler.
ok bluhm@
Diffstat (limited to 'sys/netinet/tcp_usrreq.c')
-rw-r--r--sys/netinet/tcp_usrreq.c52
1 files changed, 39 insertions, 13 deletions
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 88aa0d26ed7..48a25660432 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_usrreq.c,v 1.189 2022/08/20 23:48:58 mvs Exp $ */
+/* $OpenBSD: tcp_usrreq.c,v 1.190 2022/08/21 17:30:21 mvs Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/*
@@ -116,6 +116,7 @@ const struct pr_usrreqs tcp_usrreqs = {
.pru_attach = tcp_attach,
.pru_detach = tcp_detach,
.pru_bind = tcp_bind,
+ .pru_listen = tcp_listen,
};
static int pr_slowhz = PR_SLOWHZ;
@@ -213,18 +214,6 @@ tcp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
switch (req) {
/*
- * Prepare to accept connections.
- */
- case PRU_LISTEN:
- if (inp->inp_lport == 0)
- error = in_pcbbind(inp, NULL, p);
- /* If the in_pcbbind() above is called, the tp->pf
- should still be whatever it was before. */
- if (error == 0)
- tp->t_state = TCPS_LISTEN;
- break;
-
- /*
* Initiate connection to peer.
* Create a template for use in transmissions on this connection.
* Enter SYN_SENT state, and mark socket as connecting.
@@ -801,6 +790,43 @@ tcp_bind(struct socket *so, struct mbuf *nam, struct proc *p)
}
/*
+ * Prepare to accept connections.
+ */
+int
+tcp_listen(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 (inp->inp_lport == 0)
+ if ((error = in_pcbbind(inp, NULL, curproc)))
+ goto out;
+
+ /*
+ * If the in_pcbbind() above is called, the tp->pf
+ * should still be whatever it was before.
+ */
+ tp->t_state = TCPS_LISTEN;
+
+out:
+ if (otp)
+ tcp_trace(TA_USER, ostate, tp, otp, NULL, PRU_LISTEN, 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.