From nobody Thu Nov 19 21:55:06 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jVshW5Q5Wz71MhT for ; Thu, 19 Nov 2026 21:55:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jVshW1HYTz3LFC for ; Thu, 19 Nov 2026 21:55:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795125307; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=y+k2TPyhEd3jbllFoKP0bxhGR2N8b7ZgGxLCMM824Pg=; b=wS3T64AHjoclj19a+ry5fAkBxvheTYdDNVBnzYavLri10e3oQ2biqQWnMU8AE/u9NdE5UB DdilzsWJaxXvUIMgr7L6a57OOQdaLt/TC7i62n22UNr64aSHBkwt4hpkVLhG6w+gaokma/ xkZJ/ak7T8d3KC1Q7M/b8DTNGZjcj94E3OXIjfJBvfr7qAi0JQxahQ4oxdf4tVJ8a8VJP8 gTGiNnsZH4Ym2qlguB8FRtetLbDkTHQkOVcs47S74tHFxt08XtmuPkJFaBEbXFAQV/haFn /XHjRDst+g0/HqYXk/rpZGtrp83c3KsiA5dsBV4W0xkq+mVlFzMf9jV4fh7aZQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795125307; b=bnqaFAYuNkccdIEt/8/O9/2R8A+BeNUQA5gzK7wYG2SnQZ+XBjiTqntPhmfYAkXXk+bc6q sGS1ZSzahF0x5deBRR8c03BAMw6oEtfPyu0+9kqva/K1Ox1aVeo7/03ybd1rvnkK/eyn4c p8D6vCNxR63WXGK00odMr6MhpLAIiLGaZ5LwcgBsFAPlbEKoNLvfR6mI5iMI/fTjI93/8O B7LJ/pBTtU4wWDbwYl3xXovh1uETYbab02cAWgtIIpKzW4wHdkGTQN2L3DnU4iIorICAmY lobAJKzeuIwKubAOCYg8MpuWedz0vNXRlVuaWj7hx4jabW6C/Ozxzy0LNbZ01w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795125307; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=y+k2TPyhEd3jbllFoKP0bxhGR2N8b7ZgGxLCMM824Pg=; b=yHzJaEO9SM70BO/LUi26x6IG8xktCpc3lztRGwGzd3pcrxniCoaTEqrL/Nuq5AxzE8Vha7 VJ9niClcpCCcVOGTSb+BIT1tWgOKAnZQJ7gjcNXulF4oFsN9PWv5iSpg1HNo0ZQX5AUlTq DVJuZyLeLo17w7wTKMlG27rL8oCIyGsrSZoe8QR4FckC7xIV15QMVJQ19jZnbBzfiVq8Fj jOZ292QFHiXSt0fDluRw8QQtnfDdttN54LN+KIboBPoKzF979KMfeiC47aeAAWe0uV5uie VoJKUKd1zEXY+mDA4FVtgxyiY/5XrEBPgSAAmUAKXgX5hcE13Aa5OKHued38qg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jVshW05fhzJsq for ; Thu, 19 Nov 2026 21:55:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 13b29 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 19 Nov 2026 21:55:06 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Nick Banks From: Gleb Smirnoff Subject: git: ba045424b33d - main - tests/ssl_sendfile: size socket buffers before connecting List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ba045424b33d2a48f127adc8126d79d9eb82954a Auto-Submitted: auto-generated Date: Thu, 19 Nov 2026 21:55:06 +0000 Message-Id: <6aff703a.13b29.7e345e11@gitrepo.freebsd.org> The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=ba045424b33d2a48f127adc8126d79d9eb82954a commit ba045424b33d2a48f127adc8126d79d9eb82954a Author: Nick Banks AuthorDate: 2026-11-19 21:45:21 +0000 Commit: Gleb Smirnoff CommitDate: 2026-11-19 21:54:19 +0000 tests/ssl_sendfile: size socket buffers before connecting The :grow, :truncate and :eagain_vs_eof cases rely on the socket buffers filling up before the whole file has been sent. :grow and :truncate shrank SO_SNDBUF and SO_RCVBUF only after the connection was established, when the receiver had already advertised a window based on the default buffer size; TCP does not shrink an advertised window. :eagain_vs_eof used the default, autosized buffers. With a large net.inet.tcp.recvspace, or once autosizing has grown the buffers, the whole 2 MB file fits in the socket buffers: :grow and :truncate: sendfile(2) returns before the file is resized, and the poll loop that waits for the sender to block spins forever on a writable socket. :eagain_vs_eof: the loop that keeps writing until EAGAIN never sees it, since sendfile(2) returns 0 at EOF. Either way kyua reports a timeout, which is why doubling the timeouts did not help. Apply a 128 KB buffer size to the listening socket, which the accepted socket inherits, and to the client socket before connect(2) in all three cases. Under CPU load in a test VM, :eagain_vs_eof timed out in 3 of 11 runs without this change and passed 40 of 40 runs with it. With 1 MB recvspace and sendspace, :grow hung on its first run in 3 of 4 boots without it and passed 20 of 20 runs with it. Differential Revision: https://reviews.freebsd.org/D61752 Reviewed by: glebius, ngie PR: 299447 Co-Authored-By: Claude Opus 5.5 --- tests/sys/kern/ssl_sendfile.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/tests/sys/kern/ssl_sendfile.c b/tests/sys/kern/ssl_sendfile.c index adb3ee818437..4b36e5243a77 100644 --- a/tests/sys/kern/ssl_sendfile.c +++ b/tests/sys/kern/ssl_sendfile.c @@ -60,6 +60,7 @@ struct ctx { off_t offset; /* SSL_sendfile offset */ size_t size; /* SSL_sendfile size */ bool nb; /* SSL_sendfile mode */ + int sbsize; /* socket buffer size, 0 for default */ ossl_ssize_t sbytes; /* SSL_sendfile returned sbytes */ enum { INIT, @@ -74,7 +75,7 @@ struct ctx { static void *server_thread(void *arg); static void -common_init(struct ctx *c) +common_init(struct ctx *c, int sbsize) { char hostname[sizeof("localhost:65536")]; char tempname[] = "/tmp/ssl_sendfile_test.XXXXXXXXXX"; @@ -93,6 +94,7 @@ common_init(struct ctx *c) atf_tc_skip("kern.ipc.tls.enable is off"); c->state = INIT; + c->sbsize = sbsize; /* * Generate self signed key & certificate. @@ -152,6 +154,9 @@ common_init(struct ctx *c) ssl = c->cln = SSL_new(c->ctx); ATF_REQUIRE(c->cln != NULL); ATF_REQUIRE((c->cs = socket(AF_INET, SOCK_STREAM, 0)) > 0); + if (c->sbsize != 0) + ATF_REQUIRE(setsockopt(c->cs, SOL_SOCKET, SO_RCVBUF, + &c->sbsize, sizeof(int)) == 0); ATF_REQUIRE(connect(c->cs, (struct sockaddr *)&(struct sockaddr_in) { .sin_family = AF_INET, .sin_len = sizeof(struct sockaddr_in), .sin_addr.s_addr = htonl(INADDR_LOOPBACK), .sin_port = c->port }, @@ -207,6 +212,9 @@ server_thread(void *arg) ATF_REQUIRE((s = socket(AF_INET, SOCK_STREAM, 0)) > 0); ATF_REQUIRE(setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &(socklen_t){1}, sizeof(int)) == 0); + if (c->sbsize != 0) + ATF_REQUIRE(setsockopt(s, SOL_SOCKET, SO_SNDBUF, &c->sbsize, + sizeof(int)) == 0); ATF_REQUIRE(bind(s, (struct sockaddr *)&sin, sizeof(sin)) == 0); ATF_REQUIRE(getsockname(s, (struct sockaddr *)&sin, &(socklen_t){ sizeof(sin) }) == 0); @@ -308,7 +316,7 @@ ATF_TC_BODY(basic, tc) size_t nread; int n; - common_init(&c); + common_init(&c, 0); sendme(&c, 0, 0, false); nread = 0; @@ -328,7 +336,7 @@ ATF_TC_BODY(random, tc) struct ctx c; #define RSIZE (256*1024) - common_init(&c); + common_init(&c, 0); for (u_int i = 0; i < 10; i++) { char buf[RSIZE]; @@ -363,12 +371,7 @@ ATF_TC_BODY(truncate, tc) int n; #define TRUNC (FSIZE - 1024) - common_init(&c); - - ATF_REQUIRE(setsockopt(c.ss, SOL_SOCKET, SO_SNDBUF, &(int){FSIZE / 16}, - sizeof(int)) == 0); - ATF_REQUIRE(setsockopt(c.cs, SOL_SOCKET, SO_RCVBUF, &(int){FSIZE / 16}, - sizeof(int)) == 0); + common_init(&c, FSIZE / 16); sendme(&c, 0, 0, false); /* Make sure sender is waiting on the socket buffer. */ @@ -398,12 +401,7 @@ ATF_TC_BODY(grow, tc) int n; #define GROW (FSIZE/2) - common_init(&c); - - ATF_REQUIRE(setsockopt(c.ss, SOL_SOCKET, SO_SNDBUF, &(int){FSIZE / 16}, - sizeof(int)) == 0); - ATF_REQUIRE(setsockopt(c.cs, SOL_SOCKET, SO_RCVBUF, &(int){FSIZE / 16}, - sizeof(int)) == 0); + common_init(&c, FSIZE / 16); sendme(&c, 0, 0, false); /* Make sure sender is waiting on the socket buffer. */ @@ -441,7 +439,7 @@ ATF_TC_BODY(offset_beyond_eof, tc) { struct ctx c; - common_init(&c); + common_init(&c, 0); c.sbytes = -1; sendme(&c, FSIZE + 1, 0, false); @@ -466,7 +464,7 @@ ATF_TC_BODY(eagain_vs_eof, tc) ssize_t nread, offset = 0; int n; - common_init(&c); + common_init(&c, FSIZE / 16); /* * Exercise short write due to no buffer space on non-blocking