summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorBret Lambert <blambert@cvs.openbsd.org>2010-08-21 06:50:43 +0000
committerBret Lambert <blambert@cvs.openbsd.org>2010-08-21 06:50:43 +0000
commit9ac321b7c256e5da1096caaaa0bb9b8415910499 (patch)
tree5cbf4a37099c0f8386f62768438b5034f46e6b4d /sys/net
parentdfb648c37d8af19454f7f69dc851226717f30a74 (diff)
an unchecked-for failure of workq_add_task could lead to an mbuf leak
steal a page from dlg@ and embed a workq_task struct directly in the aoe_handler struct so that we won't fail when enqueueing a task while here, create real debugging printfs vice commenting out regular ones, and kill with fire the excessive number of includes ok marco@ tedu@
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_aoe.c34
-rw-r--r--sys/net/if_aoe.h4
2 files changed, 14 insertions, 24 deletions
diff --git a/sys/net/if_aoe.c b/sys/net/if_aoe.c
index 694fae87d5f..03c1ca3c3d4 100644
--- a/sys/net/if_aoe.c
+++ b/sys/net/if_aoe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_aoe.c,v 1.1 2008/11/23 23:44:01 tedu Exp $ */
+/* $OpenBSD: if_aoe.c,v 1.2 2010/08/21 06:50:42 blambert Exp $ */
/*
* Copyright (c) 2008 Ted Unangst <tedu@openbsd.org>
*
@@ -16,32 +16,19 @@
*/
#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/buf.h>
-#include <sys/device.h>
-#include <sys/ioctl.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/disk.h>
-#include <sys/rwlock.h>
#include <sys/queue.h>
-#include <sys/vnode.h>
-#include <sys/namei.h>
-#include <sys/fcntl.h>
-#include <sys/disklabel.h>
-#include <sys/conf.h>
-#include <sys/stat.h>
#include <sys/workq.h>
#include <sys/socket.h>
#include <sys/mbuf.h>
-#include <sys/socketvar.h>
#include <net/if.h>
-#include <netinet/in.h>
-#include <net/ethertypes.h>
-#include <netinet/if_ether.h>
#include <net/if_aoe.h>
+#ifdef AOE_DEBUG
+#define DPRINTF(x) printf x
+#else
+#define DPRINTF(x) /* nothing */
+#endif
+
struct aoe_handler_head aoe_handlers = TAILQ_HEAD_INITIALIZER(aoe_handlers);
void
@@ -53,7 +40,7 @@ aoe_input(struct ifnet *ifp, struct mbuf *m)
splassert(IPL_NET);
ap = mtod(m, struct aoe_packet *);
- /* printf("aoe packet %d %d\n", htons(ap->major), ap->minor); */
+ DPRINTF(("aoe packet %d %d\n", htons(ap->major), ap->minor));
TAILQ_FOREACH(q, &aoe_handlers, next) {
if (q->ifp == ifp) {
@@ -62,9 +49,10 @@ aoe_input(struct ifnet *ifp, struct mbuf *m)
}
}
if (!q) {
- /* printf("no q\n"); */
+ DPRINTF(("no q\n"));
m_freem(m);
return;
}
- workq_add_task(NULL, 0, q->fn, q, m);
+
+ workq_queue_task(NULL, &q->task, 0, q->fn, q, m);
}
diff --git a/sys/net/if_aoe.h b/sys/net/if_aoe.h
index 79e0fe0eb52..d73ee016eea 100644
--- a/sys/net/if_aoe.h
+++ b/sys/net/if_aoe.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_aoe.h,v 1.1 2008/11/23 23:44:01 tedu Exp $ */
+/* $OpenBSD: if_aoe.h,v 1.2 2010/08/21 06:50:42 blambert Exp $ */
/*
* Copyright (c) 2007 Ted Unangst <tedu@openbsd.org>
*
@@ -15,6 +15,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/workq.h>
+#include <sys/timeout.h> /* for struct timeout */
struct aoe_packet {
#define AOE_F_ERROR (1 << 2)
@@ -103,6 +104,7 @@ struct aoe_handler {
unsigned char minor;
struct ifnet *ifp;
workq_fn fn;
+ struct workq_task task;
TAILQ_HEAD(, aoe_req) reqs;
};