From 280d7fb53c6711de2bb83b7a67ed4ac8b8b3b32c Mon Sep 17 00:00:00 2001 From: mvs Date: Mon, 17 Oct 2022 14:49:01 +0000 Subject: [PATCH] Change pru_abort() return type to the type of void and make pru_abort() optional. We have no interest on pru_abort() return value. We call it only from soabort() which is dummy pru_abort() wrapper and has no return value. Only the connection oriented sockets need to implement (*pru_abort)() handler. Such sockets are tcp(4) and unix(4) sockets, so remove existing code for all others, it doesn't called. ok guenther@ --- sys/kern/uipc_usrreq.c | 6 ++---- sys/net/pfkeyv2.c | 11 +---------- sys/net/rtsock.c | 11 +---------- sys/netinet/ip_divert.c | 16 +--------------- sys/netinet/ip_divert.h | 3 +-- sys/netinet/ip_gre.c | 3 +-- sys/netinet/ip_var.h | 3 +-- sys/netinet/raw_ip.c | 20 +------------------- sys/netinet/tcp_usrreq.c | 10 ++++------ sys/netinet/tcp_var.h | 4 ++-- sys/netinet/udp_usrreq.c | 17 +---------------- sys/netinet/udp_var.h | 3 +-- sys/netinet6/ip6_divert.c | 15 +-------------- sys/netinet6/ip6_divert.h | 3 +-- sys/netinet6/ip6_var.h | 3 +-- sys/netinet6/raw_ip6.c | 23 +---------------------- sys/sys/protosw.h | 8 ++++---- sys/sys/unpcb.h | 4 ++-- 18 files changed, 27 insertions(+), 136 deletions(-) diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index bf5d83bb828..38f4d073198 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_usrreq.c,v 1.190 2022/10/03 16:43:52 bluhm Exp $ */ +/* $OpenBSD: uipc_usrreq.c,v 1.191 2022/10/17 14:49:01 mvs Exp $ */ /* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */ /* @@ -502,15 +502,13 @@ out: return (error); } -int +void uipc_abort(struct socket *so) { struct unpcb *unp = sotounpcb(so); unp_detach(unp); sofree(so, 0); - - return (0); } int diff --git a/sys/net/pfkeyv2.c b/sys/net/pfkeyv2.c index 022bd5ae025..d18956afce3 100644 --- a/sys/net/pfkeyv2.c +++ b/sys/net/pfkeyv2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkeyv2.c,v 1.253 2022/10/03 16:43:52 bluhm Exp $ */ +/* $OpenBSD: pfkeyv2.c,v 1.254 2022/10/17 14:49:01 mvs Exp $ */ /* * @(#)COPYRIGHT 1.1 (NRL) 17 January 1995 @@ -175,7 +175,6 @@ 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_sockaddr(struct socket *, struct mbuf *); int pfkeyv2_peeraddr(struct socket *, struct mbuf *); int pfkeyv2_output(struct mbuf *, struct socket *); @@ -209,7 +208,6 @@ const struct pr_usrreqs pfkeyv2_usrreqs = { .pru_disconnect = pfkeyv2_disconnect, .pru_shutdown = pfkeyv2_shutdown, .pru_send = pfkeyv2_send, - .pru_abort = pfkeyv2_abort, .pru_sockaddr = pfkeyv2_sockaddr, .pru_peeraddr = pfkeyv2_peeraddr, }; @@ -385,13 +383,6 @@ out: return (error); } -int -pfkeyv2_abort(struct socket *so) -{ - soisdisconnected(so); - return (0); -} - int pfkeyv2_sockaddr(struct socket *so, struct mbuf *nam) { diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 1abd01340c1..c8c5f1bad07 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.357 2022/10/03 16:43:52 bluhm Exp $ */ +/* $OpenBSD: rtsock.c,v 1.358 2022/10/17 14:49:02 mvs Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -118,7 +118,6 @@ int route_shutdown(struct socket *); void route_rcvd(struct socket *); int route_send(struct socket *, struct mbuf *, struct mbuf *, struct mbuf *); -int route_abort(struct socket *); int route_sockaddr(struct socket *, struct mbuf *); int route_peeraddr(struct socket *, struct mbuf *); void route_input(struct mbuf *m0, struct socket *, sa_family_t); @@ -347,13 +346,6 @@ out: return (error); } -int -route_abort(struct socket *so) -{ - soisdisconnected(so); - return (0); -} - int route_sockaddr(struct socket *so, struct mbuf *nam) { @@ -2409,7 +2401,6 @@ const struct pr_usrreqs route_usrreqs = { .pru_shutdown = route_shutdown, .pru_rcvd = route_rcvd, .pru_send = route_send, - .pru_abort = route_abort, .pru_sockaddr = route_sockaddr, .pru_peeraddr = route_peeraddr, }; diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 9d4867776cf..1ca49a1738f 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_divert.c,v 1.88 2022/10/03 16:43:52 bluhm Exp $ */ +/* $OpenBSD: ip_divert.c,v 1.89 2022/10/17 14:49:02 mvs Exp $ */ /* * Copyright (c) 2009 Michele Marchetto @@ -70,7 +70,6 @@ const struct pr_usrreqs divert_usrreqs = { .pru_bind = divert_bind, .pru_shutdown = divert_shutdown, .pru_send = divert_send, - .pru_abort = divert_abort, .pru_control = in_control, .pru_sockaddr = in_sockaddr, .pru_peeraddr = in_peeraddr, @@ -335,19 +334,6 @@ divert_send(struct socket *so, struct mbuf *m, struct mbuf *addr, return (divert_output(inp, m, addr, control)); } -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) { diff --git a/sys/netinet/ip_divert.h b/sys/netinet/ip_divert.h index 098e424b0f3..14188641599 100644 --- a/sys/netinet/ip_divert.h +++ b/sys/netinet/ip_divert.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_divert.h,v 1.23 2022/10/03 16:43:52 bluhm Exp $ */ +/* $OpenBSD: ip_divert.h,v 1.24 2022/10/17 14:49:02 mvs Exp $ */ /* * Copyright (c) 2009 Michele Marchetto @@ -78,6 +78,5 @@ 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 eb89d8b7cb1..2d2f929496e 100644 --- a/sys/netinet/ip_gre.c +++ b/sys/netinet/ip_gre.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_gre.c,v 1.84 2022/09/03 22:43:38 mvs Exp $ */ +/* $OpenBSD: ip_gre.c,v 1.85 2022/10/17 14:49:02 mvs Exp $ */ /* $NetBSD: ip_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */ /* @@ -71,7 +71,6 @@ const struct pr_usrreqs gre_usrreqs = { .pru_disconnect = rip_disconnect, .pru_shutdown = rip_shutdown, .pru_send = gre_send, - .pru_abort = rip_abort, .pru_control = in_control, .pru_sockaddr = in_sockaddr, .pru_peeraddr = in_peeraddr, diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h index 3f90bbc60d9..d9e12bc0c0c 100644 --- a/sys/netinet/ip_var.h +++ b/sys/netinet/ip_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_var.h,v 1.106 2022/10/03 16:43:52 bluhm Exp $ */ +/* $OpenBSD: ip_var.h,v 1.107 2022/10/17 14:49:02 mvs Exp $ */ /* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */ /* @@ -266,7 +266,6 @@ 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 68e5a443ff7..86c194a35ea 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip.c,v 1.149 2022/10/03 16:43:52 bluhm Exp $ */ +/* $OpenBSD: raw_ip.c,v 1.150 2022/10/17 14:49:02 mvs Exp $ */ /* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */ /* @@ -113,7 +113,6 @@ const struct pr_usrreqs rip_usrreqs = { .pru_disconnect = rip_disconnect, .pru_shutdown = rip_shutdown, .pru_send = rip_send, - .pru_abort = rip_abort, .pru_control = in_control, .pru_sockaddr = in_sockaddr, .pru_peeraddr = in_peeraddr, @@ -644,20 +643,3 @@ 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 85083ee1fe0..30c562dd7de 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_usrreq.c,v 1.209 2022/10/03 16:43:52 bluhm Exp $ */ +/* $OpenBSD: tcp_usrreq.c,v 1.210 2022/10/17 14:49:02 mvs Exp $ */ /* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */ /* @@ -865,18 +865,17 @@ out: /* * Abort the TCP. */ -int +void 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 (tcp_sogetpcb(so, &inp, &tp)) + return; if (so->so_options & SO_DEBUG) { otp = tp; @@ -887,7 +886,6 @@ tcp_abort(struct socket *so) if (otp) tcp_trace(TA_USER, ostate, tp, otp, NULL, PRU_ABORT, 0); - return (0); } int diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 430bc561f5b..d9630b0c58c 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_var.h,v 1.159 2022/10/03 16:43:52 bluhm Exp $ */ +/* $OpenBSD: tcp_var.h,v 1.160 2022/10/17 14:49:02 mvs Exp $ */ /* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */ /* @@ -728,7 +728,7 @@ int tcp_shutdown(struct socket *); void tcp_rcvd(struct socket *); int tcp_send(struct socket *, struct mbuf *, struct mbuf *, struct mbuf *); -int tcp_abort(struct socket *); +void tcp_abort(struct socket *); int tcp_sockaddr(struct socket *, struct mbuf *); int tcp_peeraddr(struct socket *, struct mbuf *); int tcp_sense(struct socket *, struct stat *); diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 1b7aa8210b9..f28df13e0ef 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.303 2022/10/03 16:43:52 bluhm Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.304 2022/10/17 14:49:02 mvs Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -132,7 +132,6 @@ const struct pr_usrreqs udp_usrreqs = { .pru_disconnect = udp_disconnect, .pru_shutdown = udp_shutdown, .pru_send = udp_send, - .pru_abort = udp_abort, .pru_control = in_control, .pru_sockaddr = in_sockaddr, .pru_peeraddr = in_peeraddr, @@ -149,7 +148,6 @@ const struct pr_usrreqs udp6_usrreqs = { .pru_disconnect = udp_disconnect, .pru_shutdown = udp_shutdown, .pru_send = udp_send, - .pru_abort = udp_abort, .pru_control = in6_control, .pru_sockaddr = in6_sockaddr, .pru_peeraddr = in6_peeraddr, @@ -1260,19 +1258,6 @@ 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 bfe0723f115..cd4dafbbdb4 100644 --- a/sys/netinet/udp_var.h +++ b/sys/netinet/udp_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_var.h,v 1.48 2022/10/03 16:43:52 bluhm Exp $ */ +/* $OpenBSD: udp_var.h,v 1.49 2022/10/17 14:49:02 mvs Exp $ */ /* $NetBSD: udp_var.h,v 1.12 1996/02/13 23:44:41 christos Exp $ */ /* @@ -153,6 +153,5 @@ 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 daea9b981ca..c7539f64a26 100644 --- a/sys/netinet6/ip6_divert.c +++ b/sys/netinet6/ip6_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_divert.c,v 1.87 2022/10/03 16:43:52 bluhm Exp $ */ +/* $OpenBSD: ip6_divert.c,v 1.88 2022/10/17 14:49:02 mvs Exp $ */ /* * Copyright (c) 2009 Michele Marchetto @@ -71,7 +71,6 @@ const struct pr_usrreqs divert6_usrreqs = { .pru_bind = divert6_bind, .pru_shutdown = divert6_shutdown, .pru_send = divert6_send, - .pru_abort = divert6_abort, .pru_control = in6_control, .pru_sockaddr = in6_sockaddr, .pru_peeraddr = in6_peeraddr, @@ -343,18 +342,6 @@ divert6_send(struct socket *so, struct mbuf *m, struct mbuf *addr, return (divert6_output(inp, m, addr, control)); } -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) { diff --git a/sys/netinet6/ip6_divert.h b/sys/netinet6/ip6_divert.h index d19db2141e5..aeff58338a6 100644 --- a/sys/netinet6/ip6_divert.h +++ b/sys/netinet6/ip6_divert.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_divert.h,v 1.21 2022/10/03 16:43:52 bluhm Exp $ */ +/* $OpenBSD: ip6_divert.h,v 1.22 2022/10/17 14:49:02 mvs Exp $ */ /* * Copyright (c) 2009 Michele Marchetto @@ -78,7 +78,6 @@ 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 7aad9019955..ef5703eed0a 100644 --- a/sys/netinet6/ip6_var.h +++ b/sys/netinet6/ip6_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_var.h,v 1.104 2022/10/03 16:43:52 bluhm Exp $ */ +/* $OpenBSD: ip6_var.h,v 1.105 2022/10/17 14:49:02 mvs Exp $ */ /* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */ /* @@ -361,7 +361,6 @@ 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 cfa24451874..a161cef92ae 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip6.c,v 1.170 2022/10/03 16:43:52 bluhm Exp $ */ +/* $OpenBSD: raw_ip6.c,v 1.171 2022/10/17 14:49:02 mvs Exp $ */ /* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */ /* @@ -115,7 +115,6 @@ const struct pr_usrreqs rip6_usrreqs = { .pru_disconnect = rip6_disconnect, .pru_shutdown = rip6_shutdown, .pru_send = rip6_send, - .pru_abort = rip6_abort, .pru_control = in6_control, .pru_sockaddr = in6_sockaddr, .pru_peeraddr = in6_peeraddr, @@ -779,26 +778,6 @@ out: return (error); } -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) { diff --git a/sys/sys/protosw.h b/sys/sys/protosw.h index 38304171186..cbabe0b66bd 100644 --- a/sys/sys/protosw.h +++ b/sys/sys/protosw.h @@ -1,4 +1,4 @@ -/* $OpenBSD: protosw.h,v 1.57 2022/10/03 16:43:52 bluhm Exp $ */ +/* $OpenBSD: protosw.h,v 1.58 2022/10/17 14:49:02 mvs Exp $ */ /* $NetBSD: protosw.h,v 1.10 1996/04/09 20:55:32 cgd Exp $ */ /*- @@ -75,7 +75,7 @@ struct pr_usrreqs { void (*pru_rcvd)(struct socket *); int (*pru_send)(struct socket *, struct mbuf *, struct mbuf *, struct mbuf *); - int (*pru_abort)(struct socket *); + void (*pru_abort)(struct socket *); int (*pru_control)(struct socket *, u_long, caddr_t, struct ifnet *); int (*pru_sense)(struct socket *, struct stat *); @@ -349,10 +349,10 @@ pru_send(struct socket *so, struct mbuf *top, struct mbuf *addr, return (*so->so_proto->pr_usrreqs->pru_send)(so, top, addr, control); } -static inline int +static inline void pru_abort(struct socket *so) { - return (*so->so_proto->pr_usrreqs->pru_abort)(so); + (*so->so_proto->pr_usrreqs->pru_abort)(so); } static inline int diff --git a/sys/sys/unpcb.h b/sys/sys/unpcb.h index b0a02c41856..03f4cbb9e55 100644 --- a/sys/sys/unpcb.h +++ b/sys/sys/unpcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: unpcb.h,v 1.42 2022/10/03 16:43:52 bluhm Exp $ */ +/* $OpenBSD: unpcb.h,v 1.43 2022/10/17 14:49:02 mvs Exp $ */ /* $NetBSD: unpcb.h,v 1.6 1994/06/29 06:46:08 cgd Exp $ */ /* @@ -123,7 +123,7 @@ int uipc_shutdown(struct socket *); void uipc_rcvd(struct socket *); int uipc_send(struct socket *, struct mbuf *, struct mbuf *, struct mbuf *); -int uipc_abort(struct socket *); +void uipc_abort(struct socket *); int uipc_sense(struct socket *, struct stat *); int uipc_sockaddr(struct socket *, struct mbuf *); int uipc_peeraddr(struct socket *, struct mbuf *); -- 2.20.1