-/* $OpenBSD: uipc_usrreq.c,v 1.172 2022/08/22 08:08:46 mvs Exp $ */
+/* $OpenBSD: uipc_usrreq.c,v 1.173 2022/08/22 13:23:06 mvs Exp $ */
/* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */
/*
.pru_listen = uipc_listen,
.pru_connect = uipc_connect,
.pru_accept = uipc_accept,
+ .pru_disconnect = uipc_disconnect,
};
void
}
break;
- case PRU_DISCONNECT:
- unp_disconnect(unp);
- break;
-
case PRU_SHUTDOWN:
socantsendmore(so);
unp_shutdown(unp);
return (0);
}
+int
+uipc_disconnect(struct socket *so)
+{
+ struct unpcb *unp = sotounpcb(so);
+
+ unp_disconnect(unp);
+ return (0);
+}
+
int
uipc_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
size_t newlen)
-/* $OpenBSD: pfkeyv2.c,v 1.239 2022/08/22 08:08:46 mvs Exp $ */
+/* $OpenBSD: pfkeyv2.c,v 1.240 2022/08/22 13:23:06 mvs Exp $ */
/*
* @(#)COPYRIGHT 1.1 (NRL) 17 January 1995
int pfkeyv2_attach(struct socket *, int);
int pfkeyv2_detach(struct socket *);
+int pfkeyv2_disconnect(struct socket *);
int pfkeyv2_usrreq(struct socket *, int, struct mbuf *, struct mbuf *,
struct mbuf *, struct proc *);
int pfkeyv2_output(struct mbuf *, struct socket *, struct sockaddr *,
.pru_usrreq = pfkeyv2_usrreq,
.pru_attach = pfkeyv2_attach,
.pru_detach = pfkeyv2_detach,
+ .pru_disconnect = pfkeyv2_disconnect,
};
const struct protosw pfkeysw[] = {
return (0);
}
+int
+pfkeyv2_disconnect(struct socket *so)
+{
+ soisdisconnected(so);
+ return (0);
+}
+
int
pfkeyv2_usrreq(struct socket *so, int req, struct mbuf *m,
struct mbuf *nam, struct mbuf *control, struct proc *p)
error = EOPNOTSUPP;
break;
- case PRU_DISCONNECT:
case PRU_ABORT:
soisdisconnected(so);
break;
-/* $OpenBSD: rtsock.c,v 1.339 2022/08/22 08:08:46 mvs Exp $ */
+/* $OpenBSD: rtsock.c,v 1.340 2022/08/22 13:23:07 mvs Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
int route_ctloutput(int, struct socket *, int, int, struct mbuf *);
int route_usrreq(struct socket *, int, struct mbuf *, struct mbuf *,
struct mbuf *, struct proc *);
+int route_disconnect(struct socket *);
void route_input(struct mbuf *m0, struct socket *, sa_family_t);
int route_arp_conflict(struct rtentry *, struct rt_addrinfo *);
int route_cleargateway(struct rtentry *, void *, unsigned int);
error = EOPNOTSUPP;
break;
- case PRU_DISCONNECT:
case PRU_ABORT:
soisdisconnected(so);
break;
return (0);
}
+int
+route_disconnect(struct socket *so)
+{
+ soisdisconnected(so);
+ return (0);
+}
+
int
route_ctloutput(int op, struct socket *so, int level, int optname,
struct mbuf *m)
.pru_usrreq = route_usrreq,
.pru_attach = route_attach,
.pru_detach = route_detach,
+ .pru_disconnect = route_disconnect,
};
const struct protosw routesw[] = {
-/* $OpenBSD: ip_divert.c,v 1.74 2022/08/22 08:08:46 mvs Exp $ */
+/* $OpenBSD: ip_divert.c,v 1.75 2022/08/22 13:23:07 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
break;
case PRU_CONNECT2:
- case PRU_DISCONNECT:
case PRU_SENDOOB:
case PRU_FASTTIMO:
case PRU_SLOWTIMO:
-/* $OpenBSD: ip_gre.c,v 1.77 2022/08/21 22:45:55 mvs Exp $ */
+/* $OpenBSD: ip_gre.c,v 1.78 2022/08/22 13:23:07 mvs Exp $ */
/* $NetBSD: ip_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */
/*
.pru_detach = rip_detach,
.pru_bind = rip_bind,
.pru_connect = rip_connect,
+ .pru_disconnect = rip_disconnect,
};
int
-/* $OpenBSD: ip_var.h,v 1.99 2022/08/21 22:45:55 mvs Exp $ */
+/* $OpenBSD: ip_var.h,v 1.100 2022/08/22 13:23:07 mvs Exp $ */
/* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */
/*
int rip_detach(struct socket *);
int rip_bind(struct socket *so, struct mbuf *, struct proc *);
int rip_connect(struct socket *, struct mbuf *);
+int rip_disconnect(struct socket *);
#ifdef MROUTING
extern struct socket *ip_mrouter[]; /* multicast routing daemon */
#endif
-/* $OpenBSD: raw_ip.c,v 1.135 2022/08/22 10:37:27 bluhm Exp $ */
+/* $OpenBSD: raw_ip.c,v 1.136 2022/08/22 13:23:07 mvs Exp $ */
/* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */
/*
.pru_detach = rip_detach,
.pru_bind = rip_bind,
.pru_connect = rip_connect,
+ .pru_disconnect = rip_disconnect,
};
/*
switch (req) {
- case PRU_DISCONNECT:
- if ((so->so_state & SS_ISCONNECTED) == 0) {
- error = ENOTCONN;
- break;
- }
- soisdisconnected(so);
- inp->inp_faddr.s_addr = INADDR_ANY;
- break;
case PRU_ABORT:
soisdisconnected(so);
if (inp == NULL)
return (0);
}
+
+int
+rip_disconnect(struct socket *so)
+{
+ struct inpcb *inp = sotoinpcb(so);
+
+ soassertlocked(so);
+
+ if ((so->so_state & SS_ISCONNECTED) == 0)
+ return (ENOTCONN);
+
+ soisdisconnected(so);
+ inp->inp_faddr.s_addr = INADDR_ANY;
+
+ return (0);
+}
-/* $OpenBSD: tcp_usrreq.c,v 1.192 2022/08/22 08:08:46 mvs Exp $ */
+/* $OpenBSD: tcp_usrreq.c,v 1.193 2022/08/22 13:23:07 mvs Exp $ */
/* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */
/*
.pru_listen = tcp_listen,
.pru_connect = tcp_connect,
.pru_accept = tcp_accept,
+ .pru_disconnect = tcp_disconnect,
};
static int pr_slowhz = PR_SLOWHZ;
error = EOPNOTSUPP;
break;
- /*
- * Initiate disconnect from peer.
- * If connection never passed embryonic stage, just drop;
- * else if don't need to let data drain, then can just drop anyways,
- * else have to begin TCP shutdown process: mark socket disconnecting,
- * drain unread data, state switch to reflect user close, and
- * send segment (e.g. FIN) to peer. Socket will be really disconnected
- * when peer sends FIN and acks ours.
- *
- * SHOULD IMPLEMENT LATER PRU_CONNECT VIA REALLOC TCPCB.
- */
- case PRU_DISCONNECT:
- tp = tcp_disconnect(tp);
- break;
-
/*
* Mark the connection as being incapable of further output.
*/
* which may finish later; embryonic TCB's can just
* be discarded here.
*/
- tp = tcp_disconnect(tp);
+ tp = tcp_dodisconnect(tp);
if (otp)
tcp_trace(TA_USER, ostate, tp, otp, NULL, PRU_DETACH, 0);
return (error);
}
+/*
+ * Initiate disconnect from peer.
+ * If connection never passed embryonic stage, just drop;
+ * else if don't need to let data drain, then can just drop anyways,
+ * else have to begin TCP shutdown process: mark socket disconnecting,
+ * drain unread data, state switch to reflect user close, and
+ * send segment (e.g. FIN) to peer. Socket will be really disconnected
+ * when peer sends FIN and acks ours.
+ *
+ * SHOULD IMPLEMENT LATER PRU_CONNECT VIA REALLOC TCPCB.
+ */
+int
+tcp_disconnect(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_dodisconnect(tp);
+
+ if (otp)
+ tcp_trace(TA_USER, ostate, tp, otp, NULL, PRU_DISCONNECT, 0);
+ return (0);
+}
+
/*
* Initiate (or continue) disconnect.
* If embryonic state, just send reset (once).
* send segment to peer (with FIN).
*/
struct tcpcb *
-tcp_disconnect(struct tcpcb *tp)
+tcp_dodisconnect(struct tcpcb *tp)
{
struct socket *so = tp->t_inpcb->inp_socket;
-/* $OpenBSD: tcp_var.h,v 1.145 2022/08/22 08:08:46 mvs Exp $ */
+/* $OpenBSD: tcp_var.h,v 1.146 2022/08/22 13:23:07 mvs Exp $ */
/* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */
/*
void tcp_ctlinput(int, struct sockaddr *, u_int, void *);
int tcp_ctloutput(int, struct socket *, int, int, struct mbuf *);
struct tcpcb *
- tcp_disconnect(struct tcpcb *);
+ tcp_dodisconnect(struct tcpcb *);
struct tcpcb *
tcp_drop(struct tcpcb *, int);
int tcp_dooptions(struct tcpcb *, u_char *, int, struct tcphdr *,
int tcp_listen(struct socket *);
int tcp_connect(struct socket *, struct mbuf *);
int tcp_accept(struct socket *, struct mbuf *);
+int tcp_disconnect(struct socket *);
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);
-/* $OpenBSD: udp_usrreq.c,v 1.287 2022/08/22 10:37:27 bluhm Exp $ */
+/* $OpenBSD: udp_usrreq.c,v 1.288 2022/08/22 13:23:07 mvs Exp $ */
/* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */
/*
.pru_detach = udp_detach,
.pru_bind = udp_bind,
.pru_connect = udp_connect,
+ .pru_disconnect = udp_disconnect,
};
const struct sysctl_bounded_args udpctl_vars[] = {
error = EOPNOTSUPP;
break;
- case PRU_DISCONNECT:
-#ifdef INET6
- if (inp->inp_flags & INP_IPV6) {
- if (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6)) {
- error = ENOTCONN;
- break;
- }
- } else
-#endif /* INET6 */
- {
- if (inp->inp_faddr.s_addr == INADDR_ANY) {
- error = ENOTCONN;
- break;
- }
- }
-
-#ifdef INET6
- if (inp->inp_flags & INP_IPV6)
- inp->inp_laddr6 = in6addr_any;
- else
-#endif /* INET6 */
- inp->inp_laddr.s_addr = INADDR_ANY;
- in_pcbdisconnect(inp);
-
- so->so_state &= ~SS_ISCONNECTED; /* XXX */
- break;
-
case PRU_SHUTDOWN:
socantsendmore(so);
break;
return (0);
}
+int
+udp_disconnect(struct socket *so)
+{
+ struct inpcb *inp = sotoinpcb(so);
+
+ soassertlocked(so);
+
+#ifdef INET6
+ if (inp->inp_flags & INP_IPV6) {
+ if (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_faddr6))
+ return (ENOTCONN);
+ } else
+#endif /* INET6 */
+ {
+ if (inp->inp_faddr.s_addr == INADDR_ANY)
+ return (ENOTCONN);
+ }
+
+#ifdef INET6
+ if (inp->inp_flags & INP_IPV6)
+ inp->inp_laddr6 = in6addr_any;
+ else
+#endif /* INET6 */
+ inp->inp_laddr.s_addr = INADDR_ANY;
+
+ in_pcbdisconnect(inp);
+ so->so_state &= ~SS_ISCONNECTED; /* XXX */
+
+ return (0);
+}
+
/*
* Sysctl for udp variables.
*/
-/* $OpenBSD: udp_var.h,v 1.40 2022/08/21 22:45:55 mvs Exp $ */
+/* $OpenBSD: udp_var.h,v 1.41 2022/08/22 13:23:07 mvs Exp $ */
/* $NetBSD: udp_var.h,v 1.12 1996/02/13 23:44:41 christos Exp $ */
/*
int udp_detach(struct socket *);
int udp_bind(struct socket *, struct mbuf *, struct proc *);
int udp_connect(struct socket *, struct mbuf *);
+int udp_disconnect(struct socket *);
#endif /* _KERNEL */
#endif /* _NETINET_UDP_VAR_H_ */
-/* $OpenBSD: ip6_divert.c,v 1.73 2022/08/22 08:08:46 mvs Exp $ */
+/* $OpenBSD: ip6_divert.c,v 1.74 2022/08/22 13:23:07 mvs Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
break;
case PRU_CONNECT2:
- case PRU_DISCONNECT:
case PRU_SENDOOB:
case PRU_FASTTIMO:
case PRU_SLOWTIMO:
-/* $OpenBSD: ip6_var.h,v 1.97 2022/08/21 22:45:55 mvs Exp $ */
+/* $OpenBSD: ip6_var.h,v 1.98 2022/08/22 13:23:07 mvs Exp $ */
/* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */
/*
int rip6_detach(struct socket *);
int rip6_bind(struct socket *, struct mbuf *, struct proc *);
int rip6_connect(struct socket *, struct mbuf *);
+int rip6_disconnect(struct socket *);
int rip6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
int dest6_input(struct mbuf **, int *, int, int);
-/* $OpenBSD: raw_ip6.c,v 1.155 2022/08/22 10:37:27 bluhm Exp $ */
+/* $OpenBSD: raw_ip6.c,v 1.156 2022/08/22 13:23:07 mvs Exp $ */
/* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */
/*
.pru_detach = rip6_detach,
.pru_bind = rip6_bind,
.pru_connect = rip6_connect,
+ .pru_disconnect = rip6_disconnect,
};
/*
}
switch (req) {
- case PRU_DISCONNECT:
- if ((so->so_state & SS_ISCONNECTED) == 0) {
- error = ENOTCONN;
- break;
- }
- in6p->inp_faddr6 = in6addr_any;
- so->so_state &= ~SS_ISCONNECTED; /* XXX */
- break;
-
case PRU_ABORT:
soisdisconnected(so);
if (in6p == NULL)
return (0);
}
+int
+rip6_disconnect(struct socket *so)
+{
+ struct inpcb *in6p = sotoinpcb(so);
+
+ soassertlocked(so);
+
+ if ((so->so_state & SS_ISCONNECTED) == 0)
+ return (ENOTCONN);
+
+ in6p->inp_faddr6 = in6addr_any;
+ so->so_state &= ~SS_ISCONNECTED; /* XXX */
+ return (0);
+}
+
int
rip6_sysctl_rip6stat(void *oldp, size_t *oldplen, void *newp)
{
-/* $OpenBSD: protosw.h,v 1.41 2022/08/22 08:08:47 mvs Exp $ */
+/* $OpenBSD: protosw.h,v 1.42 2022/08/22 13:23:07 mvs Exp $ */
/* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */
/*-
int (*pru_listen)(struct socket *);
int (*pru_connect)(struct socket *, struct mbuf *);
int (*pru_accept)(struct socket *, struct mbuf *);
+ int (*pru_disconnect)(struct socket *);
};
struct protosw {
static inline int
pru_disconnect(struct socket *so)
{
- return (*so->so_proto->pr_usrreqs->pru_usrreq)(so,
- PRU_DISCONNECT, NULL, NULL, NULL, curproc);
+ if (so->so_proto->pr_usrreqs->pru_disconnect)
+ return (*so->so_proto->pr_usrreqs->pru_disconnect)(so);
+ return (EOPNOTSUPP);
}
static inline int
-/* $OpenBSD: unpcb.h,v 1.31 2022/08/22 08:08:47 mvs Exp $ */
+/* $OpenBSD: unpcb.h,v 1.32 2022/08/22 13:23:07 mvs Exp $ */
/* $NetBSD: unpcb.h,v 1.6 1994/06/29 06:46:08 cgd Exp $ */
/*
int uipc_listen(struct socket *);
int uipc_connect(struct socket *, struct mbuf *);
int uipc_accept(struct socket *, struct mbuf *);
+int uipc_disconnect(struct socket *);
void unp_init(void);
int unp_bind(struct unpcb *, struct mbuf *, struct proc *);