summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>2001-03-03 05:52:49 +0000
committerjulian <julian@FreeBSD.org>2001-03-03 05:52:49 +0000
commita3c4c7524d1828d1a8519f0d54b4aa04ee532b36 (patch)
tree6b0f043c984a4b6d3ee5ca4c863869ed73504b94 /sys
parent9a72858cee48fed5669ce1a655e883f2e9ea0458 (diff)
downloadFreeBSD-src-a3c4c7524d1828d1a8519f0d54b4aa04ee532b36.zip
FreeBSD-src-a3c4c7524d1828d1a8519f0d54b4aa04ee532b36.tar.gz
Cleanups to Macros for sending data between netgraph nodes.
Diffstat (limited to 'sys')
-rw-r--r--sys/netgraph/netgraph.h94
-rw-r--r--sys/netgraph/ng_base.c1
2 files changed, 32 insertions, 63 deletions
diff --git a/sys/netgraph/netgraph.h b/sys/netgraph/netgraph.h
index 02a55f5..e6b997e 100644
--- a/sys/netgraph/netgraph.h
+++ b/sys/netgraph/netgraph.h
@@ -837,37 +837,18 @@ _ngi_hook(item_p item, char *file, int line)
/**********************************************************************
* Data macros. Send, manipulate and free.
**********************************************************************/
-/* Send previously unpackeged data and metadata. */
-#define NG_SEND_DATA(error, hook, m, meta) \
- do { \
- item_p item; \
- if ((item = ng_package_data((m), (meta)))) { \
- if (!((error) = ng_address_hook(NULL, item, \
- hook, NULL))) { \
- SAVE_LINE(item); \
- (error) = ng_snd_item((item), 0); \
- } \
- } else { \
- (error) = ENOMEM; \
- } \
- (m) = NULL; \
- (meta) = NULL; \
- } while (0)
-
-/* Send a previously unpackaged mbuf when we have no metadata to send */
-#define NG_SEND_DATA_ONLY(error, hook, m) \
+/*
+ * Assuming the data is already ok, just set the new address and send
+ */
+#define NG_FWD_ITEM_HOOK(error, item, hook) \
do { \
- item_p item; \
- if ((item = ng_package_data((m), NULL))) { \
- if (!((error) = ng_address_hook(NULL, item, \
- hook, NULL))) { \
- SAVE_LINE(item); \
- (error) = ng_snd_item((item), 0); \
- } \
- } else { \
- (error) = ENOMEM; \
+ (error) = \
+ ng_address_hook(NULL, (item), (hook), NULL); \
+ if (error == 0) { \
+ SAVE_LINE(item); \
+ (error) = ng_snd_item((item), 0); \
} \
- (m) = NULL; \
+ (item) = NULL; \
} while (0)
/*
@@ -880,35 +861,40 @@ _ngi_hook(item_p item, char *file, int line)
*/
#define NG_FWD_NEW_DATA(error, item, hook, m) \
do { \
- NGI_M(item) = m; \
- if (!((error) = ng_address_hook(NULL, (item), \
- (hook), NULL))) { \
- SAVE_LINE(item); \
- (error) = ng_snd_item((item), 0); \
+ NGI_M(item) = (m); \
+ (m) = NULL; \
+ NG_FWD_ITEM_HOOK(error, item, hook); \
+ } while (0)
+
+/* Send a previously unpackaged mbuf when we have no metadata to send */
+#define NG_SEND_DATA_ONLY(error, hook, m) \
+ do { \
+ item_p item; \
+ if ((item = ng_package_data((m), NULL))) { \
+ NG_FWD_ITEM_HOOK(error, item, hook); \
+ } else { \
+ (error) = ENOMEM; \
} \
- (item) = NULL; \
(m) = NULL; \
} while (0)
-/*
- * Assuming the data is already ok, just set the new address and send
- */
-#define NG_FWD_ITEM_HOOK(error, item, hook) \
+/* Send previously unpackeged data and metadata. */
+#define NG_SEND_DATA(error, hook, m, meta) \
do { \
- if (!((error) = ng_address_hook(NULL, (item), \
- (hook), NULL))) { \
- SAVE_LINE(item); \
- (error) = ng_snd_item((item), 0); \
+ item_p item; \
+ if ((item = ng_package_data((m), (meta)))) { \
+ NG_FWD_ITEM_HOOK(error, item, hook); \
} else { \
- (error) = ENXIO; \
+ (error) = ENOMEM; \
} \
- (item) = NULL; \
+ (m) = NULL; \
+ (meta) = NULL; \
} while (0)
#define NG_FREE_MSG(msg) \
do { \
if ((msg)) { \
- FREE((msg), M_NETGRAPH_MSG); \
+ FREE((msg), M_NETGRAPH_MSG); \
(msg) = NULL; \
} \
} while (0)
@@ -981,22 +967,6 @@ _ngi_hook(item_p item, char *file, int line)
(msg) = NULL; \
} while (0)
-#define NG_QUEUE_MSG(error, here, msg, path, retaddr) \
- do { \
- item_p item; \
- if ((item = ng_package_msg(msg)) == NULL) { \
- (msg) = NULL; \
- (error) = ENOMEM; \
- break; \
- } \
- if (((error) = ng_address_path((here), (item), \
- (path), (retaddr))) == 0) { \
- SAVE_LINE(item); \
- (error) = ng_snd_item((item), 1); \
- } \
- (msg) = NULL; \
- } while (0)
-
/*
* Redirect the message to the next hop using the given hook.
* ng_retarget_msg() frees the item if there is an error
diff --git a/sys/netgraph/ng_base.c b/sys/netgraph/ng_base.c
index 4c681ec..ed08373 100644
--- a/sys/netgraph/ng_base.c
+++ b/sys/netgraph/ng_base.c
@@ -3602,7 +3602,6 @@ ng_macro_test(item_p item)
NG_SEND_MSG_HOOK(error, node, msg, hook, retaddr);
NG_SEND_MSG_ID(error, node, msg, retaddr, retaddr);
NG_SEND_MSG_PATH(error, node, msg, ".:", retaddr);
- NG_QUEUE_MSG(error, node, msg, ".:", retaddr);
NG_FWD_MSG_HOOK(error, node, item, hook, retaddr);
}
#endif /* TESTING */
OpenPOWER on IntegriCloud