The branch main has been updated by glebius:

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

commit a170657108623cd48e3d695ca74c428a564912ee
Author:     Gleb Smirnoff <gleb...@freebsd.org>
AuthorDate: 2023-02-23 04:44:46 +0000
Commit:     Gleb Smirnoff <gleb...@freebsd.org>
CommitDate: 2023-02-23 04:44:46 +0000

    unix/dgram tests: match the kernel behavior
    
    In CURRENT for some time an overflowed unix/dgram socket would
    return EAGAIN if it has O_NONBLOCK set.  This proved to be
    undesired.  See 71e70c25c00 for details.  Update tests to match
    the "new" behavior, which actually is the historical behavior.
---
 tests/sys/kern/unix_dgram.c       | 7 +++++--
 tests/sys/kern/unix_passfd_test.c | 5 +++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/tests/sys/kern/unix_dgram.c b/tests/sys/kern/unix_dgram.c
index 891cc4a58f5c..9e9d4881a61e 100644
--- a/tests/sys/kern/unix_dgram.c
+++ b/tests/sys/kern/unix_dgram.c
@@ -156,10 +156,13 @@ ATF_TC_BODY(basic, tc)
        ATF_REQUIRE(send(fd[0], buf, maxdgram, 0) == -1);
        ATF_REQUIRE(errno == ENOBUFS);
 
-       /* Fail with EAGAIN with O_NONBLOCK set. */
+       /*
+        * Fail with ENOBUFS with O_NONBLOCK set, too. See 71e70c25c00
+        * for explanation why this behavior needs to be preserved.
+        */
        ATF_REQUIRE(fcntl(fd[0], F_SETFL, O_NONBLOCK) != -1);
        ATF_REQUIRE(send(fd[0], buf, maxdgram, 0) == -1);
-       ATF_REQUIRE(errno == EAGAIN);
+       ATF_REQUIRE(errno == ENOBUFS);
 
        /* Remote side closed -> ECONNRESET. */
        close(fd[1]);
diff --git a/tests/sys/kern/unix_passfd_test.c 
b/tests/sys/kern/unix_passfd_test.c
index 92b8d73f2f4a..16a9a304bf3a 100644
--- a/tests/sys/kern/unix_passfd_test.c
+++ b/tests/sys/kern/unix_passfd_test.c
@@ -532,8 +532,13 @@ ATF_TC_BODY(send_overflow, tc)
        nfiles = openfiles();
        tempfile(&putfd);
        len = sendfd_payload(fd[0], putfd, buf, sendspace);
+#if TEST_PROTO == SOCK_STREAM
        ATF_REQUIRE_MSG(len == -1 && errno == EAGAIN,
            "sendmsg: %zu bytes sent, errno %d", len, errno);
+#elif TEST_PROTO == SOCK_DGRAM
+       ATF_REQUIRE_MSG(len == -1 && errno == ENOBUFS,
+           "sendmsg: %zu bytes sent, errno %d", len, errno);
+#endif
        close(putfd);
        ATF_REQUIRE(nfiles == openfiles());
        closesocketpair(fd);

Reply via email to