summaryrefslogtreecommitdiff
path: root/tools/tools
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2020-11-25 00:10:54 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2020-11-25 00:10:54 +0000
commit688f8b822cea550753e7f3495339141cb6b565b7 (patch)
tree3cd4ee29d26786fc5cae6115ca6dd069672d5456 /tools/tools
parent908dca3ef4695fe0abf4001ea2b3f73e9247a540 (diff)
downloadsrc-test2-688f8b822cea550753e7f3495339141cb6b565b7.tar.gz
src-test2-688f8b822cea550753e7f3495339141cb6b565b7.zip
Remove the cloned file descriptors for /dev/crypto.
Crypto file descriptors were added in the original OCF import as a way to provide per-open data (specifically the list of symmetric sessions). However, this gives a bit of a confusing API where one has to open /dev/crypto and then invoke an ioctl to obtain a second file descriptor. This also does not match the API used with /dev/crypto on other BSDs or with Linux's /dev/crypto driver. Character devices have gained support for per-open data via cdevpriv since OCF was imported, so use cdevpriv to simplify the userland API by permitting ioctls directly on /dev/crypto descriptors. To provide backwards compatibility, CRIOGET now opens another /dev/crypto descriptor via kern_openat() rather than dup'ing the existing file descriptor. This preserves prior semantics in case CRIOGET is invoked multiple times on a single file descriptor. Reviewed by: markj Relnotes: yes Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D27302
Notes
Notes: svn path=/head/; revision=368005
Diffstat (limited to 'tools/tools')
-rw-r--r--tools/tools/crypto/cryptocheck.c19
1 files changed, 2 insertions, 17 deletions
diff --git a/tools/tools/crypto/cryptocheck.c b/tools/tools/crypto/cryptocheck.c
index a61c3d2bae77..efb68f8966ef 100644
--- a/tools/tools/crypto/cryptocheck.c
+++ b/tools/tools/crypto/cryptocheck.c
@@ -352,23 +352,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);
}
-static 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;
-}
-
static char
rdigit(void)
{
@@ -436,11 +424,10 @@ ocf_init_session(struct session2_op *sop, const char *type, const char *name,
{
int fd;
- fd = crget();
+ fd = devcrypto();
if (ioctl(fd, CIOCGSESSION2, sop) < 0) {
warn("cryptodev %s %s not supported for device %s",
type, name, crfind(sop->crid));
- close(fd);
ses->fd = -1;
return (false);
}
@@ -458,8 +445,6 @@ ocf_destroy_session(struct ocf_session *ses)
if (ioctl(ses->fd, CIOCFSESSION, &ses->ses) < 0)
warn("ioctl(CIOCFSESSION)");
-
- close(ses->fd);
}
static void