Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Feb 2024 17:01:06 GMT
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 3ad0f9a58410 - main - tests/unix_passfd: add a comment for send_a_lot
Message-ID:  <202402081701.418H16XL065786@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=3ad0f9a584106b85569c6366ef8117a664fd55f8

commit 3ad0f9a584106b85569c6366ef8117a664fd55f8
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2024-02-08 17:00:23 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2024-02-08 17:00:41 +0000

    tests/unix_passfd: add a comment for send_a_lot
    
    Explain why SOCK_DGRAM and SOCK_STREAM differ in this edge case.  While
    here improve output in case of a failure.
---
 tests/sys/kern/unix_passfd_test.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/tests/sys/kern/unix_passfd_test.c b/tests/sys/kern/unix_passfd_test.c
index 143ccd098583..74095859d899 100644
--- a/tests/sys/kern/unix_passfd_test.c
+++ b/tests/sys/kern/unix_passfd_test.c
@@ -657,11 +657,20 @@ ATF_TC_BODY(rights_creds_payload, tc)
 	ATF_REQUIRE_MSG(len != -1 , "sendmsg failed: %s", strerror(errno));
 #if TEST_PROTO == SOCK_STREAM
 	ATF_REQUIRE_MSG((size_t)len < sendspace,
-	    "sendmsg: %zd bytes sent", len);
+	    "sendmsg: %zd bytes sent, expected < %lu", len, sendspace);
 #endif
 #if TEST_PROTO == SOCK_DGRAM
+	/*
+	 * sendmsg(2) can't truncate datagrams, only recvmsg(2) can.  There are
+	 * two options for the kernel here: either accept the datagram with
+	 * slight overcommit of the socket buffer space or return ENOBUFS for a
+	 * datagram that is smaller or equal to the socket buffer space.  Our
+	 * implementation does overcommit.  Explanation is simple: from our
+	 * side we see space available, we have no idea that remote side has
+	 * LOCAL_CREDS set.  From our side we expect sendmsg(2) to succeed.
+	 */
 	ATF_REQUIRE_MSG((size_t)len == sendspace,
-	    "sendmsg: %zd bytes sent", len);
+	    "sendmsg: %zd bytes sent, expected %lu", len, sendspace);
 #endif
 	rlen = recvfd_payload(fd[1], &getfd, buf, len,
 	    CMSG_SPACE(SOCKCREDSIZE(CMGROUP_MAX)) + CMSG_SPACE(sizeof(int)), 0);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202402081701.418H16XL065786>