From a8acc2bf5699556946dda2a37589d3c3bd9762c6 Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Tue, 23 Apr 2024 17:17:14 -0700 Subject: [PATCH] sockets: inherit SO_ACCEPTFILTER from listener to child This is crucial for operation of accept_filter(9). See added comment. Fixes: d29b95ecc0d049406d27a6c11939d40a46658733 --- sys/kern/uipc_socket.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index c040bdf4d3e..f0b36fc5595 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -761,9 +761,13 @@ solisten_clone(struct socket *head) * including those completely irrelevant to a new born socket. For * compatibility with older versions we will inherit a list of * meaningful options. + * The crucial bit to inherit is SO_ACCEPTFILTER. We need it present + * in the child socket for soisconnected() promoting socket from the + * incomplete queue to complete. It will be cleared before the child + * gets available to accept(2). */ - so->so_options = head->so_options & (SO_KEEPALIVE | SO_DONTROUTE | - SO_LINGER | SO_OOBINLINE | SO_NOSIGPIPE); + so->so_options = head->so_options & (SO_ACCEPTFILTER | SO_KEEPALIVE | + SO_DONTROUTE | SO_LINGER | SO_OOBINLINE | SO_NOSIGPIPE); so->so_linger = head->so_linger; so->so_state = head->so_state; so->so_fibnum = head->so_fibnum;