- u32 bi0, bi1, next0, next1, sw_if_index0, sw_if_index1;
- const esp_header_t *esp0, *esp1;
- const ip4_header_t *ip0, *ip1;
- vlib_buffer_t *b0, *b1;
- uword *p0, *p1;
- u32 len0, len1;
- u64 key0, key1;
-
- /* Prefetch next iteration. */
- {
- vlib_buffer_t *p2, *p3;
-
- p2 = vlib_get_buffer (vm, from[2]);
- p3 = vlib_get_buffer (vm, from[3]);
-
- vlib_prefetch_buffer_header (p2, STORE);
- vlib_prefetch_buffer_header (p3, STORE);
-
- CLIB_PREFETCH (p2->data, sizeof (ip0[0]), STORE);
- CLIB_PREFETCH (p3->data, sizeof (ip0[0]), STORE);
- }
-
- bi0 = to_next[0] = from[0];
- bi1 = to_next[1] = from[1];
-
- from += 2;
- n_left_from -= 2;
- to_next += 2;
- n_left_to_next -= 2;
- next0 = next1 = IPSEC_INPUT_NEXT_DROP;
-
- b0 = vlib_get_buffer (vm, bi0);
- b1 = vlib_get_buffer (vm, bi1);
- ip0 = vlib_buffer_get_current (b0);
- ip1 = vlib_buffer_get_current (b1);
- esp0 = (const esp_header_t *) ((u8 *) ip0 + ip4_header_bytes (ip0));
- esp1 = (const esp_header_t *) ((u8 *) ip1 + ip4_header_bytes (ip1));
-
- key0 = (u64) ip0->src_address.as_u32 << 32 | (u64) esp0->spi;
- key1 = (u64) ip1->src_address.as_u32 << 32 | (u64) esp1->spi;
-
- p0 = hash_get (im->ipsec_if_pool_index_by_key, key0);
- p1 = hash_get (im->ipsec_if_pool_index_by_key, key1);
-
- /* stats for the tunnel include all the data after the IP header
- just like a norml IP-IP tunnel */
- vlib_buffer_advance (b0, ip4_header_bytes (ip0));
- vlib_buffer_advance (b1, ip4_header_bytes (ip1));
- len0 = vlib_buffer_length_in_chain (vm, b0);
- len1 = vlib_buffer_length_in_chain (vm, b1);
-
- if (PREDICT_TRUE (NULL != p0))
- {
- const ipsec_tunnel_if_t *t0;
+ esp0 =
+ (esp_header_t *) ((u8 *) ip0 + ip4_header_bytes (ip0) +
+ sizeof (udp_header_t));
+ buf_adv0 = 0;
+ }
+ else
+ {
+ esp0 = (esp_header_t *) ((u8 *) ip0 + ip4_header_bytes (ip0));
+ buf_adv0 = ip4_header_bytes (ip0);
+ }
+ if (ip1->protocol == IP_PROTOCOL_UDP)
+ {
+ esp1 =
+ (esp_header_t *) ((u8 *) ip1 + ip4_header_bytes (ip1) +
+ sizeof (udp_header_t));
+ buf_adv1 = 0;
+ }
+ else
+ {
+ esp1 = (esp_header_t *) ((u8 *) ip1 + ip4_header_bytes (ip1));
+ buf_adv1 = ip4_header_bytes (ip1);
+ }