26 #define foreach_ah_encrypt_next \ 27 _ (DROP, "error-drop") \ 28 _ (IP4_LOOKUP, "ip4-lookup") \ 29 _ (IP6_LOOKUP, "ip6-lookup") \ 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 _(SEQ_CYCLED, "sequence number cycled") 48 #define _(sym,str) AH_ENCRYPT_ERROR_##sym, 55 #define _(sym,string) string, 77 s =
format (s,
"ah: sa-index %d spi %u seq %u:%u integrity %U",
88 u32 n_left_from, *from, *to_next = 0, next_index, thread_index;
96 while (n_left_from > 0)
102 while (n_left_from > 0 && n_left_to_next > 0)
108 ip4_and_ah_header_t *ih0, *oh0 = 0;
109 ip6_and_ah_header_t *ih6_0, *oh6_0 = 0;
115 u32 ip_version_traffic_class_and_flow_label = 0;
121 next0 = AH_ENCRYPT_NEXT_DROP;
131 i_b0->
error = node->
errors[AH_ENCRYPT_ERROR_SEQ_CYCLED];
146 adv = -
sizeof (ip6_and_ah_header_t);
148 adv = -
sizeof (ip4_and_ah_header_t);
173 ih6_0 = (ip6_and_ah_header_t *) ih0;
177 hop_limit = ih6_0->ip6.hop_limit;
178 ip_version_traffic_class_and_flow_label =
179 ih6_0->ip6.ip_version_traffic_class_and_flow_label;
182 next_hdr_type = IP_PROTOCOL_IPV6;
186 next_hdr_type = ih6_0->ip6.protocol;
190 oh6_0->ip6.protocol = IP_PROTOCOL_IPSEC_AH;
191 oh6_0->ip6.hop_limit = 0;
192 oh6_0->ip6.ip_version_traffic_class_and_flow_label = 0x60;
193 oh6_0->ah.reserved = 0;
194 oh6_0->ah.nexthdr = next_hdr_type;
195 oh6_0->ah.spi = clib_net_to_host_u32 (sa0->
spi);
196 oh6_0->ah.seq_no = clib_net_to_host_u32 (sa0->
seq);
197 oh6_0->ip6.payload_length =
201 (
sizeof (
ah_header_t) + icv_size + padding_len) / 4 - 2;
207 clib_memset (oh0, 0,
sizeof (ip4_and_ah_header_t));
211 next_hdr_type = IP_PROTOCOL_IP_IN_IP;
215 next_hdr_type = ih0->ip4.protocol;
221 oh0->ip4.ip_version_and_header_length = 0x45;
222 oh0->ip4.fragment_id = 0;
223 oh0->ip4.flags_and_fragment_offset = 0;
226 oh0->ip4.protocol = IP_PROTOCOL_IPSEC_AH;
227 oh0->ah.spi = clib_net_to_host_u32 (sa0->
spi);
228 oh0->ah.seq_no = clib_net_to_host_u32 (sa0->
seq);
229 oh0->ip4.checksum = 0;
230 oh0->ah.nexthdr = next_hdr_type;
232 (
sizeof (
ah_header_t) + icv_size + padding_len) / 4 - 2;
236 if (
PREDICT_TRUE (!is_ip6 && ipsec_sa_is_set_IS_TUNNEL (sa0) &&
237 !ipsec_sa_is_set_IS_TUNNEL_V6 (sa0)))
246 else if (is_ip6 && ipsec_sa_is_set_IS_TUNNEL (sa0) &&
247 ipsec_sa_is_set_IS_TUNNEL_V6 (sa0))
249 oh6_0->ip6.src_address.as_u64[0] =
251 oh6_0->ip6.src_address.as_u64[1] =
253 oh6_0->ip6.dst_address.as_u64[0] =
255 oh6_0->ip6.dst_address.as_u64[1] =
273 memcpy (digest, sig, size);
276 oh6_0->ip6.hop_limit = hop_limit;
277 oh6_0->ip6.ip_version_traffic_class_and_flow_label =
278 ip_version_traffic_class_and_flow_label;
287 if (!ipsec_sa_is_set_IS_TUNNEL (sa0))
289 next0 = AH_ENCRYPT_NEXT_INTERFACE_OUTPUT;
306 to_next, n_left_to_next, i_bi0,
312 AH_ENCRYPT_ERROR_RX_PKTS,
327 .name =
"ah4-encrypt",
328 .vector_size =
sizeof (
u32),
337 #define _(s,n) [AH_ENCRYPT_NEXT_##s] = n, 353 .name =
"ah6-encrypt",
354 .vector_size =
sizeof (
u32),
363 #define _(s,n) [AH_ENCRYPT_NEXT_##s] = n, 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)
ip46_address_t tunnel_src_addr
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.
#define clib_memcpy_fast(a, b, c)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
ipsec_integ_alg_t integ_alg
u16 current_length
Nbytes between current data and the end of this buffer.
vlib_node_registration_t ah6_encrypt_node
(constructor) VLIB_REGISTER_NODE (ah6_encrypt_node)
#define VLIB_NODE_FN(node)
vlib_error_t * errors
Vector of errors for this node.
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
static int esp_seq_advance(ipsec_sa_t *sa)
static uword ah_encrypt_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, int is_ip6)
ipsec_integ_alg_t integ_alg
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 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.
vlib_node_registration_t ah4_encrypt_node
(constructor) VLIB_REGISTER_NODE (ah4_encrypt_node)
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)
ip46_address_t tunnel_dst_addr
static u8 * format_ah_encrypt_trace(u8 *s, va_list *args)
#define VLIB_REGISTER_NODE(x,...)
static char * ah_encrypt_error_strings[]
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.
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.
#define foreach_ah_encrypt_error
dpo_id_t dpo[IPSEC_N_PROTOCOLS]
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)
index_t dpoi_index
the index of objects of that type
VLIB buffer representation.
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
#define foreach_ah_encrypt_next
u16 dpoi_next_node
The next VLIB node to follow.
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)