28 #define foreach_ipsec_if_input_error \ 29 _(RX, "good packets received") \ 30 _(DISABLED, "ipsec packets received on disabled interface") \ 31 _(NO_TUNNEL, "no matching tunnel") \ 35 #define _(sym,string) string, 42 #define _(sym,str) IPSEC_IF_INPUT_ERROR_##sym, 74 b->
error = node->
errors[IPSEC_IF_INPUT_ERROR_SPI_0];
77 IPSEC_PUNT_IP4_SPI_UDP_0 : IPSEC_PUNT_IP4_SPI_0)];
81 b->
error = node->
errors[IPSEC_IF_INPUT_ERROR_NO_TUNNEL];
85 return IPSEC_INPUT_NEXT_PUNT;
95 b->
error = node->
errors[IPSEC_IF_INPUT_ERROR_NO_TUNNEL];
100 b->
error = node->
errors[IPSEC_IF_INPUT_ERROR_NO_TUNNEL];
104 return (IPSEC_INPUT_NEXT_PUNT);
118 u32 n_left_from, *from;
131 u64 n_bytes = 0, n_packets = 0;
132 u32 n_disabled = 0, n_no_tunnel = 0;
134 u32 last_sw_if_index = ~0;
135 u32 last_tunnel_id = ~0;
136 ipsec4_tunnel_key_t last_key4;
137 ipsec6_tunnel_key_t last_key6;
143 clib_memset (&last_key6, 0xff,
sizeof (last_key6));
145 last_key4.as_u64 = ~0;
150 while (n_left_from >= 2)
152 u32 sw_if_index0, sw_if_index1;
157 u16 buf_adv0, buf_adv1;
160 ipsec4_tunnel_key_t key40, key41;
161 ipsec6_tunnel_key_t key60, key61;
163 if (n_left_from >= 4)
188 if (ip40->
protocol == IP_PROTOCOL_UDP)
201 if (ip41->
protocol == IP_PROTOCOL_UDP)
224 key60.spi = esp0->
spi;
226 if (memcmp (&key60, &last_key6,
sizeof (last_key6)) == 0)
228 tid0 = last_tunnel_id;
237 last_tunnel_id = tid0;
252 key40.spi = esp0->
spi;
254 if (key40.as_u64 == last_key4.as_u64)
256 tid0 = last_tunnel_id;
265 last_tunnel_id = tid0;
266 last_key4.as_u64 = key40.as_u64;
289 (drop_counter, thread_index, sw_if_index0, 1, len0);
291 b[0]->
error = node->
errors[IPSEC_IF_INPUT_ERROR_DISABLED];
292 next[0] = IPSEC_INPUT_NEXT_DROP;
306 (rx_counter, thread_index, last_sw_if_index,
310 last_sw_if_index = sw_if_index0;
320 key61.spi = esp1->
spi;
322 if (memcmp (&key61, &last_key6,
sizeof (last_key6)) == 0)
324 tid1 = last_tunnel_id;
333 last_tunnel_id = tid1;
348 key41.spi = esp1->
spi;
350 if (key41.as_u64 == last_key4.as_u64)
352 tid1 = last_tunnel_id;
361 last_tunnel_id = tid1;
362 last_key4.as_u64 = key41.as_u64;
385 (drop_counter, thread_index, sw_if_index1, 1, len1);
387 b[1]->
error = node->
errors[IPSEC_IF_INPUT_ERROR_DISABLED];
388 next[1] = IPSEC_INPUT_NEXT_DROP;
402 (rx_counter, thread_index, last_sw_if_index,
406 last_sw_if_index = sw_if_index1;
415 if (b[0]->
flags & VLIB_BUFFER_IS_TRACED)
419 tr->
spi = clib_host_to_net_u32 (esp0->
spi);
420 tr->
seq = clib_host_to_net_u32 (esp0->
seq);
422 if (b[1]->
flags & VLIB_BUFFER_IS_TRACED)
426 tr->
spi = clib_host_to_net_u32 (esp1->
spi);
427 tr->
seq = clib_host_to_net_u32 (esp1->
seq);
436 while (n_left_from > 0)
446 ipsec4_tunnel_key_t key40;
447 ipsec6_tunnel_key_t key60;
461 if (ip40->
protocol == IP_PROTOCOL_UDP)
483 key60.spi = esp0->
spi;
485 if (memcmp (&key60, &last_key6,
sizeof (last_key6)) == 0)
487 tid0 = last_tunnel_id;
496 last_tunnel_id = tid0;
511 key40.spi = esp0->
spi;
513 if (key40.as_u64 == last_key4.as_u64)
515 tid0 = last_tunnel_id;
524 last_tunnel_id = tid0;
525 last_key4.as_u64 = key40.as_u64;
548 (drop_counter, thread_index, sw_if_index0, 1, len0);
550 b[0]->
error = node->
errors[IPSEC_IF_INPUT_ERROR_DISABLED];
551 next[0] = IPSEC_INPUT_NEXT_DROP;
565 (rx_counter, thread_index, last_sw_if_index,
569 last_sw_if_index = sw_if_index0;
578 if (b[0]->
flags & VLIB_BUFFER_IS_TRACED)
582 tr->
spi = clib_host_to_net_u32 (esp0->
spi);
583 tr->
seq = clib_host_to_net_u32 (esp0->
seq);
597 last_sw_if_index, n_packets, n_bytes);
601 IPSEC_IF_INPUT_ERROR_RX,
619 .name =
"ipsec4-if-input",
620 .vector_size =
sizeof (
u32),
625 .sibling_of =
"ipsec4-input-feature",
638 .name =
"ipsec6-if-input",
639 .vector_size =
sizeof (
u32),
644 .sibling_of =
"ipsec6-input-feature",
ipsec_tunnel_if_t * tunnel_interfaces
static void vlib_increment_combined_counter(vlib_combined_counter_main_t *cm, u32 thread_index, u32 index, u64 n_packets, u64 n_bytes)
Increment a combined counter.
vlib_node_registration_t ipsec4_if_input_node
(constructor) VLIB_REGISTER_NODE (ipsec4_if_input_node)
uword * ipsec4_if_pool_index_by_key
vnet_interface_main_t interface_main
#define foreach_ipsec_if_input_error
#define clib_memcpy_fast(a, b, c)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static u8 * format_ipsec_if_input_trace(u8 *s, va_list *args)
#define VLIB_NODE_FN(node)
vlib_error_t * errors
Vector of errors for this node.
static u16 ipsec_ip4_if_no_tunnel(vlib_node_runtime_t *node, vlib_buffer_t *b, const esp_header_t *esp, const ip4_header_t *ip4, u16 offset)
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
uword * ipsec6_if_pool_index_by_key
vlib_combined_counter_main_t * combined_sw_if_counters
u32 esp4_decrypt_next_index
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static u16 ipsec_ip6_if_no_tunnel(vlib_node_runtime_t *node, vlib_buffer_t *b, const esp_header_t *esp, u16 offset)
u32 node_index
Node index.
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
vlib_punt_reason_t ipsec_punt_reason[IPSEC_PUNT_N_REASONS]
#define VLIB_REGISTER_NODE(x,...)
#define CLIB_PREFETCH(addr, size, type)
static_always_inline void vlib_buffer_enqueue_to_next(vlib_main_t *vm, vlib_node_runtime_t *node, u32 *buffers, u16 *nexts, uword count)
vlib_node_registration_t ipsec6_if_input_node
(constructor) VLIB_REGISTER_NODE (ipsec6_if_input_node)
static char * ipsec_if_input_error_strings[]
vnet_hw_interface_flags_t flags
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static_always_inline void clib_memset_u16(void *p, u16 val, uword count)
template key/value backing page structure
VLIB buffer representation.
static uword ipsec_if_input_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, int is_ip6)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
A collection of combined counters.
#define hash_get_mem(h, key)
u16 flags
Copy of main node flags.
static int ip4_header_bytes(const ip4_header_t *i)
static_always_inline void vlib_get_buffers(vlib_main_t *vm, u32 *bi, vlib_buffer_t **b, int count)
Translate array of buffer indices into buffer pointers.
#define VLIB_NODE_FLAG_TRACE
#define CLIB_CACHE_LINE_BYTES