summaryrefslogtreecommitdiff
path: root/sys/net/if_aoe.c
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/if_aoe.c
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/if_aoe.c')
-rw-r--r--sys/net/if_aoe.c34
1 files changed, 11 insertions, 23 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);
}