git: 7ee47c3bb7a6 - main - sockets: in solisten_proto() don't call sbdestroy() on a PR_SOCKBUF

From: Gleb Smirnoff <glebius_at_FreeBSD.org>
Date: Wed, 28 Feb 2024 23:57:37 UTC
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=7ee47c3bb7a6d85744e2747ec969161eed5bbaab

commit 7ee47c3bb7a6d85744e2747ec969161eed5bbaab
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2024-02-28 23:57:04 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2024-02-28 23:57:25 +0000

    sockets: in solisten_proto() don't call sbdestroy() on a PR_SOCKBUF
    
    A socket marked with PR_SOCKBUF has protocol specific socket buffers
    and will take care of the in its pr_listen method.  Right now we don't
    have any sockets that can listen and are PR_SOCKBUF, but that will
    change soon.
---
 sys/kern/uipc_socket.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index b647766cf258..18ecf1409fd7 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1063,8 +1063,10 @@ solisten_proto(struct socket *so, int backlog)
 	sbrcv_timeo = so->so_rcv.sb_timeo;
 	sbsnd_timeo = so->so_snd.sb_timeo;
 
-	sbdestroy(so, SO_SND);
-	sbdestroy(so, SO_RCV);
+	if (!(so->so_proto->pr_flags & PR_SOCKBUF)) {
+		sbdestroy(so, SO_SND);
+		sbdestroy(so, SO_RCV);
+	}
 
 #ifdef INVARIANTS
 	bzero(&so->so_rcv,