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, 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") \ 46 _(NOT_IP, "Not IP packet (dropped)") 51 #define _(sym,str) AH_DECRYPT_ERROR_##sym, 58 #define _(sym,string) string, 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)
111 u8 transport_ip6 = 0;
122 next0 = AH_DECRYPT_NEXT_DROP;
134 seq = clib_host_to_net_u32 (ah0->
seq_no);
149 AH_DECRYPT_ERROR_REPLAY, 1);
162 memset (sig, 0,
sizeof (sig));
163 memset (digest, 0,
sizeof (digest));
167 memcpy (digest, icv, icv_size);
168 memset (icv, 0, icv_size);
186 AH_DECRYPT_ERROR_INTEG_ERROR,
205 i_b0->
flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
222 AH_DECRYPT_ERROR_NOT_IP,
232 next0 = AH_DECRYPT_NEXT_IP4_INPUT;
233 else if (ah0->
nexthdr == IP_PROTOCOL_IPV6)
234 next0 = AH_DECRYPT_NEXT_IP6_INPUT;
239 AH_DECRYPT_ERROR_DECRYPTION_FAILED,
256 next0 = AH_DECRYPT_NEXT_IP6_INPUT;
258 oh6->payload_length =
268 next0 = AH_DECRYPT_NEXT_IP4_INPUT;
269 oh4->ip_version_and_header_length = 0x45;
270 oh4->fragment_id = 0;
271 oh4->flags_and_fragment_offset = 0;
286 next0 = AH_DECRYPT_NEXT_IPSEC_GRE_INPUT;
293 i_b0->
flags |= VLIB_BUFFER_IS_TRACED;
299 n_left_to_next, i_bi0, next0);
304 AH_DECRYPT_ERROR_RX_PKTS,
314 .name =
"ah-decrypt",
315 .vector_size =
sizeof (
u32),
324 #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)
static int ip4_header_bytes(ip4_header_t *i)
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 vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
static void esp_replay_advance_esn(ipsec_sa_t *sa, u32 seq)
static uword ah_decrypt_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
vlib_node_registration_t ah_decrypt_node
(constructor) VLIB_REGISTER_NODE (ah_decrypt_node)
static u8 * format_ah_decrypt_trace(u8 *s, va_list *args)
#define foreach_ah_decrypt_error
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
#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.
#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,...)
#define clib_warning(format, args...)
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.
ipsec_proto_main_t ipsec_proto_main
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)