27 #define foreach_ah_decrypt_next \ 28 _ (DROP, "error-drop") \ 29 _ (IP4_INPUT, "ip4-input") \ 30 _ (IP6_INPUT, "ip6-input") 32 #define _(v, s) AH_DECRYPT_NEXT_##v, 40 #define foreach_ah_decrypt_error \ 41 _ (RX_PKTS, "AH pkts received") \ 42 _ (DECRYPTION_FAILED, "AH decryption failed") \ 43 _ (INTEG_ERROR, "Integrity check failed") \ 44 _ (NO_TAIL_SPACE, "not enough buffer tail space (dropped)") \ 45 _ (DROP_FRAGMENTS, "IP fragments drop") \ 46 _ (REPLAY, "SA replayed packet") 50 #define _(sym,str) AH_DECRYPT_ERROR_##sym, 57 #define _(sym,string) string, 76 s =
format (s,
"ah: integrity %U seq-num %d",
121 ASSERT (op - ops < n_ops);
123 if (op->
status != VNET_CRYPTO_OP_STATUS_COMPLETED)
126 b[bi]->
error = node->
errors[AH_DECRYPT_ERROR_INTEG_ERROR];
127 nexts[bi] = AH_DECRYPT_NEXT_DROP;
150 u32 current_sa_index = ~0, current_sa_bytes = 0, current_sa_pkts = 0;
163 if (
vnet_buffer (b[0])->ipsec.sad_index != current_sa_index)
165 if (current_sa_index != ~0)
170 current_sa_index =
vnet_buffer (b[0])->ipsec.sad_index;
173 current_sa_bytes = current_sa_pkts = 0;
175 thread_index, current_sa_index);
186 ip6_ext_header_t *prev =
NULL;
195 b[0]->
error = node->
errors[AH_DECRYPT_ERROR_DROP_FRAGMENTS];
196 next[0] = AH_DECRYPT_NEXT_DROP;
203 pd->
seq = clib_host_to_net_u32 (ah0->
seq_no);
208 b[0]->
error = node->
errors[AH_DECRYPT_ERROR_REPLAY];
209 next[0] = AH_DECRYPT_NEXT_DROP;
214 current_sa_pkts += 1;
222 + sizeof (
u32) > buffer_data_size))
224 b[0]->
error = node->
errors[AH_DECRYPT_ERROR_NO_TAIL_SPACE];
225 next[0] = AH_DECRYPT_NEXT_DROP;
233 op->
src = (
u8 *) ih4;
240 if (ipsec_sa_is_set_USE_ESN (sa0))
242 u32 seq_hi = clib_host_to_net_u32 (sa0->
seq_hi);
244 op->
len +=
sizeof (seq_hi);
289 current_sa_index, current_sa_pkts,
309 b[0]->
error = node->
errors[AH_DECRYPT_ERROR_REPLAY];
310 next[0] = AH_DECRYPT_NEXT_DROP;
319 b[0]->
flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
324 next[0] = AH_DECRYPT_NEXT_IP4_INPUT;
326 next[0] = AH_DECRYPT_NEXT_IP6_INPUT;
329 b[0]->
error = node->
errors[AH_DECRYPT_ERROR_DECRYPTION_FAILED];
330 next[0] = AH_DECRYPT_NEXT_DROP;
347 next[0] = AH_DECRYPT_NEXT_IP6_INPUT;
367 next[0] = AH_DECRYPT_NEXT_IP4_INPUT;
413 .name =
"ah4-decrypt",
414 .vector_size =
sizeof (
u32),
423 #define _(s,n) [AH_DECRYPT_NEXT_##s] = n, 439 .name =
"ah6-decrypt",
440 .vector_size =
sizeof (
u32),
449 #define _(s,n) [AH_DECRYPT_NEXT_##s] = n, u32 vnet_crypto_process_ops(vlib_main_t *vm, vnet_crypto_op_t ops[], u32 n_ops)
static char * ah_decrypt_error_strings[]
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
ipsec_per_thread_data_t * ptd
vnet_crypto_op_t * integ_ops
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.
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
#define vec_add2_aligned(V, P, N, A)
Add N elements to end of vector V, return pointer to new elements in P.
ipsec_integ_alg_t integ_alg
u16 current_length
Nbytes between current data and the end of this buffer.
static uword ah_decrypt_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, int is_ip6)
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
#define VLIB_NODE_FN(node)
vlib_error_t * errors
Vector of errors for this node.
vnet_crypto_op_id_t integ_op_id
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static int ip4_is_fragment(const ip4_header_t *i)
#define clib_memcpy(d, s, n)
vlib_node_registration_t ah6_decrypt_node
(constructor) VLIB_REGISTER_NODE (ah6_decrypt_node)
#define static_always_inline
u32 ip_version_traffic_class_and_flow_label
static_always_inline void vnet_crypto_op_init(vnet_crypto_op_t *op, vnet_crypto_op_id_t type)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
static u8 * format_ah_decrypt_trace(u8 *s, va_list *args)
static u8 ah_calc_icv_padding_len(u8 icv_size, int is_ipv6)
vl_api_fib_path_type_t type
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define foreach_ah_decrypt_error
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static void ipsec_sa_anti_replay_advance(ipsec_sa_t *sa, u32 seq)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static void vlib_prefetch_combined_counter(const vlib_combined_counter_main_t *cm, u32 thread_index, u32 index)
Pre-fetch a per-thread combined counter for the given object index.
u32 node_index
Node index.
#define VNET_CRYPTO_OP_FLAG_HMAC_CHECK
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
static_always_inline u32 vlib_buffer_get_default_data_size(vlib_main_t *vm)
#define VLIB_REGISTER_NODE(x,...)
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 ah4_decrypt_node
(constructor) VLIB_REGISTER_NODE (ah4_decrypt_node)
static_always_inline void ah_process_ops(vlib_main_t *vm, vlib_node_runtime_t *node, vnet_crypto_op_t *ops, vlib_buffer_t *b[], u16 *nexts)
#define foreach_ah_decrypt_next
vlib_combined_counter_main_t ipsec_sa_counters
SA packet & bytes counters.
static int ipsec_sa_anti_replay_check(ipsec_sa_t *sa, u32 seq)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
vnet_crypto_key_index_t integ_key_index
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)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
vnet_crypto_op_status_t status
#define ip6_ext_header_find_t(i, p, m, t)
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 CLIB_CACHE_LINE_BYTES
ipsec_integ_alg_t integ_alg
static u16 ip4_header_checksum(ip4_header_t *i)