From owner-svn-src-head@freebsd.org Wed Nov 25 01:31:02 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 20903470725; Wed, 25 Nov 2020 01:31:02 +0000 (UTC) (envelope-from jhb@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CgjyZ0NlBz3qPS; Wed, 25 Nov 2020 01:31:02 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 003BBE21; Wed, 25 Nov 2020 01:31:02 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0AP1V1CG008654; Wed, 25 Nov 2020 01:31:01 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0AP1V1u4008649; Wed, 25 Nov 2020 01:31:01 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <202011250131.0AP1V1u4008649@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Wed, 25 Nov 2020 01:31:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r368008 - in head: tests/sys/opencrypto tools/tools/crypto X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: in head: tests/sys/opencrypto tools/tools/crypto X-SVN-Commit-Revision: 368008 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Nov 2020 01:31:02 -0000 Author: jhb Date: Wed Nov 25 01:31:00 2020 New Revision: 368008 URL: https://svnweb.freebsd.org/changeset/base/368008 Log: Remove uses of CRIOGET in OCF tests after r368005. Pointy hat to: jhb Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D27367 Modified: head/tests/sys/opencrypto/blake2_test.c head/tests/sys/opencrypto/cryptodev.py head/tests/sys/opencrypto/poly1305_test.c head/tools/tools/crypto/cryptokeytest.c head/tools/tools/crypto/cryptotest.c Modified: head/tests/sys/opencrypto/blake2_test.c ============================================================================== --- head/tests/sys/opencrypto/blake2_test.c Wed Nov 25 01:09:58 2020 (r368007) +++ head/tests/sys/opencrypto/blake2_test.c Wed Nov 25 01:31:00 2020 (r368008) @@ -88,17 +88,10 @@ lookup_crid(int fd, const char *devname) static int get_handle_fd(void) { - int dc_fd, fd; + int fd; - dc_fd = open("/dev/crypto", O_RDWR); - - /* - * Why do we do this dance instead of just operating on /dev/crypto - * directly? I have no idea. - */ - ATF_REQUIRE(dc_fd >= 0); - ATF_REQUIRE(ioctl(dc_fd, CRIOGET, &fd) != -1); - close(dc_fd); + fd = open("/dev/crypto", O_RDWR); + ATF_REQUIRE(fd >= 0); return (fd); } Modified: head/tests/sys/opencrypto/cryptodev.py ============================================================================== --- head/tests/sys/opencrypto/cryptodev.py Wed Nov 25 01:09:58 2020 (r368007) +++ head/tests/sys/opencrypto/cryptodev.py Wed Nov 25 01:31:00 2020 (r368008) @@ -115,7 +115,6 @@ class CryptAEAD(dpkt.Packet): ) # h2py.py can't handle multiarg macros -CRIOGET = 3221513060 CIOCGSESSION = 3224396645 CIOCFSESSION = 2147771238 CIOCKEY = 3230688104 @@ -131,17 +130,7 @@ else: CIOCCRYPT = 3223085927 CIOCCRYPTAEAD = 3223872365 -def _getdev(): - buf = array.array('I', [0]) - fd = os.open('/dev/crypto', os.O_RDWR) - try: - ioctl(fd, CRIOGET, buf, 1) - finally: - os.close(fd) - - return buf[0] - -_cryptodev = _getdev() +_cryptodev = os.open('/dev/crypto', os.O_RDWR) def str_to_ascii(val): if sys.version_info[0] >= 3: Modified: head/tests/sys/opencrypto/poly1305_test.c ============================================================================== --- head/tests/sys/opencrypto/poly1305_test.c Wed Nov 25 01:09:58 2020 (r368007) +++ head/tests/sys/opencrypto/poly1305_test.c Wed Nov 25 01:31:00 2020 (r368008) @@ -302,17 +302,10 @@ parse_vector(const struct poly1305_kat *kat, static int get_handle_fd(void) { - int dc_fd, fd; + int fd; - dc_fd = open("/dev/crypto", O_RDWR); - - /* - * Why do we do this dance instead of just operating on /dev/crypto - * directly? I have no idea. - */ - ATF_REQUIRE(dc_fd >= 0); - ATF_REQUIRE(ioctl(dc_fd, CRIOGET, &fd) != -1); - close(dc_fd); + fd = open("/dev/crypto", O_RDWR); + ATF_REQUIRE(fd >= 0); return (fd); } Modified: head/tools/tools/crypto/cryptokeytest.c ============================================================================== --- head/tools/tools/crypto/cryptokeytest.c Wed Nov 25 01:09:58 2020 (r368007) +++ head/tools/tools/crypto/cryptokeytest.c Wed Nov 25 01:31:00 2020 (r368008) @@ -113,10 +113,7 @@ UB_mod_exp(BIGNUM *res, const BIGNUM *a, const BIGNUM { struct crypt_kop kop; void *ale, *ble, *cle; - static int crypto_fd = -1; - - if (crypto_fd == -1 && ioctl(devcrypto(), CRIOGET, &crypto_fd) == -1) - err(1, "CRIOGET"); + int crypto_fd = devcrypto(); if ((ale = bignum_to_le(a)) == NULL) err(1, "bignum_to_le, a"); Modified: head/tools/tools/crypto/cryptotest.c ============================================================================== --- head/tools/tools/crypto/cryptotest.c Wed Nov 25 01:09:58 2020 (r368007) +++ head/tools/tools/crypto/cryptotest.c Wed Nov 25 01:31:00 2020 (r368008) @@ -229,23 +229,11 @@ crfind(int crid) bzero(&find, sizeof(find)); find.crid = crid; - if (ioctl(devcrypto(), CRIOFINDDEV, &find) == -1) + if (ioctl(devcrypto(), CIOCFINDDEV, &find) == -1) err(1, "ioctl(CIOCFINDDEV): crid %d", crid); return find.name; } -int -crget(void) -{ - int fd; - - if (ioctl(devcrypto(), CRIOGET, &fd) == -1) - err(1, "ioctl(CRIOGET)"); - if (fcntl(fd, F_SETFD, 1) == -1) - err(1, "fcntl(F_SETFD) (crget)"); - return fd; -} - char rdigit(void) { @@ -259,7 +247,7 @@ rdigit(void) void runtest(struct alg *ealg, struct alg *alg, int count, int size, u_long cmd, struct timeval *tv) { - int i, fd = crget(); + int i, fd = devcrypto(); struct timeval start, stop, dt; char *cleartext, *ciphertext, *originaltext, *key; struct session2_op sop;