|
FD.io VPP
v21.10.1-2-g0a485f517
Vector Packet Processing
|
Go to the documentation of this file.
27 #define foreach_ah_encrypt_next \
28 _ (DROP, "error-drop") \
29 _ (HANDOFF, "handoff") \
30 _ (INTERFACE_OUTPUT, "interface-output")
33 #define _(v, s) AH_ENCRYPT_NEXT_##v,
41 #define foreach_ah_encrypt_error \
42 _ (RX_PKTS, "AH pkts received") \
43 _ (CRYPTO_ENGINE_ERROR, "crypto engine error (packet dropped)") \
44 _ (SEQ_CYCLED, "sequence number cycled (packet dropped)")
48 #define _(sym,str) AH_ENCRYPT_ERROR_##sym,
55 #define _(sym,string) string,
77 s =
format (s,
"ah: sa-index %d spi %u (0x%08x) seq %u:%u integrity %U",
99 if (op->
status != VNET_CRYPTO_OP_STATUS_COMPLETED)
102 b[bi]->
error =
node->errors[AH_ENCRYPT_ERROR_CRYPTO_ENGINE_ERROR];
103 nexts[bi] = AH_ENCRYPT_NEXT_DROP;
148 ip4_and_ah_header_t *ih0, *oh0 = 0;
149 ip6_and_ah_header_t *ih6_0, *oh6_0 = 0;
150 u32 current_sa_index = ~0, current_sa_bytes = 0, current_sa_pkts = 0;
153 .protocol = IP_PROTOCOL_IPSEC_AH,
157 .protocol = IP_PROTOCOL_IPSEC_AH,
170 if (
vnet_buffer (
b[0])->ipsec.sad_index != current_sa_index)
172 if (current_sa_index != ~0)
180 current_sa_bytes = current_sa_pkts = 0;
184 next[0] = AH_ENCRYPT_NEXT_DROP;
198 next[0] = AH_ENCRYPT_NEXT_HANDOFF;
204 b[0]->
error =
node->errors[AH_ENCRYPT_ERROR_SEQ_CYCLED];
209 current_sa_pkts += 1;
218 adv = -
sizeof (ip6_and_ah_header_t);
220 adv = -
sizeof (ip4_and_ah_header_t);
236 u8 *l2_hdr_out = l2_hdr_in + adv - icv_size;
245 ih6_0 = (ip6_and_ah_header_t *) ih0;
251 oh6_0->ip6.ip_version_traffic_class_and_flow_label =
252 ih6_0->ip6.ip_version_traffic_class_and_flow_label;
261 oh6_0->ip6.ip_version_traffic_class_and_flow_label;
265 next_hdr_type = IP_PROTOCOL_IPV6;
269 next_hdr_type = ih6_0->ip6.protocol;
274 oh6_0->ah.reserved = 0;
275 oh6_0->ah.nexthdr = next_hdr_type;
276 oh6_0->ah.spi = clib_net_to_host_u32 (sa0->
spi);
277 oh6_0->ah.seq_no = clib_net_to_host_u32 (sa0->
seq);
278 oh6_0->ip6.payload_length =
282 (
sizeof (
ah_header_t) + icv_size + padding_len) / 4 - 2;
288 pd->
ttl = ih0->ip4.ttl;
296 pd->
tos = ih0->ip4.tos;
299 TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP))
302 TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_ECN))
308 pd->
tos = ih0->ip4.tos;
312 clib_memset (oh0, 0,
sizeof (ip4_and_ah_header_t));
316 next_hdr_type = IP_PROTOCOL_IP_IN_IP;
320 next_hdr_type = ih0->ip4.protocol;
330 oh0->ah.spi = clib_net_to_host_u32 (sa0->
spi);
331 oh0->ah.seq_no = clib_net_to_host_u32 (sa0->
seq);
332 oh0->ah.nexthdr = next_hdr_type;
334 (
sizeof (
ah_header_t) + icv_size + padding_len) / 4 - 2;
338 !ipsec_sa_is_set_IS_TUNNEL_V6 (sa0)))
347 else if (
is_ip6 && ipsec_sa_is_set_IS_TUNNEL (sa0) &&
348 ipsec_sa_is_set_IS_TUNNEL_V6 (sa0))
352 sizeof (ip6_address_t) * 2);
370 if (ipsec_sa_is_set_USE_ESN (sa0))
372 u32 seq_hi = clib_host_to_net_u32 (sa0->
seq_hi);
374 op->
len +=
sizeof (seq_hi);
380 if (!ipsec_sa_is_set_IS_TUNNEL (sa0))
382 next[0] = AH_ENCRYPT_NEXT_INTERFACE_OUTPUT;
411 AH_ENCRYPT_ERROR_RX_PKTS,
n_left);
413 current_sa_index, current_sa_pkts,
427 oh6_0->ip6.ip_version_traffic_class_and_flow_label =
433 oh0->ip4.ttl = pd->
ttl;
434 oh0->ip4.tos = pd->
tos;
460 .name =
"ah4-encrypt",
461 .vector_size =
sizeof (
u32),
470 [AH_ENCRYPT_NEXT_DROP] =
"ip4-drop",
471 [AH_ENCRYPT_NEXT_HANDOFF] =
"ah4-encrypt-handoff",
472 [AH_ENCRYPT_NEXT_INTERFACE_OUTPUT] =
"interface-output",
486 .name =
"ah6-encrypt",
487 .vector_size =
sizeof (
u32),
496 [AH_ENCRYPT_NEXT_DROP] =
"ip6-drop",
497 [AH_ENCRYPT_NEXT_HANDOFF] =
"ah6-encrypt-handoff",
498 [AH_ENCRYPT_NEXT_INTERFACE_OUTPUT] =
"interface-output",
503 #ifndef CLIB_MARCH_VARIANT
510 im->ah4_enc_fq_index =
512 im->ah6_enc_fq_index =
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
vnet_crypto_op_t * integ_ops
u16 dpoi_next_node
The next VLIB node to follow.
static_always_inline void vnet_crypto_op_init(vnet_crypto_op_t *op, vnet_crypto_op_id_t type)
vnet_interface_main_t * im
vnet_crypto_key_index_t integ_key_index
index_t dpoi_index
the index of objects of that type
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
#define foreach_ah_encrypt_next
vlib_main_t vlib_node_runtime_t vlib_frame_t * frame
static u8 * format_ah_encrypt_trace(u8 *s, va_list *args)
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 clib_memcpy(d, s, n)
vnet_crypto_op_status_t status
vlib_get_buffers(vm, from, b, n_left_from)
@ VLIB_NODE_TYPE_INTERNAL
vlib_main_t vlib_node_runtime_t * node
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static_always_inline void clib_memcpy_le32(u8 *dst, u8 *src, u8 len)
static_always_inline void ip6_set_dscp_network_order(ip6_header_t *ip6, ip_dscp_t dscp)
vlib_node_registration_t ah4_encrypt_node
(constructor) VLIB_REGISTER_NODE (ah4_encrypt_node)
vlib_main_t vlib_node_runtime_t vlib_frame_t * from_frame
vlib_buffer_enqueue_to_next(vm, node, from,(u16 *) nexts, frame->n_vectors)
u32 ip_version_traffic_class_and_flow_label
static char * ah_encrypt_error_strings[]
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
u32 vlib_frame_queue_main_init(u32 node_index, u32 frame_queue_nelts)
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
static_always_inline void tunnel_encap_fixup_6o6(tunnel_encap_decap_flags_t flags, const ip6_header_t *inner, ip6_header_t *outer)
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
u32 vnet_crypto_process_ops(vlib_main_t *vm, vnet_crypto_op_t ops[], u32 n_ops)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
vlib_error_t error
Error code for buffers to be enqueued to error handler.
#define VLIB_NODE_FN(node)
static ipsec_sa_t * ipsec_sa_get(u32 sa_index)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
vlib_combined_counter_main_t ipsec_sa_counters
SA packet & bytes counters.
vlib_node_registration_t ah6_encrypt_node
(constructor) VLIB_REGISTER_NODE (ah6_encrypt_node)
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
tunnel_encap_decap_flags_t tunnel_flags
#define static_always_inline
static uword ah_encrypt_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame, int is_ip6)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
static u8 ah_calc_icv_padding_len(u8 icv_size, int is_ipv6)
static u32 ipsec_sa_assign_thread(u32 thread_id)
#define CLIB_CACHE_LINE_BYTES
struct _vlib_node_registration vlib_node_registration_t
u16 current_length
Nbytes between current data and the end of this buffer.
#define vec_add2_aligned(V, P, N, A)
Add N elements to end of vector V, return pointer to new elements in P.
description fragment has unexpected format
#define VLIB_INIT_FUNCTION(x)
#define clib_atomic_cmp_and_swap(addr, old, new)
#define foreach_ah_encrypt_error
vnet_crypto_op_id_t integ_op_id
static clib_error_t * ah_encrypt_init(vlib_main_t *vm)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
static u16 ip4_header_checksum(ip4_header_t *i)
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
ipsec_integ_alg_t integ_alg
u16 nexts[VLIB_FRAME_SIZE]
ipsec_integ_alg_t integ_alg
vl_api_fib_path_type_t type
vlib_increment_combined_counter(ccm, ti, sw_if_index, n_buffers, n_bytes)
static int esp_seq_advance(ipsec_sa_t *sa)
vnet_crypto_op_t * crypto_ops
VLIB buffer representation.
#define VLIB_REGISTER_NODE(x,...)
vl_api_wireguard_peer_flags_t flags