- sw_if_index0 = vnet_buffer(b0)->sw_if_index[VLIB_RX];
- next0 = msm->cached_next_index;
- sw_if_index1 = vnet_buffer(b1)->sw_if_index[VLIB_RX];
- next1 = msm->cached_next_index;
-
- if (PREDICT_FALSE (msm->cached_sw_if_index != sw_if_index0))
- {
- p0 = hash_get (msm->next_node_index_by_sw_if_index, sw_if_index0);
- if (p0 == 0)
- {
- vnet_hw_interface_t *hw0;
-
- hw0 = vnet_get_sup_hw_interface (msm->vnet_main,
- sw_if_index0);
-
- next0 = vlib_node_add_next (msm->vlib_main,
- mac_swap_node.index,
- hw0->output_node_index);
- hash_set (msm->next_node_index_by_sw_if_index,
- sw_if_index0, next0);
- }
- else
- next0 = p0[0];
- msm->cached_sw_if_index = sw_if_index0;
- msm->cached_next_index = next0;
- next1 = next0;
- }
- if (PREDICT_FALSE (msm->cached_sw_if_index != sw_if_index1))
- {
- p1 = hash_get (msm->next_node_index_by_sw_if_index, sw_if_index1);
- if (p1 == 0)
- {
- vnet_hw_interface_t *hw1;
-
- hw1 = vnet_get_sup_hw_interface (msm->vnet_main,
- sw_if_index1);
-
- next1 = vlib_node_add_next (msm->vlib_main,
- mac_swap_node.index,
- hw1->output_node_index);
- hash_set (msm->next_node_index_by_sw_if_index,
- sw_if_index1, next1);
- }
- else
- next1 = p1[0];
- msm->cached_sw_if_index = sw_if_index1;
- msm->cached_next_index = next1;
- }
-
- em->counters[node_counter_base_index + MAC_SWAP_ERROR_SWAPS] += 2;
-
- /* reset buffer so we always point at the MAC hdr */
- vlib_buffer_reset (b0);
- vlib_buffer_reset (b1);
- h0 = vlib_buffer_get_current (b0);
- h1 = vlib_buffer_get_current (b1);
-
- /* Swap 2 x src and dst mac addresses using 8-byte load/stores */
- tmp0a = clib_net_to_host_u64(((u64 *)(h0->dst_address))[0]);
- tmp1a = clib_net_to_host_u64(((u64 *)(h1->dst_address))[0]);
- tmp0b = clib_net_to_host_u64(((u64 *)(h0->src_address))[0]);
- tmp1b = clib_net_to_host_u64(((u64 *)(h1->src_address))[0]);
- ((u64 *)(h0->dst_address))[0] = clib_host_to_net_u64(tmp0b);
- ((u64 *)(h1->dst_address))[0] = clib_host_to_net_u64(tmp1b);
- /* Move the ethertype from "b" to "a" */
- tmp0a &= ~(0xFFFF);
- tmp1a &= ~(0xFFFF);
- tmp0a |= tmp0b & 0xFFFF;
- ((u64 *)(h0->src_address))[0] = clib_host_to_net_u64(tmp0a);
- tmp1a |= tmp1b & 0xFFFF;
- ((u64 *)(h1->src_address))[0] = clib_host_to_net_u64(tmp1a);
-
- if (PREDICT_FALSE((node->flags & VLIB_NODE_FLAG_TRACE)))
- {
- if (b0->flags & VLIB_BUFFER_IS_TRACED)
- {
- swap_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t));
- clib_memcpy (t->src, h0->src_address, 6);
- clib_memcpy (t->dst, h0->dst_address, 6);
- t->sw_if_index = sw_if_index0;
- t->next_index = next0;
- }
- if (b1->flags & VLIB_BUFFER_IS_TRACED)
- {
- swap_trace_t *t = vlib_add_trace (vm, node, b1, sizeof (*t));
- clib_memcpy (t->src, h1->src_address, 6);
- clib_memcpy (t->dst, h1->dst_address, 6);
- t->sw_if_index = sw_if_index1;
- t->next_index = next1;
- }
- }
-
- vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
- to_next, n_left_to_next,
- bi0, bi1, next0, next1);
- }
-
+ sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
+ next0 = msm->cached_next_index;
+ sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_RX];
+ next1 = msm->cached_next_index;
+
+ if (PREDICT_FALSE (msm->cached_sw_if_index != sw_if_index0))
+ {
+ p0 =
+ hash_get (msm->next_node_index_by_sw_if_index, sw_if_index0);
+ if (p0 == 0)
+ {
+ vnet_hw_interface_t *hw0;
+
+ hw0 = vnet_get_sup_hw_interface (msm->vnet_main,
+ sw_if_index0);
+
+ next0 = vlib_node_add_next (msm->vlib_main,
+ mac_swap_node.index,
+ hw0->output_node_index);
+ hash_set (msm->next_node_index_by_sw_if_index,
+ sw_if_index0, next0);
+ }
+ else
+ next0 = p0[0];
+ msm->cached_sw_if_index = sw_if_index0;
+ msm->cached_next_index = next0;
+ next1 = next0;
+ }
+ if (PREDICT_FALSE (msm->cached_sw_if_index != sw_if_index1))
+ {
+ p1 =
+ hash_get (msm->next_node_index_by_sw_if_index, sw_if_index1);
+ if (p1 == 0)
+ {
+ vnet_hw_interface_t *hw1;
+
+ hw1 = vnet_get_sup_hw_interface (msm->vnet_main,
+ sw_if_index1);
+
+ next1 = vlib_node_add_next (msm->vlib_main,
+ mac_swap_node.index,
+ hw1->output_node_index);
+ hash_set (msm->next_node_index_by_sw_if_index,
+ sw_if_index1, next1);
+ }
+ else
+ next1 = p1[0];
+ msm->cached_sw_if_index = sw_if_index1;
+ msm->cached_next_index = next1;
+ }
+
+ em->counters[node_counter_base_index + MAC_SWAP_ERROR_SWAPS] += 2;
+
+ /* reset buffer so we always point at the MAC hdr */
+ vlib_buffer_reset (b0);
+ vlib_buffer_reset (b1);
+ h0 = vlib_buffer_get_current (b0);
+ h1 = vlib_buffer_get_current (b1);
+
+ /* Swap 2 x src and dst mac addresses using 8-byte load/stores */
+ tmp0a = clib_net_to_host_u64 (((u64 *) (h0->dst_address))[0]);
+ tmp1a = clib_net_to_host_u64 (((u64 *) (h1->dst_address))[0]);
+ tmp0b = clib_net_to_host_u64 (((u64 *) (h0->src_address))[0]);
+ tmp1b = clib_net_to_host_u64 (((u64 *) (h1->src_address))[0]);
+ ((u64 *) (h0->dst_address))[0] = clib_host_to_net_u64 (tmp0b);
+ ((u64 *) (h1->dst_address))[0] = clib_host_to_net_u64 (tmp1b);
+ /* Move the ethertype from "b" to "a" */
+ tmp0a &= ~(0xFFFF);
+ tmp1a &= ~(0xFFFF);
+ tmp0a |= tmp0b & 0xFFFF;
+ ((u64 *) (h0->src_address))[0] = clib_host_to_net_u64 (tmp0a);
+ tmp1a |= tmp1b & 0xFFFF;
+ ((u64 *) (h1->src_address))[0] = clib_host_to_net_u64 (tmp1a);
+
+ if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)))
+ {
+ if (b0->flags & VLIB_BUFFER_IS_TRACED)
+ {
+ swap_trace_t *t =
+ vlib_add_trace (vm, node, b0, sizeof (*t));
+ clib_memcpy (t->src, h0->src_address, 6);
+ clib_memcpy (t->dst, h0->dst_address, 6);
+ t->sw_if_index = sw_if_index0;
+ t->next_index = next0;
+ }
+ if (b1->flags & VLIB_BUFFER_IS_TRACED)
+ {
+ swap_trace_t *t =
+ vlib_add_trace (vm, node, b1, sizeof (*t));
+ clib_memcpy (t->src, h1->src_address, 6);
+ clib_memcpy (t->dst, h1->dst_address, 6);
+ t->sw_if_index = sw_if_index1;
+ t->next_index = next1;
+ }
+ }
+
+ vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
+ to_next, n_left_to_next,
+ bi0, bi1, next0, next1);
+ }
+