26 #define foreach_ah_decrypt_next \ 27 _ (DROP, "error-drop") \ 28 _ (IP4_INPUT, "ip4-input") \ 29 _ (IP6_INPUT, "ip6-input") \ 30 _ (IPSEC_GRE_INPUT, "ipsec-gre-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 _ (REPLAY, "SA replayed packet") 48 #define _(sym,str) AH_DECRYPT_ERROR_##sym, 55 #define _(sym,string) string, 74 s =
format (s,
"ah: integrity %U seq-num %d",
84 u32 n_left_from, *from, next_index, *to_next;
93 while (n_left_from > 0)
99 while (n_left_from > 0 && n_left_to_next > 0)
113 u32 ip_version_traffic_class_and_flow_label = 0;
116 u8 icv_padding_len = 0;
124 next0 = AH_DECRYPT_NEXT_DROP;
136 ip6_ext_header_t *prev =
NULL;
139 ASSERT ((
u8 *) ah0 - (
u8 *) ih6 == ip_hdr_size);
147 seq = clib_host_to_net_u32 (ah0->
seq_no);
162 AH_DECRYPT_ERROR_REPLAY, 1);
178 memcpy (digest, icv, icv_size);
183 ip_version_traffic_class_and_flow_label =
210 AH_DECRYPT_ERROR_INTEG_ERROR,
228 i_b0->
flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
233 next0 = AH_DECRYPT_NEXT_IP4_INPUT;
234 else if (ah0->
nexthdr == IP_PROTOCOL_IPV6)
235 next0 = AH_DECRYPT_NEXT_IP6_INPUT;
239 AH_DECRYPT_ERROR_DECRYPTION_FAILED,
252 next0 = AH_DECRYPT_NEXT_IP6_INPUT;
253 oh6->protocol = nexthdr;
254 oh6->hop_limit = hop_limit;
255 oh6->ip_version_traffic_class_and_flow_label =
256 ip_version_traffic_class_and_flow_label;
257 oh6->payload_length =
267 next0 = AH_DECRYPT_NEXT_IP4_INPUT;
268 oh4->ip_version_and_header_length = 0x45;
269 oh4->fragment_id = 0;
270 oh4->flags_and_fragment_offset = 0;
285 next0 = AH_DECRYPT_NEXT_IPSEC_GRE_INPUT;
292 i_b0->
flags |= VLIB_BUFFER_IS_TRACED;
299 n_left_to_next, i_bi0, next0);
318 .name =
"ah4-decrypt",
319 .vector_size =
sizeof (
u32),
328 #define _(s,n) [AH_DECRYPT_NEXT_##s] = n, 344 .name =
"ah6-decrypt",
345 .vector_size =
sizeof (
u32),
354 #define _(s,n) [AH_DECRYPT_NEXT_##s] = n, static char * ah_decrypt_error_strings[]
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
ipsec_proto_main_integ_alg_t * ipsec_proto_main_integ_algs
static void esp_replay_advance(ipsec_sa_t *sa, u32 seq)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static unsigned int hmac_calc(ipsec_integ_alg_t alg, u8 *key, int key_len, u8 *data, int data_len, u8 *signature, u8 use_esn, u32 seq_hi)
ipsec_integ_alg_t integ_alg
static uword ah_decrypt_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, int is_ip6)
#define VLIB_NODE_FN(node)
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
ipsec_proto_main_t ipsec_proto_main
vlib_node_registration_t ah6_decrypt_node
(constructor) VLIB_REGISTER_NODE (ah6_decrypt_node)
static void esp_replay_advance_esn(ipsec_sa_t *sa, u32 seq)
static u8 * format_ah_decrypt_trace(u8 *s, va_list *args)
static u8 ah_calc_icv_padding_len(u8 icv_size, int is_ipv6)
#define foreach_ah_decrypt_error
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
u16 current_length
Nbytes between current data and the end of this buffer.
static int esp_replay_check_esn(ipsec_sa_t *sa, u32 seq)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
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
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
static int esp_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.
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
u8 * format_ipsec_integ_alg(u8 *s, va_list *args)
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)
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
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.
#define IPSEC_FLAG_IPSEC_GRE_TUNNEL
static u16 ip4_header_checksum(ip4_header_t *i)