On Mon, Aug 22, 2022 at 08:22:11PM +0200, Alexander Bluhm wrote:
> > +
> > +out:
> > + if (otp)
> > + tcp_trace(TA_USER, ostate, tp, otp, NULL, PRU_SHUTDOWN, 0);
> > return (0);
>
> This must be return (error).
>
Fixed, thanks!
Index: sys/kern/uipc_usrreq.c
===================================================================
RCS file: /cvs/src/sys/kern/uipc_usrreq.c,v
retrieving revision 1.173
diff -u -p -r1.173 uipc_usrreq.c
--- sys/kern/uipc_usrreq.c 22 Aug 2022 13:23:06 -0000 1.173
+++ sys/kern/uipc_usrreq.c 22 Aug 2022 20:57:40 -0000
@@ -135,6 +135,7 @@ const struct pr_usrreqs uipc_usrreqs = {
.pru_connect = uipc_connect,
.pru_accept = uipc_accept,
.pru_disconnect = uipc_disconnect,
+ .pru_shutdown = uipc_shutdown,
};
void
@@ -242,11 +243,6 @@ uipc_usrreq(struct socket *so, int req,
}
break;
- case PRU_SHUTDOWN:
- socantsendmore(so);
- unp_shutdown(unp);
- break;
-
case PRU_RCVD:
switch (so->so_type) {
@@ -561,6 +557,16 @@ uipc_disconnect(struct socket *so)
struct unpcb *unp = sotounpcb(so);
unp_disconnect(unp);
+ return (0);
+}
+
+int
+uipc_shutdown(struct socket *so)
+{
+ struct unpcb *unp = sotounpcb(so);
+
+ socantsendmore(so);
+ unp_shutdown(unp);
return (0);
}
Index: sys/net/pfkeyv2.c
===================================================================
RCS file: /cvs/src/sys/net/pfkeyv2.c,v
retrieving revision 1.240
diff -u -p -r1.240 pfkeyv2.c
--- sys/net/pfkeyv2.c 22 Aug 2022 13:23:06 -0000 1.240
+++ sys/net/pfkeyv2.c 22 Aug 2022 20:57:40 -0000
@@ -172,6 +172,7 @@ void pfkey_init(void);
int pfkeyv2_attach(struct socket *, int);
int pfkeyv2_detach(struct socket *);
int pfkeyv2_disconnect(struct socket *);
+int pfkeyv2_shutdown(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 *,
@@ -205,6 +206,7 @@ const struct pr_usrreqs pfkeyv2_usrreqs
.pru_attach = pfkeyv2_attach,
.pru_detach = pfkeyv2_detach,
.pru_disconnect = pfkeyv2_disconnect,
+ .pru_shutdown = pfkeyv2_shutdown,
};
const struct protosw pfkeysw[] = {
@@ -342,6 +344,13 @@ pfkeyv2_disconnect(struct socket *so)
}
int
+pfkeyv2_shutdown(struct socket *so)
+{
+ socantsendmore(so);
+ return (0);
+}
+
+int
pfkeyv2_usrreq(struct socket *so, int req, struct mbuf *m,
struct mbuf *nam, struct mbuf *control, struct proc *p)
{
@@ -372,9 +381,6 @@ pfkeyv2_usrreq(struct socket *so, int re
case PRU_ABORT:
soisdisconnected(so);
- break;
- case PRU_SHUTDOWN:
- socantsendmore(so);
break;
case PRU_SENSE:
/* stat: don't bother with a blocksize. */
Index: sys/net/rtsock.c
===================================================================
RCS file: /cvs/src/sys/net/rtsock.c,v
retrieving revision 1.340
diff -u -p -r1.340 rtsock.c
--- sys/net/rtsock.c 22 Aug 2022 13:23:07 -0000 1.340
+++ sys/net/rtsock.c 22 Aug 2022 20:57:40 -0000
@@ -115,6 +115,7 @@ int route_ctloutput(int, struct socket *
int route_usrreq(struct socket *, int, struct mbuf *, struct mbuf *,
struct mbuf *, struct proc *);
int route_disconnect(struct socket *);
+int route_shutdown(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);
@@ -241,9 +242,6 @@ route_usrreq(struct socket *so, int req,
case PRU_ABORT:
soisdisconnected(so);
break;
- case PRU_SHUTDOWN:
- socantsendmore(so);
- break;
case PRU_SENSE:
/* stat: don't bother with a blocksize. */
break;
@@ -370,6 +368,13 @@ route_disconnect(struct socket *so)
}
int
+route_shutdown(struct socket *so)
+{
+ socantsendmore(so);
+ return (0);
+}
+
+int
route_ctloutput(int op, struct socket *so, int level, int optname,
struct mbuf *m)
{
@@ -2409,6 +2414,7 @@ const struct pr_usrreqs route_usrreqs =
.pru_attach = route_attach,
.pru_detach = route_detach,
.pru_disconnect = route_disconnect,
+ .pru_shutdown = route_shutdown,
};
const struct protosw routesw[] = {
Index: sys/netinet/ip_divert.c
===================================================================
RCS file: /cvs/src/sys/netinet/ip_divert.c,v
retrieving revision 1.75
diff -u -p -r1.75 ip_divert.c
--- sys/netinet/ip_divert.c 22 Aug 2022 13:23:07 -0000 1.75
+++ sys/netinet/ip_divert.c 22 Aug 2022 20:57:40 -0000
@@ -67,6 +67,7 @@ const struct pr_usrreqs divert_usrreqs =
.pru_attach = divert_attach,
.pru_detach = divert_detach,
.pru_bind = divert_bind,
+ .pru_shutdown = divert_shutdown,
};
int divbhashsize = DIVERTHASHSIZE;
@@ -268,10 +269,6 @@ divert_usrreq(struct socket *so, int req
}
switch (req) {
- case PRU_SHUTDOWN:
- socantsendmore(so);
- break;
-
case PRU_SEND:
return (divert_output(inp, m, addr, control));
@@ -357,6 +354,14 @@ divert_bind(struct socket *so, struct mb
soassertlocked(so);
return in_pcbbind(inp, addr, p);
+}
+
+int
+divert_shutdown(struct socket *so)
+{
+ soassertlocked(so);
+ socantsendmore(so);
+ return (0);
}
int
Index: sys/netinet/ip_divert.h
===================================================================
RCS file: /cvs/src/sys/netinet/ip_divert.h,v
retrieving revision 1.17
diff -u -p -r1.17 ip_divert.h
--- sys/netinet/ip_divert.h 20 Aug 2022 23:48:58 -0000 1.17
+++ sys/netinet/ip_divert.h 22 Aug 2022 20:57:40 -0000
@@ -75,5 +75,6 @@ int divert_usrreq(struct socket *,
int divert_attach(struct socket *, int);
int divert_detach(struct socket *);
int divert_bind(struct socket *, struct mbuf *, struct proc *);
+int divert_shutdown(struct socket *);
#endif /* _KERNEL */
#endif /* _IP_DIVERT_H_ */
Index: sys/netinet/ip_gre.c
===================================================================
RCS file: /cvs/src/sys/netinet/ip_gre.c,v
retrieving revision 1.78
diff -u -p -r1.78 ip_gre.c
--- sys/netinet/ip_gre.c 22 Aug 2022 13:23:07 -0000 1.78
+++ sys/netinet/ip_gre.c 22 Aug 2022 20:57:40 -0000
@@ -68,6 +68,7 @@ const struct pr_usrreqs gre_usrreqs = {
.pru_bind = rip_bind,
.pru_connect = rip_connect,
.pru_disconnect = rip_disconnect,
+ .pru_shutdown = rip_shutdown,
};
int
Index: sys/netinet/ip_var.h
===================================================================
RCS file: /cvs/src/sys/netinet/ip_var.h,v
retrieving revision 1.100
diff -u -p -r1.100 ip_var.h
--- sys/netinet/ip_var.h 22 Aug 2022 13:23:07 -0000 1.100
+++ sys/netinet/ip_var.h 22 Aug 2022 20:57:40 -0000
@@ -263,6 +263,7 @@ 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 *);
+int rip_shutdown(struct socket *);
#ifdef MROUTING
extern struct socket *ip_mrouter[]; /* multicast routing daemon */
#endif
Index: sys/netinet/raw_ip.c
===================================================================
RCS file: /cvs/src/sys/netinet/raw_ip.c,v
retrieving revision 1.136
diff -u -p -r1.136 raw_ip.c
--- sys/netinet/raw_ip.c 22 Aug 2022 13:23:07 -0000 1.136
+++ sys/netinet/raw_ip.c 22 Aug 2022 20:57:40 -0000
@@ -110,6 +110,7 @@ const struct pr_usrreqs rip_usrreqs = {
.pru_bind = rip_bind,
.pru_connect = rip_connect,
.pru_disconnect = rip_disconnect,
+ .pru_shutdown = rip_shutdown,
};
/*
@@ -491,13 +492,6 @@ rip_usrreq(struct socket *so, int req, s
break;
/*
- * Mark the connection as being incapable of further input.
- */
- case PRU_SHUTDOWN:
- socantsendmore(so);
- break;
-
- /*
* Ship a packet out. The appropriate raw output
* routine handles any massaging necessary.
*/
@@ -664,5 +658,18 @@ rip_disconnect(struct socket *so)
soisdisconnected(so);
inp->inp_faddr.s_addr = INADDR_ANY;
+ return (0);
+}
+
+int
+rip_shutdown(struct socket *so)
+{
+ /*
+ * Mark the connection as being incapable of further input.
+ */
+
+ soassertlocked(so);
+ socantsendmore(so);
+
return (0);
}
Index: sys/netinet/tcp_usrreq.c
===================================================================
RCS file: /cvs/src/sys/netinet/tcp_usrreq.c,v
retrieving revision 1.193
diff -u -p -r1.193 tcp_usrreq.c
--- sys/netinet/tcp_usrreq.c 22 Aug 2022 13:23:07 -0000 1.193
+++ sys/netinet/tcp_usrreq.c 22 Aug 2022 20:57:40 -0000
@@ -120,6 +120,7 @@ const struct pr_usrreqs tcp_usrreqs = {
.pru_connect = tcp_connect,
.pru_accept = tcp_accept,
.pru_disconnect = tcp_disconnect,
+ .pru_shutdown = tcp_shutdown,
};
static int pr_slowhz = PR_SLOWHZ;
@@ -224,18 +225,6 @@ tcp_usrreq(struct socket *so, int req, s
break;
/*
- * Mark the connection as being incapable of further output.
- */
- case PRU_SHUTDOWN:
- if (so->so_state & SS_CANTSENDMORE)
- break;
- socantsendmore(so);
- tp = tcp_usrclosed(tp);
- if (tp)
- error = tcp_output(tp);
- break;
-
- /*
* After a receive, possibly send window update to peer.
*/
case PRU_RCVD:
@@ -888,6 +877,41 @@ tcp_disconnect(struct socket *so)
if (otp)
tcp_trace(TA_USER, ostate, tp, otp, NULL, PRU_DISCONNECT, 0);
return (0);
+}
+
+/*
+ * Mark the connection as being incapable of further output.
+ */
+int
+tcp_shutdown(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 (so->so_state & SS_CANTSENDMORE)
+ goto out;
+
+ socantsendmore(so);
+ tp = tcp_usrclosed(tp);
+ if (tp)
+ error = tcp_output(tp);
+
+out:
+ if (otp)
+ tcp_trace(TA_USER, ostate, tp, otp, NULL, PRU_SHUTDOWN, 0);
+ return (error);
}
/*
Index: sys/netinet/tcp_var.h
===================================================================
RCS file: /cvs/src/sys/netinet/tcp_var.h,v
retrieving revision 1.146
diff -u -p -r1.146 tcp_var.h
--- sys/netinet/tcp_var.h 22 Aug 2022 13:23:07 -0000 1.146
+++ sys/netinet/tcp_var.h 22 Aug 2022 20:57:40 -0000
@@ -719,6 +719,7 @@ int tcp_listen(struct socket *);
int tcp_connect(struct socket *, struct mbuf *);
int tcp_accept(struct socket *, struct mbuf *);
int tcp_disconnect(struct socket *);
+int tcp_shutdown(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);
Index: sys/netinet/udp_usrreq.c
===================================================================
RCS file: /cvs/src/sys/netinet/udp_usrreq.c,v
retrieving revision 1.288
diff -u -p -r1.288 udp_usrreq.c
--- sys/netinet/udp_usrreq.c 22 Aug 2022 13:23:07 -0000 1.288
+++ sys/netinet/udp_usrreq.c 22 Aug 2022 20:57:40 -0000
@@ -129,6 +129,7 @@ const struct pr_usrreqs udp_usrreqs = {
.pru_bind = udp_bind,
.pru_connect = udp_connect,
.pru_disconnect = udp_disconnect,
+ .pru_shutdown = udp_shutdown,
};
const struct sysctl_bounded_args udpctl_vars[] = {
@@ -1085,10 +1086,6 @@ udp_usrreq(struct socket *so, int req, s
error = EOPNOTSUPP;
break;
- case PRU_SHUTDOWN:
- socantsendmore(so);
- break;
-
case PRU_SEND:
#ifdef PIPEX
if (inp->inp_pipex) {
@@ -1288,7 +1285,15 @@ udp_disconnect(struct socket *so)
return (0);
}
-
+
+int
+udp_shutdown(struct socket *so)
+{
+ soassertlocked(so);
+ socantsendmore(so);
+ return (0);
+}
+
/*
* Sysctl for udp variables.
*/
Index: sys/netinet/udp_var.h
===================================================================
RCS file: /cvs/src/sys/netinet/udp_var.h,v
retrieving revision 1.41
diff -u -p -r1.41 udp_var.h
--- sys/netinet/udp_var.h 22 Aug 2022 13:23:07 -0000 1.41
+++ sys/netinet/udp_var.h 22 Aug 2022 20:57:40 -0000
@@ -146,5 +146,6 @@ 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 *);
+int udp_shutdown(struct socket *);
#endif /* _KERNEL */
#endif /* _NETINET_UDP_VAR_H_ */
Index: sys/netinet6/ip6_divert.c
===================================================================
RCS file: /cvs/src/sys/netinet6/ip6_divert.c,v
retrieving revision 1.74
diff -u -p -r1.74 ip6_divert.c
--- sys/netinet6/ip6_divert.c 22 Aug 2022 13:23:07 -0000 1.74
+++ sys/netinet6/ip6_divert.c 22 Aug 2022 20:57:40 -0000
@@ -68,6 +68,7 @@ const struct pr_usrreqs divert6_usrreqs
.pru_attach = divert6_attach,
.pru_detach = divert6_detach,
.pru_bind = divert6_bind,
+ .pru_shutdown = divert6_shutdown,
};
int divb6hashsize = DIVERTHASHSIZE;
@@ -274,10 +275,6 @@ divert6_usrreq(struct socket *so, int re
}
switch (req) {
- case PRU_SHUTDOWN:
- socantsendmore(so);
- break;
-
case PRU_SEND:
return (divert6_output(inp, m, addr, control));
@@ -364,6 +361,15 @@ divert6_bind(struct socket *so, struct m
soassertlocked(so);
return in_pcbbind(inp, addr, p);
+}
+
+int
+divert6_shutdown(struct socket *so)
+{
+ soassertlocked(so);
+ socantsendmore(so);
+
+ return (0);
}
int
Index: sys/netinet6/ip6_divert.h
===================================================================
RCS file: /cvs/src/sys/netinet6/ip6_divert.h,v
retrieving revision 1.15
diff -u -p -r1.15 ip6_divert.h
--- sys/netinet6/ip6_divert.h 20 Aug 2022 23:48:58 -0000 1.15
+++ sys/netinet6/ip6_divert.h 22 Aug 2022 20:57:40 -0000
@@ -75,6 +75,7 @@ int divert6_usrreq(struct socket *,
int divert6_attach(struct socket *, int);
int divert6_detach(struct socket *);
int divert6_bind(struct socket *, struct mbuf *, struct proc *);
+int divert6_shutdown(struct socket *);
#endif /* _KERNEL */
#endif /* _IP6_DIVERT_H_ */
Index: sys/netinet6/ip6_var.h
===================================================================
RCS file: /cvs/src/sys/netinet6/ip6_var.h,v
retrieving revision 1.98
diff -u -p -r1.98 ip6_var.h
--- sys/netinet6/ip6_var.h 22 Aug 2022 13:23:07 -0000 1.98
+++ sys/netinet6/ip6_var.h 22 Aug 2022 20:57:40 -0000
@@ -358,6 +358,7 @@ 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_shutdown(struct socket *);
int rip6_sysctl(int *, u_int, void *, size_t *, void *, size_t);
int dest6_input(struct mbuf **, int *, int, int);
Index: sys/netinet6/raw_ip6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/raw_ip6.c,v
retrieving revision 1.156
diff -u -p -r1.156 raw_ip6.c
--- sys/netinet6/raw_ip6.c 22 Aug 2022 13:23:07 -0000 1.156
+++ sys/netinet6/raw_ip6.c 22 Aug 2022 20:57:40 -0000
@@ -112,6 +112,7 @@ const struct pr_usrreqs rip6_usrreqs = {
.pru_bind = rip6_bind,
.pru_connect = rip6_connect,
.pru_disconnect = rip6_disconnect,
+ .pru_shutdown = rip6_shutdown,
};
/*
@@ -609,12 +610,6 @@ rip6_usrreq(struct socket *so, int req,
break;
/*
- * Mark the connection as being incapable of further input.
- */
- case PRU_SHUTDOWN:
- socantsendmore(so);
- break;
- /*
* Ship a packet out. The appropriate raw output
* routine handles any messaging necessary.
*/
@@ -798,6 +793,17 @@ rip6_disconnect(struct socket *so)
in6p->inp_faddr6 = in6addr_any;
so->so_state &= ~SS_ISCONNECTED; /* XXX */
+ return (0);
+}
+
+int
+rip6_shutdown(struct socket *so)
+{
+ /*
+ * Mark the connection as being incapable of further input.
+ */
+ soassertlocked(so);
+ socantsendmore(so);
return (0);
}
Index: sys/sys/protosw.h
===================================================================
RCS file: /cvs/src/sys/sys/protosw.h,v
retrieving revision 1.42
diff -u -p -r1.42 protosw.h
--- sys/sys/protosw.h 22 Aug 2022 13:23:07 -0000 1.42
+++ sys/sys/protosw.h 22 Aug 2022 20:57:40 -0000
@@ -71,6 +71,7 @@ struct pr_usrreqs {
int (*pru_connect)(struct socket *, struct mbuf *);
int (*pru_accept)(struct socket *, struct mbuf *);
int (*pru_disconnect)(struct socket *);
+ int (*pru_shutdown)(struct socket *);
};
struct protosw {
@@ -309,8 +310,7 @@ pru_disconnect(struct socket *so)
static inline int
pru_shutdown(struct socket *so)
{
- return (*so->so_proto->pr_usrreqs->pru_usrreq)(so,
- PRU_SHUTDOWN, NULL, NULL, NULL, curproc);
+ return (*so->so_proto->pr_usrreqs->pru_shutdown)(so);
}
static inline int
Index: sys/sys/unpcb.h
===================================================================
RCS file: /cvs/src/sys/sys/unpcb.h,v
retrieving revision 1.32
diff -u -p -r1.32 unpcb.h
--- sys/sys/unpcb.h 22 Aug 2022 13:23:07 -0000 1.32
+++ sys/sys/unpcb.h 22 Aug 2022 20:57:40 -0000
@@ -118,6 +118,7 @@ int uipc_listen(struct socket *);
int uipc_connect(struct socket *, struct mbuf *);
int uipc_accept(struct socket *, struct mbuf *);
int uipc_disconnect(struct socket *);
+int uipc_shutdown(struct socket *);
void unp_init(void);
int unp_bind(struct unpcb *, struct mbuf *, struct proc *);