PERFORCE change 1202585 for review

John-Mark Gurney jmg at FreeBSD.org
Fri Nov 7 00:14:13 UTC 2014


http://p4web.freebsd.org/@@1202585?ac=10

Change 1202585 by jmg at jmg_carbon2 on 2014/11/07 00:13:16

	improve the selection of the device...  If you ask for both
	_HARDWARE and _SOFTWARE devices, but software is disallowed
	per sysctl, silently remove _SOFTWARE... We'll still get an
	error if the _HARDWARE doesn't support it...
	
	This makes testing of both the hardware drivers and software
	drivers easier...  Most software will just set _HARDWARE and
	will continue to work...
	
	Sponsored by:	FreeBSD Foundation
	Sponsored by:	Netgate

Affected files ...

.. //depot/projects/opencrypto/sys/opencrypto/cryptodev.c#10 edit

Differences ...

==== //depot/projects/opencrypto/sys/opencrypto/cryptodev.c#10 (text+ko) ====

@@ -338,15 +338,23 @@
  * by device name/class or through search constraints.
  */
 static int
-checkforsoftware(int crid)
+checkforsoftware(int *cridp)
 {
+	int crid;
+
+	crid = *cridp;
 
 	if (!crypto_devallowsoft) {
-		if (crid & CRYPTOCAP_F_SOFTWARE)
-			return EINVAL;		/* XXX */
+		if (crid & CRYPTOCAP_F_SOFTWARE) {
+			if (crid & CRYPTOCAP_F_HARDWARE) {
+				*cridp = CRYPTOCAP_F_HARDWARE;
+				return 0;
+			}
+			return EINVAL;
+		}
 		if ((crid & CRYPTOCAP_F_HARDWARE) == 0 &&
 		    (crypto_getcaps(crid) & CRYPTOCAP_F_HARDWARE) == 0)
-			return EINVAL;		/* XXX */
+			return EINVAL;
 	}
 	return 0;
 }
@@ -537,7 +545,7 @@
 #endif
 			) {
 			crid = SES2(sop)->crid;
-			error = checkforsoftware(crid);
+			error = checkforsoftware(&crid);
 			if (error) {
 				CRYPTDEB("checkforsoftware");
 				goto bail;


More information about the p4-projects mailing list