git: 504ebd612ec6 - main - kern: sonewconn: set so_options before pru_attach()
Kyle Evans
kevans at FreeBSD.org
Tue Feb 9 03:47:07 UTC 2021
The branch main has been updated by kevans:
URL: https://cgit.FreeBSD.org/src/commit/?id=504ebd612ec61165bb949cfce3a348b0d6f37008
commit 504ebd612ec61165bb949cfce3a348b0d6f37008
Author: Kyle Evans <kevans at FreeBSD.org>
AuthorDate: 2021-01-20 17:53:05 +0000
Commit: Kyle Evans <kevans at FreeBSD.org>
CommitDate: 2021-02-09 03:44:43 +0000
kern: sonewconn: set so_options before pru_attach()
Protocol attachment has historically been able to observe and modify
so->so_options as needed, and it still can for newly created sockets.
779f106aa169 moved this to after pru_attach() when we re-acquire the
lock on the listening socket.
Restore the historical behavior so that pru_attach implementations can
consistently use it. Note that some pru_attach() do currently rely on
this, though that may change in the future. D28265 contains a change to
remove the use in TCP and IB/SDP bits, as resetting the requested linger
time on incoming connections seems questionable at best.
This does move the assignment out from under the head's listen lock, but
glebius notes that head won't be going away and applications cannot
assume any specific ordering with a race between a connection coming in
and the application changing socket options anyways.
Discussed-with: glebius
MFC-after: 1 week
---
sys/kern/uipc_socket.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 7b16401b7071..7f06b51cf096 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -718,6 +718,7 @@ sonewconn(struct socket *head, int connstatus)
}
so->so_listen = head;
so->so_type = head->so_type;
+ so->so_options = head->so_options & ~SO_ACCEPTCONN;
so->so_linger = head->so_linger;
so->so_state = head->so_state | SS_NOFDREF;
so->so_fibnum = head->so_fibnum;
@@ -754,7 +755,6 @@ sonewconn(struct socket *head, int connstatus)
if (head->sol_accept_filter != NULL)
connstatus = 0;
so->so_state |= connstatus;
- so->so_options = head->so_options & ~SO_ACCEPTCONN;
soref(head); /* A socket on (in)complete queue refs head. */
if (connstatus) {
TAILQ_INSERT_TAIL(&head->sol_comp, so, so_list);
More information about the dev-commits-src-all
mailing list