nsim: fix quad-loop packet trace
[vpp.git] / src / plugins / nsim / node.c
index 559147b..57afbd2 100644 (file)
@@ -162,7 +162,7 @@ nsim_inline (vlib_main_t * vm,
          ep->rx_sw_if_index = vnet_buffer (b[0])->sw_if_index[VLIB_RX];
          if (is_cross_connect)
            {
-             ep->tx_sw_if_index =
+             ep->tx_sw_if_index = vnet_buffer (b[0])->sw_if_index[VLIB_TX] =
                (vnet_buffer (b[0])->sw_if_index[VLIB_RX] ==
                 nsm->sw_if_index0) ? nsm->sw_if_index1 : nsm->sw_if_index0;
              ep->output_next_index =
@@ -179,16 +179,15 @@ nsim_inline (vlib_main_t * vm,
          ep->buffer_index = from[0];
          buffered++;
        }
-
       if (is_trace)
        {
-         if (b[1]->flags & VLIB_BUFFER_IS_TRACED)
+         if (b[0]->flags & VLIB_BUFFER_IS_TRACED)
            {
-             nsim_trace_t *t = vlib_add_trace (vm, node, b[1], sizeof (*t));
+             nsim_trace_t *t = vlib_add_trace (vm, node, b[0], sizeof (*t));
              t->expires = expires;
-             t->is_drop = is_drop[1];
-             t->is_lost = b[1]->error == loss_error;
-             t->tx_sw_if_index = (is_drop[1] == 0) ? ep->tx_sw_if_index : 0;
+             t->is_drop = is_drop[0];
+             t->is_lost = b[0]->error == loss_error;
+             t->tx_sw_if_index = (is_drop[0] == 0) ? ep->tx_sw_if_index : 0;
            }
        }
 
@@ -204,7 +203,7 @@ nsim_inline (vlib_main_t * vm,
          ep->rx_sw_if_index = vnet_buffer (b[1])->sw_if_index[VLIB_RX];
          if (is_cross_connect)
            {
-             ep->tx_sw_if_index =
+             ep->tx_sw_if_index = vnet_buffer (b[1])->sw_if_index[VLIB_TX] =
                (vnet_buffer (b[1])->sw_if_index[VLIB_RX] ==
                 nsm->sw_if_index0) ? nsm->sw_if_index1 : nsm->sw_if_index0;
              ep->output_next_index =
@@ -224,15 +223,16 @@ nsim_inline (vlib_main_t * vm,
 
       if (is_trace)
        {
-         if (b[2]->flags & VLIB_BUFFER_IS_TRACED)
+         if (b[1]->flags & VLIB_BUFFER_IS_TRACED)
            {
-             nsim_trace_t *t = vlib_add_trace (vm, node, b[2], sizeof (*t));
+             nsim_trace_t *t = vlib_add_trace (vm, node, b[1], sizeof (*t));
              t->expires = expires;
-             t->is_drop = is_drop[2];
-             t->is_lost = b[2]->error == loss_error;
-             t->tx_sw_if_index = (is_drop[2] == 0) ? ep->tx_sw_if_index : 0;
+             t->is_drop = is_drop[1];
+             t->is_lost = b[1]->error == loss_error;
+             t->tx_sw_if_index = (is_drop[1] == 0) ? ep->tx_sw_if_index : 0;
            }
        }
+
       if (PREDICT_TRUE (is_drop[2] == 0))
        {
          ep = wp->entries + wp->tail;
@@ -245,7 +245,7 @@ nsim_inline (vlib_main_t * vm,
          ep->rx_sw_if_index = vnet_buffer (b[2])->sw_if_index[VLIB_RX];
          if (is_cross_connect)
            {
-             ep->tx_sw_if_index =
+             ep->tx_sw_if_index = vnet_buffer (b[2])->sw_if_index[VLIB_TX] =
                (vnet_buffer (b[2])->sw_if_index[VLIB_RX] ==
                 nsm->sw_if_index0) ? nsm->sw_if_index1 : nsm->sw_if_index0;
              ep->output_next_index =
@@ -274,6 +274,7 @@ nsim_inline (vlib_main_t * vm,
              t->tx_sw_if_index = (is_drop[2] == 0) ? ep->tx_sw_if_index : 0;
            }
        }
+
       if (PREDICT_TRUE (is_drop[3] == 0))
        {
          ep = wp->entries + wp->tail;
@@ -286,7 +287,7 @@ nsim_inline (vlib_main_t * vm,
          ep->rx_sw_if_index = vnet_buffer (b[3])->sw_if_index[VLIB_RX];
          if (is_cross_connect)
            {
-             ep->tx_sw_if_index =
+             ep->tx_sw_if_index = vnet_buffer (b[3])->sw_if_index[VLIB_TX] =
                (vnet_buffer (b[3])->sw_if_index[VLIB_RX] ==
                 nsm->sw_if_index0) ? nsm->sw_if_index1 : nsm->sw_if_index0;
              ep->output_next_index =
@@ -362,7 +363,7 @@ slow_path:
          ep->rx_sw_if_index = vnet_buffer (b[0])->sw_if_index[VLIB_RX];
          if (is_cross_connect)
            {
-             ep->tx_sw_if_index =
+             ep->tx_sw_if_index = vnet_buffer (b[0])->sw_if_index[VLIB_TX] =
                (vnet_buffer (b[0])->sw_if_index[VLIB_RX] ==
                 nsm->sw_if_index0) ? nsm->sw_if_index1 : nsm->sw_if_index0;
              ep->output_next_index =