diff options
author | zec <zec@FreeBSD.org> | 2009-06-11 16:50:49 +0000 |
---|---|---|
committer | zec <zec@FreeBSD.org> | 2009-06-11 16:50:49 +0000 |
commit | 6448f34585833f5bd79b8ee7223fc4b58867529a (patch) | |
tree | 4d69c6a6c06484bb296a8dcfc43aafff98703bb6 /sys/netgraph/ng_iface.c | |
parent | 3b251954d024e0fb3b20bd953f5ec93d95449a43 (diff) | |
download | FreeBSD-src-6448f34585833f5bd79b8ee7223fc4b58867529a.zip FreeBSD-src-6448f34585833f5bd79b8ee7223fc4b58867529a.tar.gz |
Introduce a mechanism for detecting calls from outbound path of the
network stack when reentering the inbound path from netgraph, and
force queueing of mbufs at the outbound netgraph node.
The mechanism relies on two components. First, in netgraph nodes
where outbound path of the network stack calls into netgraph, the
current thread has to be appropriately marked using the new
NG_OUTBOUND_THREAD_REF() macro before proceeding to call further
into the netgraph topology, and unmarked using the
NG_OUTBOUND_THREAD_UNREF() macro before returning to the caller.
Second, netgraph nodes which can potentially reenter the network
stack in the inbound path have to mark their inbound hooks using
NG_HOOK_SET_TO_INBOUND() macro. The netgraph framework will then
detect when there is a danger of a call graph looping back from
outbound to inbound path via netgraph, and defer handing off the
mbufs to the "inbound" node to a worker thread with a clean stack.
In this first pass only the most obvious netgraph nodes have been
updated to ensure no outbound to inbound calls can occur. Nodes
such as ng_ipfw, ng_gif etc. should be further examined whether a
potential for outbound to inbound call looping exists.
This commit changes the layout of struct thread, but due to
__FreeBSD_version number shortage a version bump has been omitted
at this time, nevertheless kernel and modules have to be rebuilt.
Reviewed by: julian, rwatson, bz
Approved by: julian (mentor)
Diffstat (limited to 'sys/netgraph/ng_iface.c')
-rw-r--r-- | sys/netgraph/ng_iface.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c index 385750c..d6e3d64 100644 --- a/sys/netgraph/ng_iface.c +++ b/sys/netgraph/ng_iface.c @@ -482,9 +482,10 @@ ng_iface_send(struct ifnet *ifp, struct mbuf *m, sa_family_t sa) /* 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. */ + NG_OUTBOUND_THREAD_REF(); NG_SEND_DATA_ONLY(error, *get_hook_from_iffam(priv, iffam), m); + NG_OUTBOUND_THREAD_UNREF(); /* Update stats. */ if (error == 0) { @@ -610,6 +611,7 @@ ng_iface_newhook(node_p node, hook_p hook, const char *name) return (EISCONN); *hookptr = hook; NG_HOOK_HI_STACK(hook); + NG_HOOK_SET_TO_INBOUND(hook); return (0); } |