Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/opencrypto opencrypto: crypto_dispatch never fails now. ...



details:   https://anonhg.NetBSD.org/src/rev/615c7ef76d15
branches:  trunk
changeset: 366341:615c7ef76d15
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun May 22 11:40:29 2022 +0000

description:
opencrypto: crypto_dispatch never fails now.  Make it return void.

Same with crypto_kdispatch.

diffstat:

 share/man/man9/opencrypto.9 |  16 ++++++----------
 sys/netipsec/xform_ah.c     |  10 ++++++----
 sys/netipsec/xform_esp.c    |  10 ++++++----
 sys/netipsec/xform_ipcomp.c |  10 ++++++----
 sys/opencrypto/crypto.c     |  12 +++++-------
 sys/opencrypto/cryptodev.c  |  29 +++++++++--------------------
 sys/opencrypto/cryptodev.h  |   6 +++---
 7 files changed, 41 insertions(+), 52 deletions(-)

diffs (truncated from 306 to 300 lines):

diff -r 050d77183e8b -r 615c7ef76d15 share/man/man9/opencrypto.9
--- a/share/man/man9/opencrypto.9       Sun May 22 11:40:15 2022 +0000
+++ b/share/man/man9/opencrypto.9       Sun May 22 11:40:29 2022 +0000
@@ -1,5 +1,5 @@
 .\"    $OpenBSD: crypto.9,v 1.25 2003/07/11 13:47:41 jmc Exp $
-.\"    $NetBSD: opencrypto.9,v 1.21 2022/05/22 11:40:03 riastradh Exp $
+.\"    $NetBSD: opencrypto.9,v 1.22 2022/05/22 11:40:29 riastradh Exp $
 .\"
 .\" The author of this man page is Angelos D. Keromytis (angelos%cis.upenn.edu@localhost)
 .\"
@@ -57,9 +57,9 @@
 .Fn crypto_newsession "u_int64_t *" "struct cryptoini *" "int"
 .Ft void
 .Fn crypto_freesession "u_int64_t"
-.Ft int
+.Ft void
 .Fn crypto_dispatch "struct cryptop *"
-.Ft int
+.Ft void
 .Fn crypto_kdispatch "struct cryptkop *"
 .Ft struct cryptop *
 .Fn crypto_getreq "int"
@@ -650,14 +650,10 @@
 .Dv NULL
 on failure.
 .Fn crypto_dispatch
-returns
-.Er EINVAL
-if its argument or the callback function was
-.Dv NULL ,
-and 0 otherwise.
-The callback is provided with an error code in case of failure, in the
+arranges to invoke the callback with an error code
+in the
 .Fa crp_etype
-field.
+field, or zero on success.
 .Sh FILES
 .Bl -tag -width sys/opencrypto/crypto.c
 .It Pa sys/opencrypto/crypto.c
diff -r 050d77183e8b -r 615c7ef76d15 sys/netipsec/xform_ah.c
--- a/sys/netipsec/xform_ah.c   Sun May 22 11:40:15 2022 +0000
+++ b/sys/netipsec/xform_ah.c   Sun May 22 11:40:29 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xform_ah.c,v 1.113 2022/05/22 11:40:03 riastradh Exp $ */
+/*     $NetBSD: xform_ah.c,v 1.114 2022/05/22 11:40:29 riastradh Exp $ */
 /*     $FreeBSD: xform_ah.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $    */
 /*     $OpenBSD: ip_ah.c,v 1.63 2001/06/26 06:18:58 angelos Exp $ */
 /*
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.113 2022/05/22 11:40:03 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ah.c,v 1.114 2022/05/22 11:40:29 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -691,7 +691,8 @@
             crp->crp_ilen, tc->tc_skip,
             crda->crd_len, crda->crd_skip, crda->crd_inject);
 
-       return crypto_dispatch(crp);
+       crypto_dispatch(crp);
+       return 0;
 
 bad:
        if (tc != NULL) {
@@ -1106,7 +1107,8 @@
        tc->tc_flags = flags;
        tc->tc_sav = sav;
 
-       return crypto_dispatch(crp);
+       crypto_dispatch(crp);
+       return 0;
 
 bad_tc:
        if (__predict_true(pool_used))
diff -r 050d77183e8b -r 615c7ef76d15 sys/netipsec/xform_esp.c
--- a/sys/netipsec/xform_esp.c  Sun May 22 11:40:15 2022 +0000
+++ b/sys/netipsec/xform_esp.c  Sun May 22 11:40:29 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xform_esp.c,v 1.104 2022/05/22 11:40:03 riastradh Exp $        */
+/*     $NetBSD: xform_esp.c,v 1.105 2022/05/22 11:40:29 riastradh Exp $        */
 /*     $FreeBSD: xform_esp.c,v 1.2.2.1 2003/01/24 05:11:36 sam Exp $   */
 /*     $OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */
 
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.104 2022/05/22 11:40:03 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_esp.c,v 1.105 2022/05/22 11:40:29 riastradh Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -472,7 +472,8 @@
        crde->crd_klen = _KEYBITS(sav->key_enc);
        /* XXX Rounds ? */
 
