aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2024-11-21 18:55:35 +0000
committerMark Johnston <markj@FreeBSD.org>2024-11-21 18:55:35 +0000
commit46f38a6dedb1b474f04b7c2b072825fda5d7bd5a (patch)
treeb1d308073a77b88c9c1a21efc2a877c18f8921a8
parent30cafaa9611d82525ab32ec32304b93835a5124a (diff)
downloadsrc-46f38a6dedb1b474f04b7c2b072825fda5d7bd5a.tar.gz
src-46f38a6dedb1b474f04b7c2b072825fda5d7bd5a.zip
netgraph: Exit the net epoch to handle control messages
In general, in the direct dispatch case netgraph only enters the net epoch to send data messages, but this was inconsistent with the netgraph thread, which also entered the net epoch to send fn and fn2 messages to nodes. Some handlers, e.g., ng_bridge_newhook(), may sleep, and so cannot be called in epoch context; the netgraph tests occasionally panic due to this problem. Make ngthread() consistent with the direct dispatch path. Discussed with: afedorov (in D44615) MFC after: 2 weeks Sponsored by: Klara, Inc.
-rw-r--r--sys/netgraph/ng_base.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c
index 5bff0663e03e..77c7cb0d3c00 100644
--- a/sys/netgraph/ng_base.c
+++ b/sys/netgraph/ng_base.c
@@ -3440,10 +3440,13 @@ ngthread(void *arg)
NG_QUEUE_UNLOCK(&node->nd_input_queue);
NGI_GET_NODE(item, node); /* zaps stored node */
- if ((item->el_flags & NGQF_TYPE) == NGQF_MESG) {
+ if ((item->el_flags & NGQF_TYPE) != NGQF_DATA) {
/*
- * NGQF_MESG items should never be processed in
- * NET_EPOCH context. So, temporary exit from EPOCH.
+ * NGQF_MESG, NGQF_FN and NGQF_FN2 items
+ * should never be processed in
+ * NET_EPOCH context; they generally
+ * require heavier synchronization and
+ * may sleep. So, temporarily exit.
*/
NET_EPOCH_EXIT(et);
ng_apply_item(node, item, rw);