DragonFly BSD
DragonFly bugs List (threaded) for 2004-04
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: temporary fix to netgraph breakage


To: YONETANI Tomokazu <qhwt+dragonfly-bugs@xxxxxxxxxx>
From: Jeffrey Hsu <hsu@xxxxxxxxxxx>
Date: Mon, 19 Apr 2004 11:35:29 -0700

I think I see what's going on here.  The netgraph code is making synchronous
socket calls back into the stack.  Please try this patch out.  If it works for you,
I'll commit it shortly.  Thanks.

Jeffrey
Index: net/netisr.c
===================================================================
RCS file: /j/dragonfly/dcvs/src/sys/net/netisr.c,v
retrieving revision 1.12
diff -u -p -r1.12 netisr.c
--- net/netisr.c	17 Apr 2004 00:46:28 -0000	1.12
+++ net/netisr.c	19 Apr 2004 18:32:20 -0000
@@ -40,6 +40,31 @@ netisr_autofree_reply(lwkt_port_t port, 
     free(msg, M_LWKTMSG);
 }
 
+/*
+ * We must construct a custom putport function (which runs in the context
+ * of the message originator)
+ * Our custom putport must check for self-referential messages, which can
+ * occur when the so_upcall routine is called (e.g. nfs).  Self referential
+ * messages are simply executed synchronously.
+ */
+int
+netmsg_put_port(lwkt_port_t port, lwkt_msg_t lmsg)
+{
+    /*
+     * If it's a synchronous message for the same thread,
+     * execute it directly.
+     */
+    if (!(lmsg->ms_flags & MSGF_ASYNC) && port->mp_td == curthread) {
+	struct netmsg *msg = (struct netmsg *)lmsg;
+
+	msg->nm_handler(msg);
+    } else {
+        lwkt_default_putport(port, lmsg);
+    }
+
+    return (EASYNC);
+}
+
 static void
 netisr_init(void)
 {
@@ -49,6 +74,7 @@ netisr_init(void)
     for (i = 0; i < ncpus; ++i) {
 	lwkt_create(netmsg_service_loop, NULL, NULL, &netisr_cpu[i], 0, i,
 	    "netisr_cpu %d", i);
+	netisr_cpu[i].td_msgport.mp_putport = netmsg_put_port;
     }
     lwkt_initport(&netisr_afree_rport, NULL);
     netisr_afree_rport.mp_replyport = netisr_autofree_reply;
Index: net/netisr.h
===================================================================
RCS file: /j/dragonfly/dcvs/src/sys/net/netisr.h,v
retrieving revision 1.14
diff -u -p -r1.14 netisr.h
--- net/netisr.h	10 Apr 2004 09:35:34 -0000	1.14
+++ net/netisr.h	19 Apr 2004 18:32:12 -0000
@@ -177,6 +177,7 @@ void		netisr_dispatch(int, struct mbuf *
 int		netisr_queue(int, struct mbuf *);
 void		netisr_register(int, lwkt_portfn_t, netisr_fn_t);
 int		netisr_unregister(int);
+int		netmsg_put_port(lwkt_port_t, lwkt_msg_t);
 void		netmsg_service_loop(void *arg);
 void		schednetisr(int);
 
Index: netinet/ip_demux.c
===================================================================
RCS file: /j/dragonfly/dcvs/src/sys/netinet/ip_demux.c,v
retrieving revision 1.18
diff -u -p -r1.18 ip_demux.c
--- netinet/ip_demux.c	10 Apr 2004 00:10:42 -0000	1.18
+++ netinet/ip_demux.c	19 Apr 2004 18:31:04 -0000
@@ -255,31 +255,6 @@ tcp_cport(int cpu)
 	return (&tcp_thread[cpu].td_msgport);
 }
 
-/*
- * We must construct a custom putport function (which runs in the context
- * of the message originator)
- * Our custom putport must check for self-referential messages, which can
- * occur when the so_upcall routine is called (e.g. nfs).  Self referential
- * messages are simply executed synchronously.
- */
-static int
-netmsg_put_port(lwkt_port_t port, lwkt_msg_t lmsg)
-{
-    /*
-     * If it's a synchronous message for the same thread,
-     * execute it directly.
-     */
-    if (!(lmsg->ms_flags & MSGF_ASYNC) && port->mp_td == curthread) {
-	struct netmsg *msg = (struct netmsg *)lmsg;
-
-	msg->nm_handler(msg);
-    } else {
-        lwkt_default_putport(port, lmsg);
-    }
-
-    return (EASYNC);
-}
-
 void
 tcp_thread_init(void)
 {


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]