PERFORCE change 163871 for review
Marko Zec
zec at FreeBSD.org
Tue Jun 9 08:35:15 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=163871
Change 163871 by zec at 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. */
More information about the p4-projects
mailing list