27 #define foreach_ah_decrypt_next \ 28 _ (DROP, "error-drop") \ 29 _ (IP4_INPUT, "ip4-input") \ 30 _ (IP6_INPUT, "ip6-input") \ 31 _ (IPSEC_GRE_INPUT, "ipsec-gre-input") 33 #define _(v, s) AH_DECRYPT_NEXT_##v, 41 #define foreach_ah_decrypt_error \ 42 _ (RX_PKTS, "AH pkts received") \ 43 _ (DECRYPTION_FAILED, "AH decryption failed") \ 44 _ (INTEG_ERROR, "Integrity check failed") \ 45 _ (REPLAY, "SA replayed packet") 49 #define _(sym,str) AH_DECRYPT_ERROR_##sym, 56 #define _(sym,string) string, 75 s =
format (s,
"ah: integrity %U seq-num %d",
85 u32 n_left_from, *from, next_index, *to_next, thread_index;
94 while (n_left_from > 0)
100 while (n_left_from > 0 && n_left_to_next > 0)
114 u32 ip_version_traffic_class_and_flow_label = 0;
117 u8 icv_padding_len = 0;
125 next0 = AH_DECRYPT_NEXT_DROP;
136 thread_index, sa_index0);
140 ip6_ext_header_t *prev =
NULL;
143 ASSERT ((
u8 *) ah0 - (
u8 *) ih6 == ip_hdr_size);
151 seq = clib_host_to_net_u32 (ah0->
seq_no);
156 i_b0->
error = node->
errors[AH_DECRYPT_ERROR_REPLAY];
170 memcpy (digest, icv, icv_size);
175 ip_version_traffic_class_and_flow_label =
199 i_b0->
error = node->
errors[AH_DECRYPT_ERROR_INTEG_ERROR];
209 i_b0->
flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
214 next0 = AH_DECRYPT_NEXT_IP4_INPUT;
215 else if (ah0->
nexthdr == IP_PROTOCOL_IPV6)
216 next0 = AH_DECRYPT_NEXT_IP6_INPUT;
220 node->
errors[AH_DECRYPT_ERROR_DECRYPTION_FAILED];
232 next0 = AH_DECRYPT_NEXT_IP6_INPUT;
233 oh6->protocol = nexthdr;
234 oh6->hop_limit = hop_limit;
235 oh6->ip_version_traffic_class_and_flow_label =
236 ip_version_traffic_class_and_flow_label;
237 oh6->payload_length =
247 next0 = AH_DECRYPT_NEXT_IP4_INPUT;
248 oh4->ip_version_and_header_length = 0x45;
249 oh4->fragment_id = 0;
250 oh4->flags_and_fragment_offset = 0;
263 next0 = AH_DECRYPT_NEXT_IPSEC_GRE_INPUT;
269 i_b0->
flags |= VLIB_BUFFER_IS_TRACED;
276 n_left_to_next, i_bi0, next0);
295 .name =
"ah4-decrypt",
296 .vector_size =
sizeof (
u32),
305 #define _(s,n) [AH_DECRYPT_NEXT_##s] = n, 321 .name =
"ah6-decrypt",
322 .vector_size =
sizeof (
u32),
331 #define _(s,n) [AH_DECRYPT_NEXT_##s] = n, 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)
static int ipsec_sa_anti_replay_check(ipsec_sa_t *sa, u32 *seqp)
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.
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.
static void ipsec_sa_anti_replay_advance(ipsec_sa_t *sa, u32 *seqp)
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
vlib_node_registration_t ah6_decrypt_node
(constructor) VLIB_REGISTER_NODE (ah6_decrypt_node)
static u8 * format_ah_decrypt_trace(u8 *s, va_list *args)
static u8 ah_calc_icv_padding_len(u8 icv_size, int is_ipv6)
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 unsigned int hmac_calc(vlib_main_t *vm, ipsec_sa_t *sa, u8 *data, int data_len, u8 *signature)
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 vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
#define VLIB_REGISTER_NODE(x,...)
vlib_node_registration_t ah4_decrypt_node
(constructor) VLIB_REGISTER_NODE (ah4_decrypt_node)
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
#define foreach_ah_decrypt_next
vlib_combined_counter_main_t ipsec_sa_counters
SA packet & bytes counters.
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
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)
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#define ip6_ext_header_find_t(i, p, m, t)
static int ip4_header_bytes(const ip4_header_t *i)
ipsec_integ_alg_t integ_alg
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
static u16 ip4_header_checksum(ip4_header_t *i)