summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/uipc_usrreq.c13
-rw-r--r--sys/net/pfkeyv2.c3
-rw-r--r--sys/net/rtsock.c3
-rw-r--r--sys/netinet/ip_divert.c3
-rw-r--r--sys/netinet/ip_gre.c3
-rw-r--r--sys/netinet/ip_var.h3
-rw-r--r--sys/netinet/raw_ip.c32
-rw-r--r--sys/netinet/tcp_usrreq.c148
-rw-r--r--sys/netinet/tcp_var.h3
-rw-r--r--sys/netinet/udp_usrreq.c53
-rw-r--r--sys/netinet/udp_var.h3
-rw-r--r--sys/netinet6/ip6_divert.c3
-rw-r--r--sys/netinet6/ip6_var.h3
-rw-r--r--sys/netinet6/raw_ip6.c44
-rw-r--r--sys/sys/protosw.h8
-rw-r--r--sys/sys/unpcb.h3
16 files changed, 191 insertions, 137 deletions
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 4e19579e513..5669d522772 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_usrreq.c,v 1.170 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: uipc_usrreq.c,v 1.171 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */
/*
@@ -132,6 +132,7 @@ const struct pr_usrreqs uipc_usrreqs = {
.pru_detach = uipc_detach,
.pru_bind = uipc_bind,
.pru_listen = uipc_listen,
+ .pru_connect = uipc_connect,
};
void
@@ -224,10 +225,6 @@ uipc_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
switch (req) {
- case PRU_CONNECT:
- error = unp_connect(so, nam, p);
- break;
-
case PRU_CONNECT2:
error = unp_connect2(so, (struct socket *)nam);
if (!error) {
@@ -549,6 +546,12 @@ uipc_listen(struct socket *so)
}
int
+uipc_connect(struct socket *so, struct mbuf *nam)
+{
+ return unp_connect(so, nam, curproc);
+}
+
+int
uipc_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
size_t newlen)
{
diff --git a/sys/net/pfkeyv2.c b/sys/net/pfkeyv2.c
index e61ca87f4bd..1b9d1350a6f 100644
--- a/sys/net/pfkeyv2.c
+++ b/sys/net/pfkeyv2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pfkeyv2.c,v 1.237 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: pfkeyv2.c,v 1.238 2022/08/21 22:45:55 mvs Exp $ */
/*
* @(#)COPYRIGHT 1.1 (NRL) 17 January 1995
@@ -357,7 +357,6 @@ pfkeyv2_usrreq(struct socket *so, int req, struct mbuf *m,
switch (req) {
/* no connect, bind, accept. Socket is connected from the start */
- case PRU_CONNECT:
case PRU_CONNECT2:
case PRU_ACCEPT:
error = EOPNOTSUPP;
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index c82433e89a6..867cacbd73e 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsock.c,v 1.337 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: rtsock.c,v 1.338 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
@@ -233,7 +233,6 @@ route_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
switch (req) {
/* no connect, bind, accept. Socket is connected from the start */
- case PRU_CONNECT:
case PRU_CONNECT2:
case PRU_ACCEPT:
error = EOPNOTSUPP;
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c
index 949572ab904..3afc2be71c8 100644
--- a/sys/netinet/ip_divert.c
+++ b/sys/netinet/ip_divert.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_divert.c,v 1.72 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: ip_divert.c,v 1.73 2022/08/21 22:45:55 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -291,7 +291,6 @@ divert_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr,
case PRU_SENSE:
break;
- case PRU_CONNECT:
case PRU_CONNECT2:
case PRU_ACCEPT:
case PRU_DISCONNECT:
diff --git a/sys/netinet/ip_gre.c b/sys/netinet/ip_gre.c
index 78dcb701ca9..3b53a9a5366 100644
--- a/sys/netinet/ip_gre.c
+++ b/sys/netinet/ip_gre.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_gre.c,v 1.76 2022/08/20 23:48:58 mvs Exp $ */
+/* $OpenBSD: ip_gre.c,v 1.77 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: ip_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */
/*
@@ -66,6 +66,7 @@ const struct pr_usrreqs gre_usrreqs = {
.pru_attach = rip_attach,
.pru_detach = rip_detach,
.pru_bind = rip_bind,
+ .pru_connect = rip_connect,
};
int
diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h
index 01e6d8a764a..823947db3ac 100644
--- a/sys/netinet/ip_var.h
+++ b/sys/netinet/ip_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_var.h,v 1.98 2022/08/20 23:48:58 mvs Exp $ */
+/* $OpenBSD: ip_var.h,v 1.99 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */
/*
@@ -261,6 +261,7 @@ int rip_usrreq(struct socket *,
int rip_attach(struct socket *, int);
int rip_detach(struct socket *);
int rip_bind(struct socket *so, struct mbuf *, struct proc *);
+int rip_connect(struct socket *, struct mbuf *);
#ifdef MROUTING
extern struct socket *ip_mrouter[]; /* multicast routing daemon */
#endif
diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c
index a7c71d895f5..68fa0ac0a64 100644
--- a/sys/netinet/raw_ip.c
+++ b/sys/netinet/raw_ip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: raw_ip.c,v 1.132 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: raw_ip.c,v 1.133 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */
/*
@@ -108,6 +108,7 @@ const struct pr_usrreqs rip_usrreqs = {
.pru_attach = rip_attach,
.pru_detach = rip_detach,
.pru_bind = rip_bind,
+ .pru_connect = rip_connect,
};
/*
@@ -486,17 +487,6 @@ rip_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
in_pcbdetach(inp);
break;
- case PRU_CONNECT:
- {
- struct sockaddr_in *addr;
-
- if ((error = in_nam2sin(nam, &addr)))
- break;
- inp->inp_faddr = addr->sin_addr;
- soisconnected(so);
- break;
- }
-
case PRU_CONNECT2:
error = EOPNOTSUPP;
break;
@@ -644,3 +634,21 @@ rip_bind(struct socket *so, struct mbuf *nam, struct proc *p)
return (0);
}
+
+int
+rip_connect(struct socket *so, struct mbuf *nam)
+{
+ struct inpcb *inp = sotoinpcb(so);
+ struct sockaddr_in *addr;
+ int error;
+
+ soassertlocked(so);
+
+ if ((error = in_nam2sin(nam, &addr)))
+ return (error);
+
+ inp->inp_faddr = addr->sin_addr;
+ soisconnected(so);
+
+ return (0);
+}
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index 48a25660432..d151eba11aa 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_usrreq.c,v 1.190 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: tcp_usrreq.c,v 1.191 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/*
@@ -117,6 +117,7 @@ const struct pr_usrreqs tcp_usrreqs = {
.pru_detach = tcp_detach,
.pru_bind = tcp_bind,
.pru_listen = tcp_listen,
+ .pru_connect = tcp_connect,
};
static int pr_slowhz = PR_SLOWHZ;
@@ -214,67 +215,6 @@ tcp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
switch (req) {
/*
- * Initiate connection to peer.
- * Create a template for use in transmissions on this connection.
- * Enter SYN_SENT state, and mark socket as connecting.
- * Start keep-alive timer, and seed output sequence space.
- * Send initial segment on connection.
- */
- case PRU_CONNECT:
-#ifdef INET6
- if (inp->inp_flags & INP_IPV6) {
- struct sockaddr_in6 *sin6;
-
- if ((error = in6_nam2sin6(nam, &sin6)))
- break;
- if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr) ||
- IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) {
- error = EINVAL;
- break;
- }
- error = in6_pcbconnect(inp, nam);
- } else
-#endif /* INET6 */
- {
- struct sockaddr_in *sin;
-
- if ((error = in_nam2sin(nam, &sin)))
- break;
- if ((sin->sin_addr.s_addr == INADDR_ANY) ||
- (sin->sin_addr.s_addr == INADDR_BROADCAST) ||
- IN_MULTICAST(sin->sin_addr.s_addr) ||
- in_broadcast(sin->sin_addr, inp->inp_rtableid)) {
- error = EINVAL;
- break;
- }
- error = in_pcbconnect(inp, nam);
- }
- if (error)
- break;
-
- tp->t_template = tcp_template(tp);
- if (tp->t_template == 0) {
- in_pcbdisconnect(inp);
- error = ENOBUFS;
- break;
- }
-
- so->so_state |= SS_CONNECTOUT;
-
- /* Compute window scaling to request. */
- tcp_rscale(tp, sb_max);
-
- soisconnecting(so);
- tcpstat_inc(tcps_connattempt);
- tp->t_state = TCPS_SYN_SENT;
- TCP_TIMER_ARM(tp, TCPT_KEEP, tcptv_keep_init);
- tcp_set_iss_tsm(tp);
- tcp_sendseqinit(tp);
- tp->snd_last = tp->snd_una;
- error = tcp_output(tp);
- break;
-
- /*
* Create a TCP connection between two sockets.
*/
case PRU_CONNECT2:
@@ -827,6 +767,90 @@ out:
}
/*
+ * Initiate connection to peer.
+ * Create a template for use in transmissions on this connection.
+ * Enter SYN_SENT state, and mark socket as connecting.
+ * Start keep-alive timer, and seed output sequence space.
+ * Send initial segment on connection.
+ */
+int
+tcp_connect(struct socket *so, struct mbuf *nam)
+{
+ 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;
+ }
+
+#ifdef INET6
+ if (inp->inp_flags & INP_IPV6) {
+ struct sockaddr_in6 *sin6;
+
+ if ((error = in6_nam2sin6(nam, &sin6)))
+ goto out;
+ if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr) ||
+ IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) {
+ error = EINVAL;
+ goto out;
+ }
+ error = in6_pcbconnect(inp, nam);
+ } else
+#endif /* INET6 */
+ {
+ struct sockaddr_in *sin;
+
+ if ((error = in_nam2sin(nam, &sin)))
+ goto out;
+ if ((sin->sin_addr.s_addr == INADDR_ANY) ||
+ (sin->sin_addr.s_addr == INADDR_BROADCAST) ||
+ IN_MULTICAST(sin->sin_addr.s_addr) ||
+ in_broadcast(sin->sin_addr, inp->inp_rtableid)) {
+ error = EINVAL;
+ goto out;
+ }
+ error = in_pcbconnect(inp, nam);
+ }
+ if (error)
+ goto out;
+
+ tp->t_template = tcp_template(tp);
+ if (tp->t_template == 0) {
+ in_pcbdisconnect(inp);
+ error = ENOBUFS;
+ goto out;
+ }
+
+ so->so_state |= SS_CONNECTOUT;
+
+ /* Compute window scaling to request. */
+ tcp_rscale(tp, sb_max);
+
+ soisconnecting(so);
+ tcpstat_inc(tcps_connattempt);
+ tp->t_state = TCPS_SYN_SENT;
+ TCP_TIMER_ARM(tp, TCPT_KEEP, tcptv_keep_init);
+ tcp_set_iss_tsm(tp);
+ tcp_sendseqinit(tp);
+ tp->snd_last = tp->snd_una;
+ error = tcp_output(tp);
+
+out:
+ if (otp)
+ tcp_trace(TA_USER, ostate, tp, otp, NULL, PRU_CONNECT, 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.
diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h
index 867a7772e4f..6250b3f12ab 100644
--- a/sys/netinet/tcp_var.h
+++ b/sys/netinet/tcp_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_var.h,v 1.143 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: tcp_var.h,v 1.144 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */
/*
@@ -716,6 +716,7 @@ int tcp_attach(struct socket *, int);
int tcp_detach(struct socket *);
int tcp_bind(struct socket *, struct mbuf *, struct proc *);
int tcp_listen(struct socket *);
+int tcp_connect(struct socket *, struct mbuf *);
void tcp_xmit_timer(struct tcpcb *, int);
void tcpdropoldhalfopen(struct tcpcb *, u_int16_t);
void tcp_sack_option(struct tcpcb *,struct tcphdr *,u_char *,int);
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index ea9726c253d..2f0c795c112 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: udp_usrreq.c,v 1.284 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.285 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
@@ -127,6 +127,7 @@ const struct pr_usrreqs udp_usrreqs = {
.pru_attach = udp_attach,
.pru_detach = udp_detach,
.pru_bind = udp_bind,
+ .pru_connect = udp_connect,
};
const struct sysctl_bounded_args udpctl_vars[] = {
@@ -1075,28 +1076,6 @@ udp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr,
*/
switch (req) {
- case PRU_CONNECT:
-#ifdef INET6
- if (inp->inp_flags & INP_IPV6) {
- if (!IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6)) {
- error = EISCONN;
- break;
- }
- error = in6_pcbconnect(inp, addr);
- } else
-#endif /* INET6 */
- {
- if (inp->inp_faddr.s_addr != INADDR_ANY) {
- error = EISCONN;
- break;
- }
- error = in_pcbconnect(inp, addr);
- }
-
- if (error == 0)
- soisconnected(so);
- break;
-
case PRU_CONNECT2:
error = EOPNOTSUPP;
break;
@@ -1277,6 +1256,34 @@ udp_bind(struct socket *so, struct mbuf *addr, struct proc *p)
return in_pcbbind(inp, addr, p);
}
+int
+udp_connect(struct socket *so, struct mbuf *addr)
+{
+ struct inpcb *inp = sotoinpcb(so);
+ int error;
+
+ soassertlocked(so);
+
+#ifdef INET6
+ if (inp->inp_flags & INP_IPV6) {
+ if (!IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6))
+ return (EISCONN);
+ error = in6_pcbconnect(inp, addr);
+ } else
+#endif /* INET6 */
+ {
+ if (inp->inp_faddr.s_addr != INADDR_ANY)
+ return (EISCONN);
+ error = in_pcbconnect(inp, addr);
+ }
+
+ if (error)
+ return (error);
+
+ soisconnected(so);
+ return (0);
+}
+
/*
* Sysctl for udp variables.
*/
diff --git a/sys/netinet/udp_var.h b/sys/netinet/udp_var.h
index c8ef191313d..9098492c958 100644
--- a/sys/netinet/udp_var.h
+++ b/sys/netinet/udp_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: udp_var.h,v 1.39 2022/08/20 23:48:58 mvs Exp $ */
+/* $OpenBSD: udp_var.h,v 1.40 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: udp_var.h,v 1.12 1996/02/13 23:44:41 christos Exp $ */
/*
@@ -144,5 +144,6 @@ int udp_usrreq(struct socket *,
int udp_attach(struct socket *, int);
int udp_detach(struct socket *);
int udp_bind(struct socket *, struct mbuf *, struct proc *);
+int udp_connect(struct socket *, struct mbuf *);
#endif /* _KERNEL */
#endif /* _NETINET_UDP_VAR_H_ */
diff --git a/sys/netinet6/ip6_divert.c b/sys/netinet6/ip6_divert.c
index 382b4593232..e3b0898568d 100644
--- a/sys/netinet6/ip6_divert.c
+++ b/sys/netinet6/ip6_divert.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_divert.c,v 1.71 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: ip6_divert.c,v 1.72 2022/08/21 22:45:55 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -297,7 +297,6 @@ divert6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr,
case PRU_SENSE:
break;
- case PRU_CONNECT:
case PRU_CONNECT2:
case PRU_ACCEPT:
case PRU_DISCONNECT:
diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h
index eb45f1d6408..d7bb0d4a2b5 100644
--- a/sys/netinet6/ip6_var.h
+++ b/sys/netinet6/ip6_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_var.h,v 1.96 2022/08/20 23:48:58 mvs Exp $ */
+/* $OpenBSD: ip6_var.h,v 1.97 2022/08/21 22:45:55 mvs Exp $ */
/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */
/*
@@ -356,6 +356,7 @@ int rip6_usrreq(struct socket *,
int rip6_attach(struct socket *, int);
int rip6_detach(struct socket *);
int rip6_bind(struct socket *, struct mbuf *, struct proc *);
+int rip6_connect(struct socket *, struct mbuf *);
int rip6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
int dest6_input(struct mbuf **, int *, int, int);
diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c
index 6926aebf300..d4bd78e1f39 100644
--- a/sys/netinet6/raw_ip6.c
+++ b/sys/netinet6/raw_ip6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: raw_ip6.c,v 1.152 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: raw_ip6.c,v 1.153 2022/08/21 22:45:55 mvs Exp $ */
/* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */
/*
@@ -110,6 +110,7 @@ const struct pr_usrreqs rip6_usrreqs = {
.pru_attach = rip6_attach,
.pru_detach = rip6_detach,
.pru_bind = rip6_bind,
+ .pru_connect = rip6_connect,
};
/*
@@ -605,23 +606,6 @@ rip6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
in_pcbdetach(in6p);
break;
- case PRU_CONNECT:
- {
- struct sockaddr_in6 *addr;
- struct in6_addr *in6a = NULL;
-
- if ((error = in6_nam2sin6(nam, &addr)))
- break;
- /* Source address selection. XXX: need pcblookup? */
- error = in6_pcbselsrc(&in6a, addr, in6p, in6p->inp_outputopts6);
- if (error)
- break;
- in6p->inp_laddr6 = *in6a;
- in6p->inp_faddr6 = addr->sin6_addr;
- soisconnected(so);
- break;
- }
-
case PRU_CONNECT2:
error = EOPNOTSUPP;
break;
@@ -782,6 +766,30 @@ rip6_bind(struct socket *so, struct mbuf *nam, struct proc *p)
}
int
+rip6_connect(struct socket *so, struct mbuf *nam)
+{
+ struct inpcb *in6p = sotoinpcb(so);
+ struct sockaddr_in6 *addr;
+ struct in6_addr *in6a = NULL;
+ int error;
+
+ soassertlocked(so);
+
+ if ((error = in6_nam2sin6(nam, &addr)))
+ return (error);
+
+ /* Source address selection. XXX: need pcblookup? */
+ error = in6_pcbselsrc(&in6a, addr, in6p, in6p->inp_outputopts6);
+ if (error)
+ return (error);
+
+ in6p->inp_laddr6 = *in6a;
+ in6p->inp_faddr6 = addr->sin6_addr;
+ soisconnected(so);
+ return (0);
+}
+
+int
rip6_sysctl_rip6stat(void *oldp, size_t *oldplen, void *newp)
{
struct rip6stat rip6stat;
diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h
index dfcb2cd62e5..f153e455456 100644
--- a/sys/sys/protosw.h
+++ b/sys/sys/protosw.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: protosw.h,v 1.39 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: protosw.h,v 1.40 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */
/*-
@@ -68,6 +68,7 @@ struct pr_usrreqs {
int (*pru_detach)(struct socket *);
int (*pru_bind)(struct socket *, struct mbuf *, struct proc *);
int (*pru_listen)(struct socket *);
+ int (*pru_connect)(struct socket *, struct mbuf *);
};
struct protosw {
@@ -282,8 +283,9 @@ pru_listen(struct socket *so)
static inline int
pru_connect(struct socket *so, struct mbuf *nam)
{
- return (*so->so_proto->pr_usrreqs->pru_usrreq)(so,
- PRU_CONNECT, NULL, nam, NULL, curproc);
+ if (so->so_proto->pr_usrreqs->pru_connect)
+ return (*so->so_proto->pr_usrreqs->pru_connect)(so, nam);
+ return (EOPNOTSUPP);
}
static inline int
diff --git a/sys/sys/unpcb.h b/sys/sys/unpcb.h
index ee11523e730..6498168f4f9 100644
--- a/sys/sys/unpcb.h
+++ b/sys/sys/unpcb.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: unpcb.h,v 1.29 2022/08/21 17:30:21 mvs Exp $ */
+/* $OpenBSD: unpcb.h,v 1.30 2022/08/21 22:45:55 mvs Exp $ */
/* $NetBSD: unpcb.h,v 1.6 1994/06/29 06:46:08 cgd Exp $ */
/*
@@ -115,6 +115,7 @@ int uipc_attach(struct socket *, int);
int uipc_detach(struct socket *);
int uipc_bind(struct socket *, struct mbuf *, struct proc *);
int uipc_listen(struct socket *);
+int uipc_connect(struct socket *, struct mbuf *);
void unp_init(void);
int unp_bind(struct unpcb *, struct mbuf *, struct proc *);