-       return crypto_dispatch(crp);
+       crypto_dispatch(crp);
+       return 0;
 
 out2:
        pool_cache_put(esp_tdb_crypto_pool_cache, tc);
@@ -924,7 +925,8 @@
                }
        }
 
-       return crypto_dispatch(crp);
+       crypto_dispatch(crp);
+       return 0;
 
 bad:
        if (m)
diff -r 050d77183e8b -r 615c7ef76d15 sys/netipsec/xform_ipcomp.c
--- a/sys/netipsec/xform_ipcomp.c       Sun May 22 11:40:15 2022 +0000
+++ b/sys/netipsec/xform_ipcomp.c       Sun May 22 11:40:29 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: xform_ipcomp.c,v 1.73 2022/05/22 11:40:03 riastradh Exp $      */
+/*     $NetBSD: xform_ipcomp.c,v 1.74 2022/05/22 11:40:29 riastradh Exp $      */
 /*     $FreeBSD: xform_ipcomp.c,v 1.1.4.1 2003/01/24 05:11:36 sam Exp $        */
 /* $OpenBSD: ip_ipcomp.c,v 1.1 2001/07/05 12:08:52 jjbg Exp $ */
 
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xform_ipcomp.c,v 1.73 2022/05/22 11:40:03 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xform_ipcomp.c,v 1.74 2022/05/22 11:40:29 riastradh Exp $");
 
 /* IP payload compression protocol (IPComp), see RFC 2393 */
 #if defined(_KERNEL_OPT)
@@ -208,7 +208,8 @@
        tc->tc_skip = skip;
        tc->tc_sav = sav;
 
-       return crypto_dispatch(crp);
+       crypto_dispatch(crp);
+       return 0;
 
 error_tc:
        pool_cache_put(ipcomp_tdb_crypto_pool_cache, tc);
@@ -493,7 +494,8 @@
        crp->crp_opaque = tc;
        crp->crp_sid = sav->tdb_cryptoid;
 
-       return crypto_dispatch(crp);
+       crypto_dispatch(crp);
+       return 0;
 
 bad:
        if (m)
diff -r 050d77183e8b -r 615c7ef76d15 sys/opencrypto/crypto.c
--- a/sys/opencrypto/crypto.c   Sun May 22 11:40:15 2022 +0000
+++ b/sys/opencrypto/crypto.c   Sun May 22 11:40:29 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: crypto.c,v 1.128 2022/05/22 11:40:15 riastradh Exp $ */
+/*     $NetBSD: crypto.c,v 1.129 2022/05/22 11:40:29 riastradh Exp $ */
 /*     $FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $   */
 /*     $OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $ */
 
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.128 2022/05/22 11:40:15 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.129 2022/05/22 11:40:29 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/reboot.h>
@@ -1274,7 +1274,7 @@
  * Dispatch a crypto request to a driver or queue
  * it, to be processed by the kernel thread.
  */
