summaryrefslogtreecommitdiff
path: root/sys/netinet/ip_divert.c
diff options
context:
space:
mode:
authorVitaliy Makkoveev <mvs@cvs.openbsd.org>2022-08-28 18:44:18 +0000
committerVitaliy Makkoveev <mvs@cvs.openbsd.org>2022-08-28 18:44:18 +0000
commit7cf93c0df658ac4ed0ffb76abe6741d99501477a (patch)
tree319723c6d59cbc6a272ce7fcf38655ff7048128e /sys/netinet/ip_divert.c
parent5edcdacdf523ba0d449de8e32b954c4a9aee8437 (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/netinet/ip_divert.c')
-rw-r--r--sys/netinet/ip_divert.c21
1 files changed, 15 insertions, 6 deletions
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];