Module Name:    src
Committed By:   riastradh
Date:           Sun May 22 11:40:29 UTC 2022

Modified Files:
        src/share/man/man9: opencrypto.9
        src/sys/netipsec: xform_ah.c xform_esp.c xform_ipcomp.c
        src/sys/opencrypto: crypto.c cryptodev.c cryptodev.h

Log Message:
opencrypto: crypto_dispatch never fails now.  Make it return void.

Same with crypto_kdispatch.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/share/man/man9/opencrypto.9
cvs rdiff -u -r1.113 -r1.114 src/sys/netipsec/xform_ah.c
cvs rdiff -u -r1.104 -r1.105 src/sys/netipsec/xform_esp.c
cvs rdiff -u -r1.73 -r1.74 src/sys/netipsec/xform_ipcomp.c
cvs rdiff -u -r1.128 -r1.129 src/sys/opencrypto/crypto.c
cvs rdiff -u -r1.122 -r1.123 src/sys/opencrypto/cryptodev.c
cvs rdiff -u -r1.49 -r1.50 src/sys/opencrypto/cryptodev.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/share/man/man9/opencrypto.9
diff -u src/share/man/man9/opencrypto.9:1.21 src/share/man/man9/opencrypto.9:1.22
--- src/share/man/man9/opencrypto.9:1.21	Sun May 22 11:40:03 2022
+++ src/share/man/man9/opencrypto.9	Sun May 22 11:40:29 2022
@@ -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 (ange...@cis.upenn.edu)
 .\"
@@ -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 @@ structure and
 .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

Index: src/sys/netipsec/xform_ah.c
diff -u src/sys/netipsec/xform_ah.c:1.113 src/sys/netipsec/xform_ah.c:1.114
--- src/sys/netipsec/xform_ah.c:1.113	Sun May 22 11:40:03 2022
+++ src/sys/netipsec/xform_ah.c	Sun May 22 11:40:29 2022
@@ -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 @@ ah_input(struct mbuf *m, struct secasvar
 	     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 @@ ah_output(struct mbuf *m, const struct i
 	tc->tc_flags = flags;
 	tc->tc_sav = sav;
 
-	return crypto_dispatch(crp);
+	crypto_dispatch(crp);
+	return 0;
 
 bad_tc:
 	if (__predict_true(pool_used))

Index: src/sys/netipsec/xform_esp.c
diff -u src/sys/netipsec/xform_esp.c:1.104 src/sys/netipsec/xform_esp.c:1.105
--- src/sys/netipsec/xform_esp.c:1.104	Sun May 22 11:40:03 2022
+++ src/sys/netipsec/xform_esp.c	Sun May 22 11:40:29 2022
@@ -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 @@ esp_input(struct mbuf *m, struct secasva
 	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 @@ esp_output(struct mbuf *m, const struct 
 		}
 	}
 
-	return crypto_dispatch(crp);
+	crypto_dispatch(crp);
+	return 0;
 
 bad:
 	if (m)

Index: src/sys/netipsec/xform_ipcomp.c
diff -u src/sys/netipsec/xform_ipcomp.c:1.73 src/sys/netipsec/xform_ipcomp.c:1.74
--- src/sys/netipsec/xform_ipcomp.c:1.73	Sun May 22 11:40:03 2022
+++ src/sys/netipsec/xform_ipcomp.c	Sun May 22 11:40:29 2022
@@ -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 @@ ipcomp_input(struct mbuf *m, struct seca
 	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 @@ ipcomp_output(struct mbuf *m, const stru
 	crp->crp_opaque = tc;
 	crp->crp_sid = sav->tdb_cryptoid;
 
-	return crypto_dispatch(crp);
+	crypto_dispatch(crp);
+	return 0;
 
 bad:
 	if (m)

Index: src/sys/opencrypto/crypto.c
diff -u src/sys/opencrypto/crypto.c:1.128 src/sys/opencrypto/crypto.c:1.129
--- src/sys/opencrypto/crypto.c:1.128	Sun May 22 11:40:15 2022
+++ src/sys/opencrypto/crypto.c	Sun May 22 11:40:29 2022
@@ -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 @@ crypto_unblock(u_int32_t driverid, int w
  * 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 @@ crypto_dispatch(struct cryptop *crp)
 			softint_schedule(crypto_q_si);
 			kpreempt_enable();
 		}
-		return 0;
+		return;
 	}
 
 	crp_qs = crypto_get_crp_qs(&s);
@@ -1371,14 +1371,13 @@ crypto_dispatch(struct cryptop *crp)
 
 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 @@ crypto_kdispatch(struct cryptkop *krp)
 
 out:
 	crypto_put_crp_qs(&s);
-	return 0;
 }
 
 /*

Index: src/sys/opencrypto/cryptodev.c
diff -u src/sys/opencrypto/cryptodev.c:1.122 src/sys/opencrypto/cryptodev.c:1.123
--- src/sys/opencrypto/cryptodev.c:1.122	Sun May 22 11:40:03 2022
+++ src/sys/opencrypto/cryptodev.c	Sun May 22 11:40:29 2022
@@ -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 @@ cryptodev_op(struct csession *cse, struc
 	}
 
 	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 @@ cryptodev_key(struct crypt_kop *kop)
 			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 @@ cryptodev_mop(struct fcrypt *fcr, 
 #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 @@ cryptodev_mkey(struct fcrypt *fcr, struc
 		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++) {

Index: src/sys/opencrypto/cryptodev.h
diff -u src/sys/opencrypto/cryptodev.h:1.49 src/sys/opencrypto/cryptodev.h:1.50
--- src/sys/opencrypto/cryptodev.h:1.49	Sun May 22 11:40:03 2022
+++ src/sys/opencrypto/cryptodev.h	Sun May 22 11:40:29 2022
@@ -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 @@ extern	int crypto_kregister(u_int32_t, i
 	    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);
-extern	int crypto_kdispatch(struct cryptkop *);
+extern	void crypto_dispatch(struct cryptop *crp);
+extern	void crypto_kdispatch(struct cryptkop *);
 #define	CRYPTO_SYMQ	0x1
 #define	CRYPTO_ASYMQ	0x2
 extern	int crypto_unblock(u_int32_t, int);

Reply via email to