-int
+void
 crypto_dispatch(struct cryptop *crp)
 {
        int result, s;
@@ -1318,7 +1318,7 @@
                        softint_schedule(crypto_q_si);
                        kpreempt_enable();
                }
-               return 0;
+               return;
        }
 
        crp_qs = crypto_get_crp_qs(&s);
@@ -1371,14 +1371,13 @@
 
 out:
        crypto_put_crp_qs(&s);
-       return 0;
 }
 
 /*
  * Add an asymmetric crypto request to a queue,
  * to be processed by the kernel thread.
  */
-int
+void
 crypto_kdispatch(struct cryptkop *krp)
 {
        int result, s;
@@ -1433,7 +1432,6 @@
 
 out:
        crypto_put_crp_qs(&s);
-       return 0;
 }
 
 /*
diff -r 050d77183e8b -r 615c7ef76d15 sys/opencrypto/cryptodev.c
--- a/sys/opencrypto/cryptodev.c        Sun May 22 11:40:15 2022 +0000
+++ b/sys/opencrypto/cryptodev.c        Sun May 22 11:40:29 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cryptodev.c,v 1.122 2022/05/22 11:40:03 riastradh Exp $ */
+/*     $NetBSD: cryptodev.c,v 1.123 2022/05/22 11:40:29 riastradh 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.122 2022/05/22 11:40:03 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.123 2022/05/22 11:40:29 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -648,13 +648,7 @@
        }
 
        cv_init(&crp->crp_cv, "crydev");
-       error = crypto_dispatch(crp);
-       if (error) {
-               DPRINTF("not waiting, error.\n");
-               cv_destroy(&crp->crp_cv);
-               goto bail;
-       }
-
+       crypto_dispatch(crp);
        mutex_enter(&cryptodev_mtx);
        while (!(crp->crp_devflags & CRYPTODEV_F_RET)) {
                DPRINTF("cse->sid[%d]: sleeping on cv %p for crp %p\n",
@@ -849,10 +843,7 @@
                        goto fail;
        }
 
-       error = crypto_kdispatch(krp);
-       if (error != 0) {
-               goto fail;
-       }
+       crypto_kdispatch(krp);
 
        mutex_enter(&cryptodev_mtx);
        while (!(krp->krp_devflags & CRYPTODEV_F_RET)) {
@@ -1304,7 +1295,8 @@
 #ifdef notyet
 eagain:
 #endif
-               cnop[req].status = crypto_dispatch(crp);
+               crypto_dispatch(crp);
+               cnop[req].status = 0;
                mutex_enter(&cryptodev_mtx);    /* XXX why mutex? */
 
                switch (cnop[req].status) {
@@ -1455,13 +1447,10 @@
                krp->krp_reqid = kop[req].crk_reqid;
                krp->krp_usropaque = kop[req].crk_opaque;
 
-               kop[req].crk_status = crypto_kdispatch(krp);
-               if (kop[req].crk_status != 0) {
-                       goto fail;
-               }
-
+               crypto_kdispatch(krp);
+               kop[req].crk_status = 0;
 fail:
-               if(kop[req].crk_status) {
+               if (kop[req].crk_status) {
                        if (krp) {
                                kop[req].crk_status = krp->krp_status;
                                for (i = 0; i < CRK_MAXPARAM; i++) {
diff -r 050d77183e8b -r 615c7ef76d15 sys/opencrypto/cryptodev.h
--- a/sys/opencrypto/cryptodev.h        Sun May 22 11:40:15 2022 +0000
+++ b/sys/opencrypto/cryptodev.h        Sun May 22 11:40:29 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cryptodev.h,v 1.49 2022/05/22 11:40:03 riastradh Exp $ */
+/*     $NetBSD: cryptodev.h,v 1.50 2022/05/22 11:40:29 riastradh 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 $      */
 
@@ -609,8 +609,8 @@
            void *arg);
 extern int crypto_unregister(u_int32_t driverid, int alg);
 extern int crypto_unregister_all(u_int32_t driverid);
-extern int crypto_dispatch(struct cryptop *crp);



Home | Main Index | Thread Index | Old Index