diff --git a/sys/netgraph/netgraph.h b/sys/netgraph/netgraph.h index 02a55f517877..e6b997e4fead 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) \ +/* + * 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), (meta)))) { \ - 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; \ - (meta) = NULL; \ - } 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))) { \ - if (!((error) = ng_address_hook(NULL, item, \ - hook, NULL))) { \ - SAVE_LINE(item); \ - (error) = ng_snd_item((item), 0); \ - } \ - } else { \ - (error) = ENOMEM; \ - } \ - (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 4c681ec78a83..ed083731542a 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 */