summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2014-04-28 20:38:08 +0000
committerbrooks <brooks@FreeBSD.org>2014-04-28 20:38:08 +0000
commit2e62cc3f357edf671acfc1ef17b4172de3eb806a (patch)
tree7d03473b060c2e3d2550ce849d6dea5fd31ce279
parent654570b8ce245261548a53b1fbd13da926c6047f (diff)
downloadFreeBSD-src-2e62cc3f357edf671acfc1ef17b4172de3eb806a.zip
FreeBSD-src-2e62cc3f357edf671acfc1ef17b4172de3eb806a.tar.gz
Revert r263754, re-adding support for hw.bus.devctl_disable. Breaking
old devd's and thus hosts that get IP addresses from DHCP was too much of a POLA violation. The sysctl may be removed again after r263758 has been merged to at least stable/9 and stable/10, and releases have been cut from those branches. Discussed with: mjg Reported by: theraven, rwatson
-rw-r--r--sys/kern/subr_bus.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index dbe88b2..53b10ec 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -355,6 +355,13 @@ device_sysctl_fini(device_t dev)
* tested since 3.4 or 2.2.8!
*/
+/* Deprecated way to adjust queue length */
+static int sysctl_devctl_disable(SYSCTL_HANDLER_ARGS);
+/* XXX Need to support old-style tunable hw.bus.devctl_disable" */
+SYSCTL_PROC(_hw_bus, OID_AUTO, devctl_disable, CTLTYPE_INT | CTLFLAG_RW |
+ CTLFLAG_MPSAFE, NULL, 0, sysctl_devctl_disable, "I",
+ "devctl disable -- deprecated");
+
#define DEVCTL_DEFAULT_QUEUE_LEN 1000
static int sysctl_devctl_queue(SYSCTL_HANDLER_ARGS);
static int devctl_queue_length = DEVCTL_DEFAULT_QUEUE_LEN;
@@ -685,9 +692,9 @@ devctl_notify(const char *system, const char *subsystem, const char *type,
* Common routine that tries to make sending messages as easy as possible.
* We allocate memory for the data, copy strings into that, but do not
* free it unless there's an error. The dequeue part of the driver should
- * free the data. We don't send data when queue length is 0. We do send
- * data, even when we have no listeners, because we wish to avoid races
- * relating to startup and restart of listening applications.
+ * free the data. We don't send data when the device is disabled. We do
+ * send data, even when we have no listeners, because we wish to avoid
+ * races relating to startup and restart of listening applications.
*
* devaddq is designed to string together the type of event, with the
* object of that event, plus the plug and play info and location info
@@ -779,6 +786,33 @@ devnomatch(device_t dev)
}
static int
+sysctl_devctl_disable(SYSCTL_HANDLER_ARGS)
+{
+ struct dev_event_info *n1;
+ int dis, error;
+
+ dis = devctl_queue_length == 0;
+ error = sysctl_handle_int(oidp, &dis, 0, req);
+ if (error || !req->newptr)
+ return (error);
+ mtx_lock(&devsoftc.mtx);
+ if (dis) {
+ while (!TAILQ_EMPTY(&devsoftc.devq)) {
+ n1 = TAILQ_FIRST(&devsoftc.devq);
+ TAILQ_REMOVE(&devsoftc.devq, n1, dei_link);
+ free(n1->dei_data, M_BUS);
+ free(n1, M_BUS);
+ }
+ devsoftc.queued = 0;
+ devctl_queue_length = 0;
+ } else {
+ devctl_queue_length = DEVCTL_DEFAULT_QUEUE_LEN;
+ }
+ mtx_unlock(&devsoftc.mtx);
+ return (0);
+}
+
+static int
sysctl_devctl_queue(SYSCTL_HANDLER_ARGS)
{
struct dev_event_info *n1;
OpenPOWER on IntegriCloud