From owner-p4-projects@FreeBSD.ORG Tue Jun 9 08:35:14 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id BF78B1065674; Tue, 9 Jun 2009 08:35:13 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 79B0010656A6 for ; Tue, 9 Jun 2009 08:35:13 +0000 (UTC) (envelope-from zec@fer.hr) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 685D38FC31 for ; Tue, 9 Jun 2009 08:35:13 +0000 (UTC) (envelope-from zec@fer.hr) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n598ZDso031442 for ; Tue, 9 Jun 2009 08:35:13 GMT (envelope-from zec@fer.hr) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n598ZDhd031438 for perforce@freebsd.org; Tue, 9 Jun 2009 08:35:13 GMT (envelope-from zec@fer.hr) Date: Tue, 9 Jun 2009 08:35:13 GMT Message-Id: <200906090835.n598ZDhd031438@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to zec@fer.hr using -f From: Marko Zec To: Perforce Change Reviews Cc: Subject: PERFORCE change 163871 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jun 2009 08:35:15 -0000 http://perforce.freebsd.org/chv.cgi?CH=163871 Change 163871 by zec@zec_tpx32 on 2009/06/09 08:34:52 When outbound path of the network stack calls into netgraph, depending on the netgraph topology configuration it is possible that the call graph will loop back to inbound network processing path. In such cases we must not permit direct dispatch of netisr handlers in the same call graph. This change introduces a new thread flag, TDF_NODIRNETISR, which prevents direct netisr dispatch when set. It is however mandatory that the caller clears this flag once the call into netgraph is completed. Discussed with: rwatson, julian, bz Affected files ... .. //depot/projects/vimage/src/sys/net/netisr.c#18 edit .. //depot/projects/vimage/src/sys/netgraph/ng_eiface.c#28 edit .. //depot/projects/vimage/src/sys/netgraph/ng_ether.c#26 edit .. //depot/projects/vimage/src/sys/netgraph/ng_iface.c#27 edit .. //depot/projects/vimage/src/sys/sys/proc.h#33 edit Differences ... ==== //depot/projects/vimage/src/sys/net/netisr.c#18 (text+ko) ==== @@ -872,7 +872,7 @@ /* * If direct dispatch is entirely disabled, fall back on queueing. */ - if (!netisr_direct) + if (!netisr_direct || curthread->td_flags & TDF_NODIRNETISR) return (netisr_queue_src(proto, source, m)); KASSERT(proto < NETISR_MAXPROT, ==== //depot/projects/vimage/src/sys/netgraph/ng_eiface.c#28 (text+ko) ==== @@ -261,7 +261,9 @@ * Send packet; if hook is not connected, mbuf will get * freed. */ + curthread->td_flags |= TDF_NODIRNETISR; NG_SEND_DATA_ONLY(error, priv->ether, m); + curthread->td_flags &= ~TDF_NODIRNETISR; /* Update stats */ if (error == 0) ==== //depot/projects/vimage/src/sys/netgraph/ng_ether.c#26 (text+ko) ==== @@ -242,7 +242,9 @@ /* If "lower" hook not connected, let packet continue */ if (priv->lower == NULL) return; + curthread->td_flags |= TDF_NODIRNETISR; NG_SEND_DATA_ONLY(error, priv->lower, *mp); /* sets *mp = NULL */ + curthread->td_flags &= ~TDF_NODIRNETISR; } /* ==== //depot/projects/vimage/src/sys/netgraph/ng_iface.c#27 (text+ko) ==== @@ -482,9 +482,10 @@ /* Copy length before the mbuf gets invalidated. */ len = m->m_pkthdr.len; - /* Send packet. If hook is not connected, - mbuf will get freed. */ + /* Send packet. If hook is not connected, mbuf will get freed. */ + curthread->td_flags |= TDF_NODIRNETISR; NG_SEND_DATA_ONLY(error, *get_hook_from_iffam(priv, iffam), m); + curthread->td_flags &= ~TDF_NODIRNETISR; /* Update stats. */ if (error == 0) { ==== //depot/projects/vimage/src/sys/sys/proc.h#33 (text+ko) ==== @@ -319,7 +319,7 @@ #define TDF_BOUNDARY 0x00000400 /* Thread suspended at user boundary */ #define TDF_ASTPENDING 0x00000800 /* Thread has some asynchronous events. */ #define TDF_TIMOFAIL 0x00001000 /* Timeout from sleep after we were awake. */ -#define TDF_UNUSED2000 0x00002000 /* --available-- */ +#define TDF_NODIRNETISR 0x00002000 /* Do not direct dispatch netisr handlers. */ #define TDF_UPIBLOCKED 0x00004000 /* Thread blocked on user PI mutex. */ #define TDF_NEEDSUSPCHK 0x00008000 /* Thread may need to suspend. */ #define TDF_NEEDRESCHED 0x00010000 /* Thread needs to yield. */