Re: IPSEC/crypto is broken in FreeBSD/powerpc 7.0-RELEASE!

From: M. Warner Losh <imp_at_bsdimp.com>
Date: Tue, 04 Mar 2008 19:31:20 -0700 (MST)
OK.  Digging deeper into this problem shows that sparc64 also appears
to do the same things to the nexus bus children that powerpc does.
There may be other nexus devices that do this, and rewriting them to
conform to the x86 conventions would take a little bit of effort.

I'm starting to think that the architecturally clean way to solve this
issue is to allow children to ask if they have a fixed devclass or a
wildcard one in newbus.  This is easy to implement, but as I typed
this up, something inside me rebelled.  In this scenario, the newbus
would grow a new function device_is_wildcard() that drivers could
call.

The other way to fix this is to return a better value from the probe
routine for those devices that attach to the nexus.  A quick grep of
the tree suggests that opencrypto is the only MI driver that uses this
trick.  There are a few MD drivers that use it as well, but they are
all well controlled.  Here's a quick hack.  If you want to test this
out without changing newbus, change the cryptosoft.c probe routine to
return (BUS_PROBE_HOOVER - 1) rather than zero.

Comments?

Warner

Index: sys/bus.h
===================================================================
RCS file: /cache/ncvs/src/sys/sys/bus.h,v
retrieving revision 1.79
diff -u -r1.79 bus.h
--- sys/bus.h	27 Jan 2008 16:06:37 -0000	1.79
+++ sys/bus.h	5 Mar 2008 02:28:17 -0000
_at__at_ -494,7 +494,10 _at__at_
  * is for drivers that wish to have a generic form and a specialized form,
  * like is done with the pci bus and the acpi pci bus.  BUS_PROBE_HOOVER is
  * for those busses that implement a generic device place-holder for devices on
- * the bus that have no more specific driver for them (aka ugen).
+ * the bus that have no more specific river for them (aka ugen).
+ * BUS_PROBE_NOWILDCARD or lower means that the device isn't really bidding
+ * for a device node, but accepts only devices that its parent has told it
+ * use this driver.
  */
 #define BUS_PROBE_SPECIFIC	0	/* Only I can use this device */
 #define BUS_PROBE_VENDOR	(-10)	/* Vendor supplied driver */
_at__at_ -502,6 +505,7 _at__at_
 #define BUS_PROBE_LOW_PRIORITY	(-40)	/* Older, less desirable drivers */
 #define BUS_PROBE_GENERIC	(-100)	/* generic driver for dev */
 #define BUS_PROBE_HOOVER	(-500)	/* Generic dev for all devs on bus */
+#define BUS_PROBE_NOWILDCARD	(-2000000000) /* No wildcard device matches */
 
 /**
  * Shorthand for constructing method tables.
Index: kern/subr_bus.c
===================================================================
RCS file: /cache/ncvs/src/sys/kern/subr_bus.c,v
retrieving revision 1.204
diff -u -r1.204 subr_bus.c
--- kern/subr_bus.c	27 Jan 2008 16:06:37 -0000	1.204
+++ kern/subr_bus.c	5 Mar 2008 02:27:30 -0000
_at__at_ -1777,6 +1777,14 _at__at_
 			 * of pri for the first match.
 			 */
 			if (best == NULL || result > pri) {
+				/*
+				 * Probes that return BUS_PROBE_NOWILDCARD
+				 * or lower only match when they are set
+				 * in stone by the parent bus.
+				 */
+				if (result <= BUS_PROBE_NOWILDCARD &&
+				    child->flags & DF_WILDCARD)
+					continue;
 				best = dl;
 				pri = result;
 				continue;
Index: opencrypto/cryptosoft.c
===================================================================
RCS file: /cache/ncvs/src/sys/opencrypto/cryptosoft.c,v
retrieving revision 1.19
diff -u -r1.19 cryptosoft.c
--- opencrypto/cryptosoft.c	9 May 2007 19:37:02 -0000	1.19
+++ opencrypto/cryptosoft.c	5 Mar 2008 02:22:28 -0000
_at__at_ -989,7 +989,7 _at__at_
 swcr_probe(device_t dev)
 {
 	device_set_desc(dev, "software crypto");
-	return (0);
+	return (BUS_PROBE_NOWILDCARD);
 }
 
 static int
Received on Wed Mar 05 2008 - 01:31:25 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:28 UTC