summaryrefslogtreecommitdiffstats
path: root/src/vlib
diff options
context:
space:
mode:
Diffstat (limited to 'src/vlib')
-rw-r--r--src/vlib/main.c12
-rw-r--r--src/vlib/main.h3
-rw-r--r--src/vlib/node_funcs.h9
3 files changed, 22 insertions, 2 deletions
diff --git a/src/vlib/main.c b/src/vlib/main.c
index 27cbcb0df18..6369f39b09a 100644
--- a/src/vlib/main.c
+++ b/src/vlib/main.c
@@ -1208,13 +1208,21 @@ dispatch_node (vlib_main_t * vm,
}
if (PREDICT_FALSE (vm->dispatch_pcap_enable))
dispatch_pcap_trace (vm, node, frame);
- n = node->function (vm, node, frame);
+
+ if (PREDICT_TRUE (vm->dispatch_wrapper_fn == 0))
+ n = node->function (vm, node, frame);
+ else
+ n = vm->dispatch_wrapper_fn (vm, node, frame);
}
else
{
if (PREDICT_FALSE (vm->dispatch_pcap_enable))
dispatch_pcap_trace (vm, node, frame);
- n = node->function (vm, node, frame);
+
+ if (PREDICT_TRUE (vm->dispatch_wrapper_fn == 0))
+ n = node->function (vm, node, frame);
+ else
+ n = vm->dispatch_wrapper_fn (vm, node, frame);
}
t = clib_cpu_time_now ();
diff --git a/src/vlib/main.h b/src/vlib/main.h
index 477211d65ce..5f78b7941a4 100644
--- a/src/vlib/main.h
+++ b/src/vlib/main.h
@@ -149,6 +149,9 @@ typedef struct vlib_main_t
/* Main loop hw / sw performance counters */
vlib_node_runtime_perf_callback_set_t vlib_node_runtime_perf_callbacks;
+ /* dispatch wrapper function */
+ vlib_node_function_t *dispatch_wrapper_fn;
+
/* Every so often we switch to the next counter. */
#define VLIB_LOG2_MAIN_LOOPS_PER_STATS_UPDATE 7
diff --git a/src/vlib/node_funcs.h b/src/vlib/node_funcs.h
index 33bdc795816..b33f4960a90 100644
--- a/src/vlib/node_funcs.h
+++ b/src/vlib/node_funcs.h
@@ -1247,6 +1247,15 @@ vlib_node_increment_counter (vlib_main_t * vm, u32 node_index,
u32 vlib_process_create (vlib_main_t * vm, char *name,
vlib_node_function_t * f, u32 log2_n_stack_bytes);
+always_inline int
+vlib_node_set_dispatch_wrapper (vlib_main_t *vm, vlib_node_function_t *fn)
+{
+ if (fn && vm->dispatch_wrapper_fn)
+ return 1;
+ vm->dispatch_wrapper_fn = fn;
+ return 0;
+}
+
#endif /* included_vlib_node_funcs_h */
/*