+ if (t->hw_if_index != ~0)
+ {
+ vnet_hw_interface_t *hi;
+
+ vnet_buffer (b0)->ipsec.flags = 0;
+ hi = vnet_get_hw_interface (vnm, t->hw_if_index);
+ sw_if_index0 = hi->sw_if_index;
+ vnet_buffer (b0)->sw_if_index[VLIB_RX] = sw_if_index0;
+
+ if (PREDICT_TRUE (sw_if_index0 == last_sw_if_index))
+ {
+ n_packets++;
+ n_bytes += vlib_buffer_length_in_chain (vm, b0);
+ }
+ else
+ {
+ sa0 = pool_elt_at_index (im->sad, t->input_sa_index);
+ icv_len =
+ em->ipsec_proto_main_integ_algs[sa0->
+ integ_alg].trunc_size;
+
+ /* length = packet length - ESP/tunnel overhead */
+ n_bytes -= n_packets * (sizeof (ip4_header_t) +
+ sizeof (esp_header_t) +
+ sizeof (esp_footer_t) +
+ 16 /* aes-cbc IV */ + icv_len);
+
+ if (last_t)
+ {
+ vlib_increment_combined_counter
+ (vim->combined_sw_if_counters
+ + VNET_INTERFACE_COUNTER_RX,
+ thread_index, sw_if_index0, n_packets, n_bytes);
+ }
+
+ last_sw_if_index = sw_if_index0;
+ last_t = t;
+ n_packets = 1;
+ n_bytes = vlib_buffer_length_in_chain (vm, b0);
+ }
+ }
+ else
+ {
+ vnet_buffer (b0)->ipsec.flags = IPSEC_FLAG_IPSEC_GRE_TUNNEL;
+ }
+