From nobody Fri Sep 30 20:45:04 2022 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 4MfMg46N3Mz4YNFD; Fri, 30 Sep 2022 20:45:04 +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 4MfMg45m5hz3Xwy; Fri, 30 Sep 2022 20:45:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664570704; 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=LPTsQK4dGvk0E4ywdzykiQm64rwW3bx3qR6+x8xejIQ=; b=IXc48OL6wKvwtKrhpozLMUC5dCJfPPeJX9ZUe0Rl2/3UC47OhctEFsHhG1+qJ32ox5YEsz QwNgfU6zE7Kn7Xge8eR9mrtbk/hkOeEH3mQo1A7wZMxFqhSavYfsSkZnlzHH2i/qLqi+VL yGNjTZb6SoO54kJT3YMR2LORML/dLSaPSEuvtjnXKtgb1lrGLC2ZAZNw2TfzuXuLikrP6+ jZ9G6L7yZ/FdFgGG+FxqB9EwF1Crc6383cRwufQKr+7v9YVAN0zFRdixvd0N6uVncvNTVO 67MJNTlrTvXfilh2ViEj0kx1EkgC1IPIN939rgapZ7Z92reLM98SnMrWU8uBdg== 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 4MfMg44rGlzHtr; Fri, 30 Sep 2022 20:45:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 28UKj40x093518; Fri, 30 Sep 2022 20:45:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28UKj4dw093517; Fri, 30 Sep 2022 20:45:04 GMT (envelope-from git) Date: Fri, 30 Sep 2022 20:45:04 GMT Message-Id: <202209302045.28UKj4dw093517@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: 0421ff5ab186 - main - tests/unix_passfd: factor out sysctl(3) read into separate function 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: 0421ff5ab18691dacb99f1ba8c4b8463bfd08c79 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1664570704; 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=LPTsQK4dGvk0E4ywdzykiQm64rwW3bx3qR6+x8xejIQ=; b=RGxJJ//K1+bw+TF2KnfAnsRhvA6FqKA80qIH96SGernE6yq3Ctzo7RLw7YZkPNl6114VNJ wsVr3988Sozy9GH7osbeABOecdm6fYdgYeljRir5S9SuAa9ZOE6htE8Hydq05Oh8Td4/Km 0eZiH7/935jA2b80U7Nb+wG2/YERO/6R/8LULayj9dTuK0boZ46F9hgBpon8BhgKRgcVt7 WPPK12whdVsFv+KHVBlibcjvf13GRD7825CXGmlKQIoFNYrn7AAjBIV0DD0qeiNIDV0nh+ SFVPOovuI/Lpz0ZpAAZN0Yw4RXAR+Z/ze7PBaciO8A2Q6HePiugN1XSrAT5BVw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1664570704; a=rsa-sha256; cv=none; b=EeQqw2Hi3nhXbaShpEHuVojj+/hQrAAG8stVCzO1zdfVRKugFyRDiqc2Uc+s5UfAeEVbiW 23BYaYD+o1t0jhQ/48IWg9L6251MEdbiw4NxHVZ+3GnjBwOgZZvfdfIAwH7/7ZoWiM+N/Y gn8yQpquyfhL5z8gATuJs0IWrMo4+rv926WmmIl/qvq5agcEJqCoJbv+0OHGbE/vahbVDm pRAa1dOwo5BPvylBV2YO7ujMQ9bidqqYnNkzF7rxbDAsW8+s8G41SDNkR7/FW1c+h0UISY gc7c6BVd6qzHmwFFwSjYfD/TW5f7yEojFikDCOCqxh5qKv2n/zV8cAbqysAunw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=0421ff5ab18691dacb99f1ba8c4b8463bfd08c79 commit 0421ff5ab18691dacb99f1ba8c4b8463bfd08c79 Author: Gleb Smirnoff AuthorDate: 2022-09-30 20:29:23 +0000 Commit: Gleb Smirnoff CommitDate: 2022-09-30 20:43:08 +0000 tests/unix_passfd: factor out sysctl(3) read into separate function --- tests/sys/kern/unix_passfd_test.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/tests/sys/kern/unix_passfd_test.c b/tests/sys/kern/unix_passfd_test.c index 49f4540bb9d0..875201c4702e 100644 --- a/tests/sys/kern/unix_passfd_test.c +++ b/tests/sys/kern/unix_passfd_test.c @@ -268,6 +268,24 @@ recvfd(int sockfd, int *recv_fd, int flags) CMSG_SPACE(sizeof(int)), flags); } +#if TEST_PROTO == SOCK_STREAM +#define LOCAL_SENDSPACE_SYSCTL "net.local.stream.sendspace" +#elif TEST_PROTO == SOCK_DGRAM +#define LOCAL_SENDSPACE_SYSCTL "net.local.dgram.maxdgram" +#endif + +static u_long +getsendspace(void) +{ + u_long sendspace; + + ATF_REQUIRE_MSG(sysctlbyname(LOCAL_SENDSPACE_SYSCTL, &sendspace, + &(size_t){sizeof(u_long)}, NULL, 0) != -1, + "sysctl %s failed: %s", LOCAL_SENDSPACE_SYSCTL, strerror(errno)); + + return (sendspace); +} + /* * Put a temporary file into a UNIX domain socket, then take it out and make * sure it's the same file. First time around, don't close the reference @@ -530,12 +548,6 @@ ATF_TC_BODY(devfs_orphan, tc) closesocketpair(fd); } -#if TEST_PROTO == SOCK_STREAM -#define LOCAL_SENDSPACE_SYSCTL "net.local.stream.sendspace" -#elif TEST_PROTO == SOCK_DGRAM -#define LOCAL_SENDSPACE_SYSCTL "net.local.dgram.maxdgram" -#endif - /* * Test for PR 181741. Receiver sets LOCAL_CREDS, and kernel prepends a * control message to the data. Sender sends large payload using a non-blocking @@ -551,12 +563,7 @@ ATF_TC_BODY(rights_creds_payload, tc) void *buf; int fd[2], getfd, putfd, rc; - len = sizeof(sendspace); - rc = sysctlbyname(LOCAL_SENDSPACE_SYSCTL, &sendspace, - &len, NULL, 0); - ATF_REQUIRE_MSG(rc != -1, - "sysctl %s failed: %s", LOCAL_SENDSPACE_SYSCTL, strerror(errno)); - + sendspace = getsendspace(); buf = calloc(1, sendspace); ATF_REQUIRE(buf != NULL);