Add TDF_NETWORK lwkt flag, so various assertion could be performed to make sure
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 20 Sep 2008 04:31:02 +0000 (04:31 +0000)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 20 Sep 2008 04:31:02 +0000 (04:31 +0000)
that packets are processed in network threads (i.e. controlled enviroment)

sys/net/if.c
sys/net/netisr.c
sys/netinet/ip_demux.c
sys/sys/thread.h

index 3408a02..7114db8 100644 (file)
@@ -32,7 +32,7 @@
  *
  *     @(#)if.c        8.3 (Berkeley) 1/4/94
  * $FreeBSD: src/sys/net/if.c,v 1.185 2004/03/13 02:35:03 brooks Exp $
  *
  *     @(#)if.c        8.3 (Berkeley) 1/4/94
  * $FreeBSD: src/sys/net/if.c,v 1.185 2004/03/13 02:35:03 brooks Exp $
- * $DragonFly: src/sys/net/if.c,v 1.78 2008/09/17 11:25:16 sephe Exp $
+ * $DragonFly: src/sys/net/if.c,v 1.79 2008/09/20 04:31:02 sephe Exp $
  */
 
 #include "opt_compat.h"
  */
 
 #include "opt_compat.h"
@@ -2360,8 +2360,8 @@ ifnetinit(void *dummy __unused)
        for (i = 0; i < ncpus; ++i) {
                struct thread *thr = &ifnet_threads[i];
 
        for (i = 0; i < ncpus; ++i) {
                struct thread *thr = &ifnet_threads[i];
 
-               lwkt_create(netmsg_service_loop_mpsafe, NULL, NULL, thr, 0, i,
-                           "ifnet %d", i);
+               lwkt_create(netmsg_service_loop, NULL, NULL, thr,
+                           TDF_NETWORK | TDF_MPSAFE, i, "ifnet %d", i);
                netmsg_service_port_init(&thr->td_msgport);
        }
 }
                netmsg_service_port_init(&thr->td_msgport);
        }
 }
index 4da491a..4ff5155 100644 (file)
@@ -35,7 +35,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $DragonFly: src/sys/net/netisr.c,v 1.44 2008/09/17 07:24:18 sephe Exp $
+ * $DragonFly: src/sys/net/netisr.c,v 1.45 2008/09/20 04:31:02 sephe Exp $
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -150,7 +150,7 @@ netisr_init(void)
        lwkt_create(netisr_mpsafe_thread ?
                    netmsg_service_loop_mpsafe : netmsg_service_loop,
                    NULL, NULL, &netisr_cpu[i],
        lwkt_create(netisr_mpsafe_thread ?
                    netmsg_service_loop_mpsafe : netmsg_service_loop,
                    NULL, NULL, &netisr_cpu[i],
-                   0, i, "netisr_cpu %d", i);
+                   TDF_NETWORK, i, "netisr_cpu %d", i);
        netmsg_service_port_init(&netisr_cpu[i].td_msgport);
     }
 
        netmsg_service_port_init(&netisr_cpu[i].td_msgport);
     }
 
index 9ee55e9..f6a68a0 100644 (file)
@@ -30,7 +30,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $DragonFly: src/sys/netinet/ip_demux.c,v 1.39 2008/03/29 04:45:47 sephe Exp $
+ * $DragonFly: src/sys/netinet/ip_demux.c,v 1.40 2008/09/20 04:31:02 sephe Exp $
  */
 
 #include "opt_inet.h"
  */
 
 #include "opt_inet.h"
@@ -377,7 +377,8 @@ tcp_thread_init(void)
 
        for (cpu = 0; cpu < ncpus2; cpu++) {
                lwkt_create(tcpmsg_service_loop, NULL, NULL,
 
        for (cpu = 0; cpu < ncpus2; cpu++) {
                lwkt_create(tcpmsg_service_loop, NULL, NULL,
-                       &tcp_thread[cpu], 0, cpu, "tcp_thread %d", cpu);
+                           &tcp_thread[cpu], TDF_NETWORK, cpu,
+                           "tcp_thread %d", cpu);
                netmsg_service_port_init(&tcp_thread[cpu].td_msgport);
        }
 }
                netmsg_service_port_init(&tcp_thread[cpu].td_msgport);
        }
 }
@@ -390,7 +391,7 @@ udp_thread_init(void)
        for (cpu = 0; cpu < ncpus2; cpu++) {
                lwkt_create(udp_mpsafe_thread ?
                            netmsg_service_loop_mpsafe : netmsg_service_loop,
        for (cpu = 0; cpu < ncpus2; cpu++) {
                lwkt_create(udp_mpsafe_thread ?
                            netmsg_service_loop_mpsafe : netmsg_service_loop,
-                           NULL, NULL, &udp_thread[cpu], 0, cpu,
+                           NULL, NULL, &udp_thread[cpu], TDF_NETWORK, cpu,
                            "udp_thread %d", cpu);
                netmsg_service_port_init(&udp_thread[cpu].td_msgport);
        }
                            "udp_thread %d", cpu);
                netmsg_service_port_init(&udp_thread[cpu].td_msgport);
        }
index 143c9bc..1a540d2 100644 (file)
@@ -7,7 +7,7 @@
  * Types which must already be defined when this header is included by
  * userland:   struct md_thread
  * 
  * Types which must already be defined when this header is included by
  * userland:   struct md_thread
  * 
- * $DragonFly: src/sys/sys/thread.h,v 1.96 2008/09/09 07:21:57 dillon Exp $
+ * $DragonFly: src/sys/sys/thread.h,v 1.97 2008/09/20 04:31:02 sephe Exp $
  */
 
 #ifndef _SYS_THREAD_H_
  */
 
 #ifndef _SYS_THREAD_H_
@@ -283,6 +283,7 @@ struct thread {
 #define TDF_EXITING            0x00400000      /* thread exiting */
 #define TDF_USINGFP            0x00800000      /* thread using fp coproc */
 #define TDF_KERNELFP           0x01000000      /* kernel using fp coproc */
 #define TDF_EXITING            0x00400000      /* thread exiting */
 #define TDF_USINGFP            0x00800000      /* thread using fp coproc */
 #define TDF_KERNELFP           0x01000000      /* kernel using fp coproc */
+#define TDF_NETWORK            0x02000000      /* network proto thread */
 
 /*
  * Thread priorities.  Typically only one thread from any given
 
 /*
  * Thread priorities.  Typically only one thread from any given