diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2022-08-08 12:06:32 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2022-08-08 12:06:32 +0000 |
commit | 2c56b01a18fc4cacc0b9509a2657a57be470d69b (patch) | |
tree | ad5503da9e75dfee7b34906402bcfbcfa3249fad /sys/netinet/tcp_usrreq.c | |
parent | 8d515cf4247f32f44f2291ad4eb92432f69ee447 (diff) |
To make protocol input functions MP safe, internet PCB need protection.
Use their reference counter in more places.
The in_pcb lookup functions hold the PCBs in hash tables protected
by table->inpt_mtx mutex. Whenever a result is returned, increment
the ref count before releasing the mutex. Then the inp can be used
as long as neccessary. Unref it at the end of all functions that
call in_pcb lookup.
As a shortcut, pf may also hold a reference to the PCB. When
pf_inp_lookup() returns it, it also incements the ref count and the
caller can handle it like the inp from table lookup.
OK sashan@
Diffstat (limited to 'sys/netinet/tcp_usrreq.c')
-rw-r--r-- | sys/netinet/tcp_usrreq.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 67035bd4553..6185187ca0b 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_usrreq.c,v 1.183 2022/02/25 23:51:03 guenther Exp $ */ +/* $OpenBSD: tcp_usrreq.c,v 1.184 2022/08/08 12:06:30 bluhm Exp $ */ /* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */ /* @@ -822,6 +822,7 @@ tcp_ident(void *oldp, size_t *oldlenp, void *newp, size_t newlen, int dodrop) tp = tcp_drop(tp, ECONNABORTED); else error = ESRCH; + in_pcbunref(inp); return (error); } @@ -851,6 +852,7 @@ tcp_ident(void *oldp, size_t *oldlenp, void *newp, size_t newlen, int dodrop) *oldlenp = sizeof (tir); error = copyout((void *)&tir, oldp, sizeof (tir)); + in_pcbunref(inp); return (error); } |