diff options
author | Vitaliy Makkoveev <mvs@cvs.openbsd.org> | 2022-08-28 18:44:18 +0000 |
---|---|---|
committer | Vitaliy Makkoveev <mvs@cvs.openbsd.org> | 2022-08-28 18:44:18 +0000 |
commit | 7cf93c0df658ac4ed0ffb76abe6741d99501477a (patch) | |
tree | 319723c6d59cbc6a272ce7fcf38655ff7048128e /sys | |
parent | 5edcdacdf523ba0d449de8e32b954c4a9aee8437 (diff) |
Move PRU_ABORT request to (*pru_abort)().
We abort only the sockets which are linked to `so_q' or `so_q0' queues of
listening socket. Such sockets have no corresponding file descriptor and
are not accessed from userland, so PRU_ABORT used to destroy them on
listening socket destruction.
Currently all our sockets support PRU_ABORT request, but actually it
required only for tcp(4) and unix(4) sockets, so i should be optional.
However, they will be removed with separate diff, and this time PRU_ABORT
requests were converted as is.
Also, the socket should be destroyed on PRU_ABORT request, but route and
key management sockets leave it alive. This was also converted as is,
because this wrong code never called.
ok bluhm@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/uipc_usrreq.c | 19 | ||||
-rw-r--r-- | sys/net/pfkeyv2.c | 14 | ||||
-rw-r--r-- | sys/net/rtsock.c | 14 | ||||
-rw-r--r-- | sys/netinet/ip_divert.c | 21 | ||||
-rw-r--r-- | sys/netinet/ip_divert.h | 3 | ||||
-rw-r--r-- | sys/netinet/ip_gre.c | 3 | ||||
-rw-r--r-- | sys/netinet/ip_var.h | 3 | ||||
-rw-r--r-- | sys/netinet/raw_ip.c | 30 | ||||
-rw-r--r-- | sys/netinet/tcp_usrreq.c | 38 | ||||
-rw-r--r-- | sys/netinet/tcp_var.h | 3 | ||||
-rw-r--r-- | sys/netinet/udp_usrreq.c | 21 | ||||
-rw-r--r-- | sys/netinet/udp_var.h | 3 | ||||
-rw-r--r-- | sys/netinet6/ip6_divert.c | 20 | ||||
-rw-r--r-- | sys/netinet6/ip6_divert.h | 3 | ||||
-rw-r--r-- | sys/netinet6/ip6_var.h | 3 | ||||
-rw-r--r-- | sys/netinet6/raw_ip6.c | 37 | ||||
-rw-r--r-- | sys/sys/protosw.h | 6 | ||||
-rw-r--r-- | sys/sys/unpcb.h | 3 |
18 files changed, 166 insertions, 78 deletions
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 2dbbabf689f..93a49040a42 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_usrreq.c,v 1.176 2022/08/27 20:28:01 mvs Exp $ */ +/* $OpenBSD: uipc_usrreq.c,v 1.177 2022/08/28 18:44:16 mvs Exp $ */ /* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */ /* @@ -138,6 +138,7 @@ const struct pr_usrreqs uipc_usrreqs = { .pru_shutdown = uipc_shutdown, .pru_rcvd = uipc_rcvd, .pru_send = uipc_send, + .pru_abort = uipc_abort, }; void @@ -245,11 +246,6 @@ uipc_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, } break; - case PRU_ABORT: - unp_detach(unp); - sofree(so, 0); - break; - case PRU_SENSE: { struct stat *sb = (struct stat *)m; @@ -591,6 +587,17 @@ out: } int +uipc_abort(struct socket *so) +{ + struct unpcb *unp = sotounpcb(so); + + unp_detach(unp); + sofree(so, 0); + + return (0); +} + +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 995fb51036f..df2daf9283d 100644 --- a/sys/net/pfkeyv2.c +++ b/sys/net/pfkeyv2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkeyv2.c,v 1.243 2022/08/27 20:28:01 mvs Exp $ */ +/* $OpenBSD: pfkeyv2.c,v 1.244 2022/08/28 18:44:16 mvs Exp $ */ /* * @(#)COPYRIGHT 1.1 (NRL) 17 January 1995 @@ -175,6 +175,7 @@ int pfkeyv2_disconnect(struct socket *); int pfkeyv2_shutdown(struct socket *); int pfkeyv2_send(struct socket *, struct mbuf *, struct mbuf *, struct mbuf *); +int pfkeyv2_abort(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 *, @@ -210,6 +211,7 @@ const struct pr_usrreqs pfkeyv2_usrreqs = { .pru_disconnect = pfkeyv2_disconnect, .pru_shutdown = pfkeyv2_shutdown, .pru_send = pfkeyv2_send, + .pru_abort = pfkeyv2_abort, }; const struct protosw pfkeysw[] = { @@ -382,6 +384,13 @@ out: } int +pfkeyv2_abort(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) { @@ -410,9 +419,6 @@ pfkeyv2_usrreq(struct socket *so, int req, struct mbuf *m, error = EOPNOTSUPP; break; - case PRU_ABORT: - soisdisconnected(so); - break; case PRU_SENSE: /* stat: don't bother with a blocksize. */ break; diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 19c77bd8538..2d8cb44e614 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.343 2022/08/27 20:28:01 mvs Exp $ */ +/* $OpenBSD: rtsock.c,v 1.344 2022/08/28 18:44:16 mvs Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -119,6 +119,7 @@ int route_shutdown(struct socket *); int route_rcvd(struct socket *); int route_send(struct socket *, struct mbuf *, struct mbuf *, struct mbuf *); +int route_abort(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); @@ -242,9 +243,6 @@ route_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, error = EOPNOTSUPP; break; - case PRU_ABORT: - soisdisconnected(so); - break; case PRU_SENSE: /* stat: don't bother with a blocksize. */ break; @@ -406,6 +404,13 @@ out: } int +route_abort(struct socket *so) +{ + soisdisconnected(so); + return (0); +} + +int route_ctloutput(int op, struct socket *so, int level, int optname, struct mbuf *m) { @@ -2448,6 +2453,7 @@ const struct pr_usrreqs route_usrreqs = { .pru_shutdown = route_shutdown, .pru_rcvd = route_rcvd, .pru_send = route_send, + .pru_abort = route_abort, }; const struct protosw routesw[] = { diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 11583387f61..dffb8e8477b 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_divert.c,v 1.78 2022/08/27 20:28:01 mvs Exp $ */ +/* $OpenBSD: ip_divert.c,v 1.79 2022/08/28 18:44:16 mvs Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -69,6 +69,7 @@ const struct pr_usrreqs divert_usrreqs = { .pru_bind = divert_bind, .pru_shutdown = divert_shutdown, .pru_send = divert_send, + .pru_abort = divert_abort, }; int divbhashsize = DIVERTHASHSIZE; @@ -270,11 +271,6 @@ divert_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr, } switch (req) { - case PRU_ABORT: - soisdisconnected(so); - in_pcbdetach(inp); - break; - case PRU_SOCKADDR: in_setsockaddr(inp, addr); break; @@ -372,6 +368,19 @@ divert_send(struct socket *so, struct mbuf *m, struct mbuf *addr, } int +divert_abort(struct socket *so) +{ + struct inpcb *inp = sotoinpcb(so); + + soassertlocked(so); + + soisdisconnected(so); + in_pcbdetach(inp); + + return (0); +} + +int divert_sysctl_divstat(void *oldp, size_t *oldlenp, void *newp) { uint64_t counters[divs_ncounters]; diff --git a/sys/netinet/ip_divert.h b/sys/netinet/ip_divert.h index 020f2ae2ef1..004047b9403 100644 --- a/sys/netinet/ip_divert.h +++ b/sys/netinet/ip_divert.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_divert.h,v 1.19 2022/08/27 20:28:01 mvs Exp $ */ +/* $OpenBSD: ip_divert.h,v 1.20 2022/08/28 18:44:16 mvs Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -78,5 +78,6 @@ int divert_bind(struct socket *, struct mbuf *, struct proc *); int divert_shutdown(struct socket *); int divert_send(struct socket *, struct mbuf *, struct mbuf *, struct mbuf *); +int divert_abort(struct socket *); #endif /* _KERNEL */ #endif /* _IP_DIVERT_H_ */ diff --git a/sys/netinet/ip_gre.c b/sys/netinet/ip_gre.c index 55a853f45f8..588a51ff8cf 100644 --- a/sys/netinet/ip_gre.c +++ b/sys/netinet/ip_gre.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_gre.c,v 1.80 2022/08/27 20:28:01 mvs Exp $ */ +/* $OpenBSD: ip_gre.c,v 1.81 2022/08/28 18:44:16 mvs Exp $ */ /* $NetBSD: ip_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */ /* @@ -70,6 +70,7 @@ const struct pr_usrreqs gre_usrreqs = { .pru_disconnect = rip_disconnect, .pru_shutdown = rip_shutdown, .pru_send = gre_send, + .pru_abort = rip_abort, }; int diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h index d96d55fa5b9..89a53ccd43e 100644 --- a/sys/netinet/ip_var.h +++ b/sys/netinet/ip_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_var.h,v 1.102 2022/08/27 20:28:01 mvs Exp $ */ +/* $OpenBSD: ip_var.h,v 1.103 2022/08/28 18:44:16 mvs Exp $ */ /* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */ /* @@ -266,6 +266,7 @@ int rip_disconnect(struct socket *); int rip_shutdown(struct socket *); int rip_send(struct socket *, struct mbuf *, struct mbuf *, struct mbuf *); +int rip_abort(struct socket *); #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 958c5dddbb2..14d8b23e06c 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip.c,v 1.139 2022/08/27 20:28:01 mvs Exp $ */ +/* $OpenBSD: raw_ip.c,v 1.140 2022/08/28 18:44:16 mvs Exp $ */ /* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */ /* @@ -112,6 +112,7 @@ const struct pr_usrreqs rip_usrreqs = { .pru_disconnect = rip_disconnect, .pru_shutdown = rip_shutdown, .pru_send = rip_send, + .pru_abort = rip_abort, }; /* @@ -477,17 +478,6 @@ rip_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, switch (req) { - case PRU_ABORT: - soisdisconnected(so); - if (inp == NULL) - panic("rip_abort"); -#ifdef MROUTING - if (so == ip_mrouter[inp->inp_rtableid]) - ip_mrouter_done(so); -#endif - in_pcbdetach(inp); - break; - case PRU_CONNECT2: error = EOPNOTSUPP; break; @@ -685,3 +675,19 @@ out: return (error); } +int +rip_abort(struct socket *so) +{ + struct inpcb *inp = sotoinpcb(so); + + soassertlocked(so); + + soisdisconnected(so); +#ifdef MROUTING + if (so == ip_mrouter[inp->inp_rtableid]) + ip_mrouter_done(so); +#endif + in_pcbdetach(inp); + + return (0); +} 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. diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index b07457c8613..516b3c478c8 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_var.h,v 1.149 2022/08/27 20:28:01 mvs Exp $ */ +/* $OpenBSD: tcp_var.h,v 1.150 2022/08/28 18:44:16 mvs Exp $ */ /* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */ /* @@ -723,6 +723,7 @@ int tcp_shutdown(struct socket *); int tcp_rcvd(struct socket *); int tcp_send(struct socket *, struct mbuf *, struct mbuf *, struct mbuf *); +int tcp_abort(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); diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index a85645ed9be..3dd324f735a 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.291 2022/08/27 20:28:01 mvs Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.292 2022/08/28 18:44:16 mvs Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -131,6 +131,7 @@ const struct pr_usrreqs udp_usrreqs = { .pru_disconnect = udp_disconnect, .pru_shutdown = udp_shutdown, .pru_send = udp_send, + .pru_abort = udp_abort, }; const struct sysctl_bounded_args udpctl_vars[] = { @@ -1087,11 +1088,6 @@ udp_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr, error = EOPNOTSUPP; break; - case PRU_ABORT: - soisdisconnected(so); - in_pcbdetach(inp); - break; - case PRU_SOCKADDR: #ifdef INET6 if (inp->inp_flags & INP_IPV6) @@ -1304,6 +1300,19 @@ udp_send(struct socket *so, struct mbuf *m, struct mbuf *addr, return (error); } +int +udp_abort(struct socket *so) +{ + struct inpcb *inp = sotoinpcb(so); + + soassertlocked(so); + + soisdisconnected(so); + in_pcbdetach(inp); + + return (0); +} + /* * Sysctl for udp variables. */ diff --git a/sys/netinet/udp_var.h b/sys/netinet/udp_var.h index bdf2dff98b4..a564b799fc0 100644 --- a/sys/netinet/udp_var.h +++ b/sys/netinet/udp_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_var.h,v 1.43 2022/08/27 20:28:01 mvs Exp $ */ +/* $OpenBSD: udp_var.h,v 1.44 2022/08/28 18:44:16 mvs Exp $ */ /* $NetBSD: udp_var.h,v 1.12 1996/02/13 23:44:41 christos Exp $ */ /* @@ -149,5 +149,6 @@ int udp_disconnect(struct socket *); int udp_shutdown(struct socket *); int udp_send(struct socket *, struct mbuf *, struct mbuf *, struct mbuf *); +int udp_abort(struct socket *); #endif /* _KERNEL */ #endif /* _NETINET_UDP_VAR_H_ */ diff --git a/sys/netinet6/ip6_divert.c b/sys/netinet6/ip6_divert.c index b9617bab118..73019e5914f 100644 --- a/sys/netinet6/ip6_divert.c +++ b/sys/netinet6/ip6_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_divert.c,v 1.77 2022/08/27 20:28:01 mvs Exp $ */ +/* $OpenBSD: ip6_divert.c,v 1.78 2022/08/28 18:44:17 mvs Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -70,6 +70,7 @@ const struct pr_usrreqs divert6_usrreqs = { .pru_bind = divert6_bind, .pru_shutdown = divert6_shutdown, .pru_send = divert6_send, + .pru_abort = divert6_abort, }; int divb6hashsize = DIVERTHASHSIZE; @@ -276,11 +277,6 @@ divert6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *addr, } switch (req) { - case PRU_ABORT: - soisdisconnected(so); - in_pcbdetach(inp); - break; - case PRU_SOCKADDR: in6_setsockaddr(inp, addr); break; @@ -380,6 +376,18 @@ divert6_send(struct socket *so, struct mbuf *m, struct mbuf *addr, } int +divert6_abort(struct socket *so) +{ + struct inpcb *inp = sotoinpcb(so); + + soassertlocked(so); + soisdisconnected(so); + in_pcbdetach(inp); + + return (0); +} + +int divert6_sysctl_div6stat(void *oldp, size_t *oldlenp, void *newp) { uint64_t counters[div6s_ncounters]; diff --git a/sys/netinet6/ip6_divert.h b/sys/netinet6/ip6_divert.h index 0414661edcf..21884ac948e 100644 --- a/sys/netinet6/ip6_divert.h +++ b/sys/netinet6/ip6_divert.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_divert.h,v 1.17 2022/08/27 20:28:01 mvs Exp $ */ +/* $OpenBSD: ip6_divert.h,v 1.18 2022/08/28 18:44:17 mvs Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -78,6 +78,7 @@ int divert6_bind(struct socket *, struct mbuf *, struct proc *); int divert6_shutdown(struct socket *); int divert6_send(struct socket *, struct mbuf *, struct mbuf *, struct mbuf *); +int divert6_abort(struct socket *); #endif /* _KERNEL */ #endif /* _IP6_DIVERT_H_ */ diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h index e24406f826e..ee560a02273 100644 --- a/sys/netinet6/ip6_var.h +++ b/sys/netinet6/ip6_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_var.h,v 1.100 2022/08/27 20:28:01 mvs Exp $ */ +/* $OpenBSD: ip6_var.h,v 1.101 2022/08/28 18:44:17 mvs Exp $ */ /* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */ /* @@ -361,6 +361,7 @@ int rip6_disconnect(struct socket *); int rip6_shutdown(struct socket *); int rip6_send(struct socket *, struct mbuf *, struct mbuf *, struct mbuf *); +int rip6_abort(struct socket *); 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 c1270d73c8a..20306191f8a 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip6.c,v 1.159 2022/08/27 20:28:01 mvs Exp $ */ +/* $OpenBSD: raw_ip6.c,v 1.160 2022/08/28 18:44:17 mvs Exp $ */ /* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */ /* @@ -114,6 +114,7 @@ const struct pr_usrreqs rip6_usrreqs = { .pru_disconnect = rip6_disconnect, .pru_shutdown = rip6_shutdown, .pru_send = rip6_send, + .pru_abort = rip6_abort, }; /* @@ -592,20 +593,6 @@ rip6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, } switch (req) { - case PRU_ABORT: - soisdisconnected(so); - if (in6p == NULL) - panic("%s", __func__); -#ifdef MROUTING - if (so == ip6_mrouter[in6p->inp_rtableid]) - ip6_mrouter_done(so); -#endif - free(in6p->inp_icmp6filt, M_PCB, sizeof(struct icmp6_filter)); - in6p->inp_icmp6filt = NULL; - - in_pcbdetach(in6p); - break; - case PRU_CONNECT2: error = EOPNOTSUPP; break; @@ -820,6 +807,26 @@ out: } int +rip6_abort(struct socket *so) +{ + struct inpcb *in6p = sotoinpcb(so); + + soassertlocked(so); + + soisdisconnected(so); +#ifdef MROUTING + if (so == ip6_mrouter[in6p->inp_rtableid]) + ip6_mrouter_done(so); +#endif + free(in6p->inp_icmp6filt, M_PCB, sizeof(struct icmp6_filter)); + in6p->inp_icmp6filt = NULL; + + in_pcbdetach(in6p); + + 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 cec2616288c..be609dea880 100644 --- a/sys/sys/protosw.h +++ b/sys/sys/protosw.h @@ -1,4 +1,4 @@ -/* $OpenBSD: protosw.h,v 1.45 2022/08/27 20:28:01 mvs Exp $ */ +/* $OpenBSD: protosw.h,v 1.46 2022/08/28 18:44:17 mvs Exp $ */ /* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */ /*- @@ -75,6 +75,7 @@ struct pr_usrreqs { int (*pru_rcvd)(struct socket *); int (*pru_send)(struct socket *, struct mbuf *, struct mbuf *, struct mbuf *); + int (*pru_abort)(struct socket *); }; struct protosw { @@ -334,8 +335,7 @@ pru_send(struct socket *so, struct mbuf *top, struct mbuf *addr, static inline int pru_abort(struct socket *so) { - return (*so->so_proto->pr_usrreqs->pru_usrreq)(so, - PRU_ABORT, NULL, NULL, NULL, curproc); + return (*so->so_proto->pr_usrreqs->pru_abort)(so); } static inline int diff --git a/sys/sys/unpcb.h b/sys/sys/unpcb.h index 4521ceb25ba..b4e46618688 100644 --- a/sys/sys/unpcb.h +++ b/sys/sys/unpcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: unpcb.h,v 1.35 2022/08/27 20:28:01 mvs Exp $ */ +/* $OpenBSD: unpcb.h,v 1.36 2022/08/28 18:44:17 mvs Exp $ */ /* $NetBSD: unpcb.h,v 1.6 1994/06/29 06:46:08 cgd Exp $ */ /* @@ -122,6 +122,7 @@ int uipc_shutdown(struct socket *); int uipc_rcvd(struct socket *); int uipc_send(struct socket *, struct mbuf *, struct mbuf *, struct mbuf *); +int uipc_abort(struct socket *); void unp_init(void); int unp_bind(struct unpcb *, struct mbuf *, struct proc *); |