sockets: inherit SO_ACCEPTFILTER from listener to child

This is crucial for operation of accept_filter(9).  See added comment.

Fixes:	d29b95ecc0
This commit is contained in:
Gleb Smirnoff 2024-04-23 17:17:14 -07:00
parent 91bdebc958
commit a8acc2bf56

View file

@ -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;