summaryrefslogtreecommitdiffstats
path: root/sys/netgraph/netgraph.h
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2005-07-05 17:35:20 +0000
committerglebius <glebius@FreeBSD.org>2005-07-05 17:35:20 +0000
commitfcbdfd0eb4f509af7f2a382daaf2c52ce49704c8 (patch)
tree7c65a2a332dab7cec59b3eb4bdcbf403ceaac133 /sys/netgraph/netgraph.h
parent9c552f7c01059c885fb0604e8fc082ce51f3228a (diff)
downloadFreeBSD-src-fcbdfd0eb4f509af7f2a382daaf2c52ce49704c8.zip
FreeBSD-src-fcbdfd0eb4f509af7f2a382daaf2c52ce49704c8.tar.gz
In the splnet times, netgraph was functional and synchronous. Nowadays,
an item may be queued and processed later. While this is OK for mbufs, this is a problem for control messages. In the framework: - Add optional callback function pointer to an item. When item gets applied the callback is executed from ng_apply_item(). - Add new flag NG_PROGRESS. If this flag is supplied, then return EINPROGRESS instead of 0 in case if item failed to deliver synchronously and was queued. - Honor NG_PROGRESS in ng_snd_item(). In ng_socket: - When userland sends control message add callback to the item. - If ng_snd_item() returns EINPROGRESS, then sleep. This change fixes possible races in ngctl(8) scripts. Reviewed by: julian Approved by: re (scottl)
Diffstat (limited to 'sys/netgraph/netgraph.h')
-rw-r--r--sys/netgraph/netgraph.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/netgraph/netgraph.h b/sys/netgraph/netgraph.h
index a963fc8..4304ced 100644
--- a/sys/netgraph/netgraph.h
+++ b/sys/netgraph/netgraph.h
@@ -580,6 +580,7 @@ _ng_node_foreach_hook(node_p node, ng_fn_eachhook *fn, void *arg,
*
*/
typedef void ng_item_fn(node_p node, hook_p hook, void *arg1, int arg2);
+typedef void ng_apply_t(void *context, int error);
struct ng_item {
u_long el_flags;
item_p el_next;
@@ -597,6 +598,12 @@ struct ng_item {
int fn_arg2;
} fn;
} body;
+ /*
+ * Optional callback called when item is being applied,
+ * and its context.
+ */
+ ng_apply_t *apply;
+ void *context;
#ifdef NETGRAPH_DEBUG /*----------------------------------------------*/
char *lastfile;
int lastline;
@@ -1084,6 +1091,7 @@ int ng_callout(struct callout *c, node_p node, hook_p hook, int ticks,
#define NG_NOFLAGS 0x00000000 /* no special options */
#define NG_QUEUE 0x00000001 /* enqueue item, don't dispatch */
#define NG_WAITOK 0x00000002 /* use M_WAITOK, etc. */
+#define NG_PROGRESS 0x00000004 /* return EINPROGRESS if queued */
/*
* prototypes the user should DEFINITELY not use directly
OpenPOWER on IntegriCloud