summaryrefslogtreecommitdiffstats
path: root/src/plugins/nsim/nsim_input.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2018-12-06 10:20:14 -0500
committerFlorin Coras <florin.coras@gmail.com>2018-12-06 18:28:47 +0000
commit10c5ff143a86d15e78cb1f8625eb0ab8bf72b6ce (patch)
tree00afabf7ca2ccd4042b2315b38fa6fb1bf5902c2 /src/plugins/nsim/nsim_input.c
parent995ff06fb73a2d1ac8472977cf3089d763f17d33 (diff)
nsim: add packet loss simulation, docs
Change-Id: Ic9747541aad8148ebf7d520b525b99c4cc3961f3 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/plugins/nsim/nsim_input.c')
-rw-r--r--src/plugins/nsim/nsim_input.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/plugins/nsim/nsim_input.c b/src/plugins/nsim/nsim_input.c
index 66bd8d10954..2e328a58bf3 100644
--- a/src/plugins/nsim/nsim_input.c
+++ b/src/plugins/nsim/nsim_input.c
@@ -76,6 +76,7 @@ nsim_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
u32 my_thread_index = vm->thread_index;
u32 *my_buffer_cache = nsm->buffer_indices_by_thread[my_thread_index];
nsim_wheel_t *wp = nsm->wheel_by_thread[my_thread_index];
+ u32 n_trace = vlib_get_trace_count (vm, node);
f64 now = vlib_time_now (vm);
uword n_rx_packets = 0;
vlib_buffer_t *b0;
@@ -153,6 +154,18 @@ nsim_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
b0->current_data = 0;
b0->current_length = ep->current_length;
+ VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b0);
+
+ if (PREDICT_FALSE (n_trace))
+ {
+ nsim_tx_trace_t *t0;
+ vlib_trace_buffer (vm, node, next_index, b0,
+ 0 /* follow_chain */ );
+ t0 = vlib_add_trace (vm, node, b0, sizeof (*t0));
+ t0->expired = ep->tx_time;
+ t0->tx_sw_if_index = ep->tx_sw_if_index;
+ }
+
/* Copy data from the ring */
clib_memcpy_fast (b0->data, ep->data, ep->current_length);
b0->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;