diff options
author | Gleb Smirnoff <glebius@FreeBSD.org> | 2022-07-04 19:40:51 +0000 |
---|---|---|
committer | Gleb Smirnoff <glebius@FreeBSD.org> | 2022-07-04 19:40:51 +0000 |
commit | d8596171c5d68c8dda1853e1243ad08944812400 (patch) | |
tree | c4096e184780b6309319c19327fcb99da98adb97 /sys/sys | |
parent | bc7605647c7193af7eba4b4af65dc7b66a118a09 (diff) | |
download | src-d8596171c5d68c8dda1853e1243ad08944812400.tar.gz src-d8596171c5d68c8dda1853e1243ad08944812400.zip |
sockets: use only soref()/sorele() as socket reference count
o Retire SS_FDREF as it is basically a debug flag on top of already
existing soref()/sorele().
o Convert SS_PROTOREF into soref()/sorele().
o Change reference model for the listen queues, see below.
o Make sofree() private. The correct KPI to use is only sorele().
o Make soabort() respect the model and sorele() instead of sofree().
Note on listening queues. Until now the sockets on a queue had zero
reference count. And the reference were given only upon accept(2). The
assumption was that there is no way to see the queued socket from anywhere
except its head. This is not true, since queued sockets already have pcbs,
which are linked at least into the global pcb lists. With this change we
put the reference right in the sonewconn() and on accept(2) path we just
hand the existing reference to the file descriptor.
Differential revision: https://reviews.freebsd.org/D35679
Diffstat (limited to 'sys/sys')
-rw-r--r-- | sys/sys/socketvar.h | 11 |
1 files changed, 0 insertions, 11 deletions
diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h index d1ce687ac956..c496239f92bc 100644 --- a/sys/sys/socketvar.h +++ b/sys/sys/socketvar.h @@ -210,7 +210,6 @@ struct socket { * Many fields will be read without locks to improve performance and avoid * lock order issues. However, this approach must be used with caution. */ -#define SS_FDREF 0x0001 /* strong file descriptor reference */ #define SS_ISCONNECTED 0x0002 /* socket connected to a peer */ #define SS_ISCONNECTING 0x0004 /* in process of connecting to peer */ #define SS_ISDISCONNECTING 0x0008 /* in process of disconnecting */ @@ -219,15 +218,6 @@ struct socket { #define SS_ISCONFIRMING 0x0400 /* deciding to accept connection req */ #define SS_ISDISCONNECTED 0x2000 /* socket disconnected from peer */ -/* - * Protocols can mark a socket as SS_PROTOREF to indicate that, following - * pru_detach, they still want the socket to persist, and will free it - * themselves when they are done. Protocols should only ever call sofree() - * following setting this flag in pru_detach(), and never otherwise, as - * sofree() bypasses socket reference counting. - */ -#define SS_PROTOREF 0x4000 /* strong protocol reference */ - #ifdef _KERNEL #define SOCK_MTX(so) (&(so)->so_lock) @@ -479,7 +469,6 @@ int socreate(int dom, struct socket **aso, int type, int proto, int sodisconnect(struct socket *so); void sodtor_set(struct socket *, so_dtor_t *); struct sockaddr *sodupsockaddr(const struct sockaddr *sa, int mflags); -void sofree(struct socket *so); void sohasoutofband(struct socket *so); int solisten(struct socket *so, int backlog, struct thread *td); void solisten_proto(struct socket *so, int backlog); |