From nobody Wed Feb 28 22:33:10 2024 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 4TlTdg2nBCz5CXvt; Wed, 28 Feb 2024 22:33:11 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TlTdf6WqQz4q56; Wed, 28 Feb 2024 22:33:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709159590; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kf3zqvnylMhB5Wqbij4Ei2K1VuQvR3TykvvGq4aFLYQ=; b=w9mvRkvAcpqwmjWriAjJjjrw5bI/uvv3j87IkmCidFnVmyky00cVkB17VC8e+bGYNG03Ha O2DfLszPSqzZRE4xTr6ptY3fOTn4TviVyGj4MSUxjeD32ypJtHJKTXmjjSJr7Yt9q3vFbw EZL+8Zo1/dQTs9ep0joxNxBHAZs0zx/f9I0ZXXuXzuJPtul6MBfccz3+bd12s/qd7MQE3b 2zwf5fvzDrX/y3Wo0p0a31d6WktvD6cIkSS6uPCK+GSY9NZoXDnFsxPL9uD/2i9WvTYXhw DTUDg1MdvFr6jYXo+TSO/vZAF8eD8+rNBUGJIK+TgxM6koGqVtWRmrqFbeqS0g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1709159590; a=rsa-sha256; cv=none; b=EvqQyZCf+IzgkkDbnXkJY4JCmErVKqMIz5c29gXx5DpCqn1vf3vXm9Msr69J/I8rUQCMvr kkoh6ErARz68KRcwa346leob7R9s5V2aYaGSZAxVeUTpEV5rvuSpgneNBzaKHLfaf+vdbf 8mY1o663B0FpzkvPxPdGBk/bu10P6iAQD7D1V8oB0/2zHyq2HUqY/YGe0PD7HHODgvCeWc eJHyQHio+zdbGGJi4fpmb6XWiBzD3TVxEQn6XhJRwndZQU1FBtaOFpAZVmJMU5PM//g7aV xrEUyAkr/AUZnr9cmUdhjBE6uK3t0UxVqg7BLSw7l61tAN/yVEw5ZmFCKYblKw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1709159590; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kf3zqvnylMhB5Wqbij4Ei2K1VuQvR3TykvvGq4aFLYQ=; b=Acc7wtLYhd3NWzRJW+Xslw9biuZDu362JCUcQMHJXPNzX/WvK/pZaNCovXXkiIuvAmpg4X eL+5JH/KraPFmoGM7S/Abhuoq9wXaYpHwftOWaE8f/WLyGxTU9BkgauLgS3qVVGpZa33e8 LGGRjeOTa8xY48+MSa8xWGStpy/LTfaQ0lqweoU0ccIngRWqJwRTKEjiJx89CRe/dNUClz +HVnK2OirrkJ3+d+Bn1prQ2p2uI8+R8XW9H2XHoEnGRfNnB4yLvgQoWY/oE/lKaD3NUJ5d vA/2iIa4uhADmb0CALdqB62FmSxl9k513KZkSFrwhr6C6Vm8nk7t8WeVWhuLsg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TlTdf61ZgzGBn; Wed, 28 Feb 2024 22:33:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41SMXAmx011010; Wed, 28 Feb 2024 22:33:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41SMXAYv011007; Wed, 28 Feb 2024 22:33:10 GMT (envelope-from git) Date: Wed, 28 Feb 2024 22:33:10 GMT Message-Id: <202402282233.41SMXAYv011007@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 3bc122d27064 - main - tests/unix_seqpacket: test that data can be sent before accept(2) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org 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: 3bc122d27064957911570c1037e6b644b7303c17 Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=3bc122d27064957911570c1037e6b644b7303c17 commit 3bc122d27064957911570c1037e6b644b7303c17 Author: Gleb Smirnoff AuthorDate: 2024-02-28 22:32:46 +0000 Commit: Gleb Smirnoff CommitDate: 2024-02-28 22:32:46 +0000 tests/unix_seqpacket: test that data can be sent before accept(2) This is undocumented feature of PF_UNIX/SOCK_STREAM and thus of PF_UNIX/SOCK_SEQPACKET, too. Put the test into this file, since this file is most advanced and has all primitives to write this test in minimum number of lines. Differential Revision: https://reviews.freebsd.org/D43853 --- tests/sys/kern/unix_seqpacket_test.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/sys/kern/unix_seqpacket_test.c b/tests/sys/kern/unix_seqpacket_test.c index 3ea7bb3ea165..cde427401970 100644 --- a/tests/sys/kern/unix_seqpacket_test.c +++ b/tests/sys/kern/unix_seqpacket_test.c @@ -501,6 +501,32 @@ ATF_TC_BODY(connect, tc) close(s2); } +/* + * An undocumented feature that we probably want to preserve: sending to + * a socket that isn't yet accepted lands data on the socket. It can be + * read after accept(2). + */ +ATF_TC_WITHOUT_HEAD(send_before_accept); +ATF_TC_BODY(send_before_accept, tc) +{ + const char buf[] = "hello"; + char repl[sizeof(buf)]; + const struct sockaddr_un *sun; + int l, s, a; + + sun = mk_listening_socket(&l); + + ATF_REQUIRE((s = socket(PF_LOCAL, SOCK_SEQPACKET, 0)) > 0); + ATF_REQUIRE(connect(s, (struct sockaddr *)sun, sizeof(*sun)) == 0); + ATF_REQUIRE(send(s, &buf, sizeof(buf), 0) == sizeof(buf)); + ATF_REQUIRE((a = accept(l, NULL, NULL)) != 1); + ATF_REQUIRE(recv(a, &repl, sizeof(repl), 0) == sizeof(buf)); + ATF_REQUIRE(strcmp(buf, repl) == 0); + close(l); + close(s); + close(a); +} + /* accept(2) can receive a connection */ ATF_TC_WITHOUT_HEAD(accept); ATF_TC_BODY(accept, tc) @@ -1072,6 +1098,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, send_recv_nonblocking); ATF_TP_ADD_TC(tp, send_recv_with_connect); ATF_TP_ADD_TC(tp, sendto_recvfrom); + ATF_TP_ADD_TC(tp, send_before_accept); ATF_TP_ADD_TC(tp, shutdown_send); ATF_TP_ADD_TC(tp, shutdown_send_sigpipe); ATF_TP_ADD_TC(tp, eagain_8k_8k);