diff options
| author | pgoyette <pgoyette@NetBSD.org> | 2019-01-27 02:08:33 +0000 |
|---|---|---|
| committer | pgoyette <pgoyette@NetBSD.org> | 2019-01-27 02:08:33 +0000 |
| commit | cc17ee2ece085d7d746bcd8fa9be19170855aaac (patch) | |
| tree | 5be40613f405cb081b2c44410b1506781927f8e3 /sys/opencrypto | |
| parent | 10dd4cc92542aa04b0e59469a484a48e4c3cdd24 (diff) | |
Merge the [pgoyette-compat] branch
Diffstat (limited to 'sys/opencrypto')
| -rw-r--r-- | sys/opencrypto/cryptodev.c | 21 | ||||
| -rw-r--r-- | sys/opencrypto/files.opencrypto | 4 | ||||
| -rw-r--r-- | sys/opencrypto/ocryptodev.c | 52 | ||||
| -rw-r--r-- | sys/opencrypto/ocryptodev.h | 8 |
4 files changed, 63 insertions, 22 deletions
diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c index 2304ad1ac88..7693efedb11 100644 --- a/sys/opencrypto/cryptodev.c +++ b/sys/opencrypto/cryptodev.c @@ -1,4 +1,4 @@ -/* $NetBSD: cryptodev.c,v 1.98 2018/02/08 09:05:20 dholland Exp $ */ +/* $NetBSD: cryptodev.c,v 1.99 2019/01/27 02:08:48 pgoyette Exp $ */ /* $FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $ */ /* $OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $ */ @@ -64,7 +64,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.98 2018/02/08 09:05:20 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.99 2019/01/27 02:08:48 pgoyette Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -86,6 +86,7 @@ __KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.98 2018/02/08 09:05:20 dholland Exp #include <sys/atomic.h> #include <sys/stat.h> #include <sys/module.h> +#include <sys/compat_stub.h> #ifdef _KERNEL_OPT #include "opt_ocf.h" @@ -93,6 +94,7 @@ __KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.98 2018/02/08 09:05:20 dholland Exp #endif #include <opencrypto/cryptodev.h> +#include <opencrypto/ocryptodev.h> #include <opencrypto/cryptodev_internal.h> #include <opencrypto/xform.h> @@ -196,10 +198,6 @@ static int cryptodev_getmstatus(struct fcrypt *, struct crypt_result *, int); static int cryptodev_getstatus(struct fcrypt *, struct crypt_result *); -#ifdef COMPAT_50 -extern int ocryptof_ioctl(struct file *, u_long, void *); -#endif - /* * sysctl-able control variables for /dev/crypto now defined in crypto.c: * crypto_usercrypto, crypto_userasmcrypto, crypto_devallowsoft. @@ -441,12 +439,13 @@ reterr: error = cryptodev_getstatus(fcr, (struct crypt_result *)data); break; default: -#ifdef COMPAT_50 /* Check for backward compatible commands */ - error = ocryptof_ioctl(fp, cmd, data); -#else - return EINVAL; -#endif + + MODULE_CALL_HOOK(ocryptof_50_hook, (fp, cmd, data), + enosys(), error); + if (error == ENOSYS) + error = EINVAL; + return error; } return error; } diff --git a/sys/opencrypto/files.opencrypto b/sys/opencrypto/files.opencrypto index 228ec79f415..e1bf2a8a796 100644 --- a/sys/opencrypto/files.opencrypto +++ b/sys/opencrypto/files.opencrypto @@ -1,4 +1,4 @@ -# $NetBSD: files.opencrypto,v 1.26 2017/05/24 10:05:09 knakahara Exp $ +# $NetBSD: files.opencrypto,v 1.27 2019/01/27 02:08:48 pgoyette Exp $ # # @@ -25,7 +25,7 @@ file opencrypto/gmac.c swcrypto # (and thus crypto hardware accelerators). defpseudo crypto: opencrypto file opencrypto/cryptodev.c crypto -file opencrypto/ocryptodev.c crypto & compat_50 +file opencrypto/ocryptodev.c compat_50 & crypto defflag opt_ocf.h CRYPTO_DEBUG CRYPTO_TIMING defparam opt_ocf.h CRYPTO_RET_Q_MAXLEN CRYPTO_RET_KQ_MAXLEN diff --git a/sys/opencrypto/ocryptodev.c b/sys/opencrypto/ocryptodev.c index 46d853d7493..9033caedb13 100644 --- a/sys/opencrypto/ocryptodev.c +++ b/sys/opencrypto/ocryptodev.c @@ -1,4 +1,4 @@ -/* $NetBSD: ocryptodev.c,v 1.11 2017/07/28 17:14:04 riastradh Exp $ */ +/* $NetBSD: ocryptodev.c,v 1.12 2019/01/27 02:08:48 pgoyette Exp $ */ /* $FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $ */ /* $OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $ */ @@ -69,7 +69,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ocryptodev.c,v 1.11 2017/07/28 17:14:04 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ocryptodev.c,v 1.12 2019/01/27 02:08:48 pgoyette Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -89,6 +89,8 @@ __KERNEL_RCSID(0, "$NetBSD: ocryptodev.c,v 1.11 2017/07/28 17:14:04 riastradh Ex #include <sys/select.h> #include <sys/poll.h> #include <sys/atomic.h> +#include <sys/compat_stub.h> +#include <sys/module.h> #ifdef _KERNEL_OPT #include "opt_ocf.h" @@ -104,7 +106,8 @@ static int ocryptodev_op(struct csession *, struct ocrypt_op *, static int ocryptodev_mop(struct fcrypt *, struct ocrypt_n_op *, int, struct lwp *); static int ocryptodev_session(struct fcrypt *, struct osession_op *); -static int ocryptodev_msession(struct fcrypt *, struct osession_n_op *, int); +static int ocryptodev_msession(struct fcrypt *, struct osession_n_op *, + int); int ocryptof_ioctl(struct file *fp, u_long cmd, void *data) @@ -174,7 +177,8 @@ mbail: error = copyin(omop->reqs, ocnop, (omop->count * sizeof(struct ocrypt_n_op))); if(!error) { - error = ocryptodev_mop(fcr, ocnop, omop->count, curlwp); + error = ocryptodev_mop(fcr, ocnop, omop->count, + curlwp); if (!error) { error = copyout(ocnop, omop->reqs, (omop->count * sizeof(struct ocrypt_n_op))); @@ -209,9 +213,8 @@ ocryptodev_op(struct csession *cse, struct ocrypt_op *ocop, struct lwp *l) }; static int -ocryptodev_mop(struct fcrypt *fcr, - struct ocrypt_n_op *ocnop, - int count, struct lwp *l) +ocryptodev_mop(struct fcrypt *fcr, struct ocrypt_n_op *ocnop, int count, + struct lwp *l) { int res; @@ -242,7 +245,7 @@ ocryptodev_mop(struct fcrypt *fcr, static int -ocryptodev_session(struct fcrypt *fcr, struct osession_op *osop) +ocryptodev_session(struct fcrypt *fcr, struct osession_op *osop) { struct session_op sop; int res; @@ -283,3 +286,36 @@ ocryptodev_msession(struct fcrypt *fcr, struct osession_n_op *osn_ops, return 0; } + +static void +crypto_50_init(void) +{ + + MODULE_SET_HOOK(ocryptof_50_hook, "cryp50", ocryptof_ioctl); +} + +static void +crypto_50_fini(void) +{ + + MODULE_UNSET_HOOK(ocryptof_50_hook); +} + +MODULE(MODULE_CLASS_EXEC, compat_crypto_50, "crypto,compat_50"); + +static int +compat_crypto_50_modcmd(modcmd_t cmd, void *arg) +{ + + switch (cmd) { + case MODULE_CMD_INIT: + crypto_50_init(); + return 0; + case MODULE_CMD_FINI: + crypto_50_fini(); + return 0; + default: + return ENOTTY; + } +} + diff --git a/sys/opencrypto/ocryptodev.h b/sys/opencrypto/ocryptodev.h index 9ed3cae5aa5..aa07fe7643a 100644 --- a/sys/opencrypto/ocryptodev.h +++ b/sys/opencrypto/ocryptodev.h @@ -1,4 +1,4 @@ -/* $NetBSD: ocryptodev.h,v 1.3 2015/09/06 06:01:02 dholland Exp $ */ +/* $NetBSD: ocryptodev.h,v 1.4 2019/01/27 02:08:48 pgoyette Exp $ */ /* $FreeBSD: src/sys/opencrypto/cryptodev.h,v 1.2.2.6 2003/07/02 17:04:50 sam Exp $ */ /* $OpenBSD: cryptodev.h,v 1.33 2002/07/17 23:52:39 art Exp $ */ @@ -170,6 +170,12 @@ struct ocrypt_mop { #define OCIOCCRYPT _IOWR('c', 103, struct ocrypt_op) #define OCIOCNCRYPTM _IOWR('c', 107, struct ocrypt_mop) +struct fcrypt; +struct session_op; +struct csession; +struct crypt_op; +struct crypt_n_op; + int ocryptof_ioctl(struct file *, u_long, void *); #endif /* _CRYPTO_OCRYPTODEV_H_ */ |
