FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
ah_decrypt.c
Go to the documentation of this file.
1 /*
2  * ah_decrypt.c : IPSec AH decrypt node
3  *
4  * Copyright (c) 2015 Cisco and/or its affiliates.
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at:
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include <vnet/vnet.h>
19 #include <vnet/api_errno.h>
20 #include <vnet/ip/ip.h>
21 
22 #include <vnet/ipsec/ipsec.h>
23 #include <vnet/ipsec/esp.h>
24 #include <vnet/ipsec/ah.h>
25 #include <vnet/ipsec/ipsec_io.h>
26 
27 #define foreach_ah_decrypt_next \
28  _(DROP, "error-drop") \
29  _(IP4_INPUT, "ip4-input") \
30  _(IP6_INPUT, "ip6-input") \
31  _(HANDOFF, "handoff")
32 
33 #define _(v, s) AH_DECRYPT_NEXT_##v,
34 typedef enum
35 {
37 #undef _
40 
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  _ (NO_TAIL_SPACE, "not enough buffer tail space (dropped)") \
46  _ (DROP_FRAGMENTS, "IP fragments drop") \
47  _ (REPLAY, "SA replayed packet")
48 
49 typedef enum
50 {
51 #define _(sym,str) AH_DECRYPT_ERROR_##sym,
53 #undef _
56 
57 static char *ah_decrypt_error_strings[] = {
58 #define _(sym,string) string,
60 #undef _
61 };
62 
63 typedef struct
64 {
65  ipsec_integ_alg_t integ_alg;
68 
69 /* packet trace format function */
70 static u8 *
71 format_ah_decrypt_trace (u8 * s, va_list * args)
72 {
73  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
74  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
75  ah_decrypt_trace_t *t = va_arg (*args, ah_decrypt_trace_t *);
76 
77  s = format (s, "ah: integrity %U seq-num %d",
79  return s;
80 }
81 
82 typedef struct
83 {
84  union
85  {
86  struct
87  {
91  };
92 
93  struct
94  {
97  };
98  };
108 
111  vnet_crypto_op_t * ops, vlib_buffer_t * b[], u16 * nexts)
112 {
113  u32 n_fail, n_ops = vec_len (ops);
114  vnet_crypto_op_t *op = ops;
115 
116  if (n_ops == 0)
117  return;
118 
119  n_fail = n_ops - vnet_crypto_process_ops (vm, op, n_ops);
120 
121  while (n_fail)
122  {
123  ASSERT (op - ops < n_ops);
124 
125  if (op->status != VNET_CRYPTO_OP_STATUS_COMPLETED)
126  {
127  u32 bi = op->user_data;
128  b[bi]->error = node->errors[AH_DECRYPT_ERROR_INTEG_ERROR];
129  nexts[bi] = AH_DECRYPT_NEXT_DROP;
130  n_fail--;
131  }
132  op++;
133  }
134 }
135 
139  int is_ip6)
140 {
141  u32 n_left, *from;
143  u16 buffer_data_size = vlib_buffer_get_default_data_size (vm);
144  ah_decrypt_packet_data_t pkt_data[VLIB_FRAME_SIZE], *pd = pkt_data;
150  n_left = from_frame->n_vectors;
151  ipsec_sa_t *sa0 = 0;
152  u32 current_sa_index = ~0, current_sa_bytes = 0, current_sa_pkts = 0;
153 
154  clib_memset (pkt_data, 0, VLIB_FRAME_SIZE * sizeof (pkt_data[0]));
158 
159  while (n_left > 0)
160  {
161  ah_header_t *ah0;
162  ip4_header_t *ih4;
163  ip6_header_t *ih6;
164 
165  if (vnet_buffer (b[0])->ipsec.sad_index != current_sa_index)
166  {
167  if (current_sa_index != ~0)
169  current_sa_index,
170  current_sa_pkts,
171  current_sa_bytes);
172  current_sa_index = vnet_buffer (b[0])->ipsec.sad_index;
173  sa0 = ipsec_sa_get (current_sa_index);
174 
175  current_sa_bytes = current_sa_pkts = 0;
177  thread_index, current_sa_index);
178  }
179 
180  if (PREDICT_FALSE (~0 == sa0->thread_index))
181  {
182  /* this is the first packet to use this SA, claim the SA
183  * for this thread. this could happen simultaneously on
184  * another thread */
187  }
188 
189  if (PREDICT_TRUE (thread_index != sa0->thread_index))
190  {
191  vnet_buffer (b[0])->ipsec.thread_index = sa0->thread_index;
192  next[0] = AH_DECRYPT_NEXT_HANDOFF;
193  goto next;
194  }
195 
196  pd->sa_index = current_sa_index;
197 
198  ih4 = vlib_buffer_get_current (b[0]);
199  ih6 = vlib_buffer_get_current (b[0]);
200  pd->current_data = b[0]->current_data;
201 
202  if (is_ip6)
203  {
204  ip6_ext_header_t *prev = NULL;
205  ah0 =
206  ip6_ext_header_find (vm, b[0], ih6, IP_PROTOCOL_IPSEC_AH, &prev);
207  pd->ip_hdr_size = sizeof (ip6_header_t);
208  ASSERT ((u8 *) ah0 - (u8 *) ih6 == pd->ip_hdr_size);
209  }
210  else
211  {
212  if (ip4_is_fragment (ih4))
213  {
214  b[0]->error = node->errors[AH_DECRYPT_ERROR_DROP_FRAGMENTS];
215  next[0] = AH_DECRYPT_NEXT_DROP;
216  goto next;
217  }
218  pd->ip_hdr_size = ip4_header_bytes (ih4);
219  ah0 = (ah_header_t *) ((u8 *) ih4 + pd->ip_hdr_size);
220  }
221 
222  pd->seq = clib_host_to_net_u32 (ah0->seq_no);
223 
224  /* anti-replay check */
225  if (ipsec_sa_anti_replay_and_sn_advance (sa0, pd->seq, ~0, false,
226  &pd->seq_hi))
227  {
228  b[0]->error = node->errors[AH_DECRYPT_ERROR_REPLAY];
229  next[0] = AH_DECRYPT_NEXT_DROP;
230  goto next;
231  }
232 
233  current_sa_bytes += b[0]->current_length;
234  current_sa_pkts += 1;
235 
236  pd->icv_size = sa0->integ_icv_size;
237  pd->nexthdr_cached = ah0->nexthdr;
238  if (PREDICT_TRUE (sa0->integ_alg != IPSEC_INTEG_ALG_NONE))
239  {
240  if (PREDICT_FALSE (ipsec_sa_is_set_USE_ESN (sa0) &&
241  pd->current_data + b[0]->current_length
242  + sizeof (u32) > buffer_data_size))
243  {
244  b[0]->error = node->errors[AH_DECRYPT_ERROR_NO_TAIL_SPACE];
245  next[0] = AH_DECRYPT_NEXT_DROP;
246  goto next;
247  }
248 
249  vnet_crypto_op_t *op;
251  vnet_crypto_op_init (op, sa0->integ_op_id);
252 
253  op->src = (u8 *) ih4;
254  op->len = b[0]->current_length;
255  op->digest = (u8 *) ih4 - pd->icv_size;
257  op->digest_len = pd->icv_size;
258  op->key_index = sa0->integ_key_index;
259  op->user_data = b - bufs;
260  if (ipsec_sa_is_set_USE_ESN (sa0))
261  {
262  u32 seq_hi = clib_host_to_net_u32 (pd->seq_hi);
263 
264  op->len += sizeof (seq_hi);
265  clib_memcpy (op->src + b[0]->current_length, &seq_hi,
266  sizeof (seq_hi));
267  }
268  clib_memcpy (op->digest, ah0->auth_data, pd->icv_size);
269  clib_memset (ah0->auth_data, 0, pd->icv_size);
270 
271  if (is_ip6)
272  {
275  pd->hop_limit = ih6->hop_limit;
277  ih6->hop_limit = 0;
278  pd->nexthdr = ah0->nexthdr;
279  pd->icv_padding_len =
280  ah_calc_icv_padding_len (pd->icv_size, 1 /* is_ipv6 */ );
281  }
282  else
283  {
284  pd->tos = ih4->tos;
285  pd->ttl = ih4->ttl;
286  ih4->tos = 0;
287  ih4->ttl = 0;
288  ih4->checksum = 0;
289  pd->icv_padding_len =
290  ah_calc_icv_padding_len (pd->icv_size, 0 /* is_ipv6 */ );
291  }
292  }
293 
294  next:
295  n_left -= 1;
296  pd += 1;
297  next += 1;
298  b += 1;
299  }
300 
301  n_left = from_frame->n_vectors;
302  next = nexts;
303  pd = pkt_data;
304  b = bufs;
305 
306  vlib_node_increment_counter (vm, node->node_index, AH_DECRYPT_ERROR_RX_PKTS,
307  n_left);
309  current_sa_index, current_sa_pkts,
310  current_sa_bytes);
311 
313 
314  while (n_left > 0)
315  {
316  ip4_header_t *oh4;
317  ip6_header_t *oh6;
318 
319  if (next[0] < AH_DECRYPT_N_NEXT)
320  goto trace;
321 
322  sa0 = ipsec_sa_get (pd->sa_index);
323 
324  if (PREDICT_TRUE (sa0->integ_alg != IPSEC_INTEG_ALG_NONE))
325  {
326  /* redo the anit-reply check. see esp_decrypt for details */
328  true, NULL))
329  {
330  b[0]->error = node->errors[AH_DECRYPT_ERROR_REPLAY];
331  next[0] = AH_DECRYPT_NEXT_DROP;
332  goto trace;
333  }
334  ipsec_sa_anti_replay_advance (sa0, pd->seq, pd->seq_hi);
335  }
336 
337  u16 ah_hdr_len = sizeof (ah_header_t) + pd->icv_size
338  + pd->icv_padding_len;
339  vlib_buffer_advance (b[0], pd->ip_hdr_size + ah_hdr_len);
340  b[0]->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
341 
342  if (PREDICT_TRUE (ipsec_sa_is_set_IS_TUNNEL (sa0)))
343  { /* tunnel mode */
344  if (PREDICT_TRUE (pd->nexthdr_cached == IP_PROTOCOL_IP_IN_IP))
345  next[0] = AH_DECRYPT_NEXT_IP4_INPUT;
346  else if (pd->nexthdr_cached == IP_PROTOCOL_IPV6)
347  next[0] = AH_DECRYPT_NEXT_IP6_INPUT;
348  else
349  {
350  b[0]->error = node->errors[AH_DECRYPT_ERROR_DECRYPTION_FAILED];
351  next[0] = AH_DECRYPT_NEXT_DROP;
352  goto trace;
353  }
354  }
355  else
356  { /* transport mode */
357  if (is_ip6)
358  {
359  vlib_buffer_advance (b[0], -sizeof (ip6_header_t));
360  oh6 = vlib_buffer_get_current (b[0]);
361  if (ah_hdr_len >= sizeof (ip6_header_t))
362  clib_memcpy (oh6, b[0]->data + pd->current_data,
363  sizeof (ip6_header_t));
364  else
365  memmove (oh6, b[0]->data + pd->current_data,
366  sizeof (ip6_header_t));
367 
368  next[0] = AH_DECRYPT_NEXT_IP6_INPUT;
369  oh6->protocol = pd->nexthdr;
370  oh6->hop_limit = pd->hop_limit;
373  oh6->payload_length =
374  clib_host_to_net_u16 (vlib_buffer_length_in_chain
375  (vm, b[0]) - sizeof (ip6_header_t));
376  }
377  else
378  {
379  vlib_buffer_advance (b[0], -sizeof (ip4_header_t));
380  oh4 = vlib_buffer_get_current (b[0]);
381  if (ah_hdr_len >= sizeof (ip4_header_t))
382  clib_memcpy (oh4, b[0]->data + pd->current_data,
383  sizeof (ip4_header_t));
384  else
385  memmove (oh4, b[0]->data + pd->current_data,
386  sizeof (ip4_header_t));
387 
388  next[0] = AH_DECRYPT_NEXT_IP4_INPUT;
389  oh4->ip_version_and_header_length = 0x45;
390  oh4->fragment_id = 0;
391  oh4->flags_and_fragment_offset = 0;
392  oh4->protocol = pd->nexthdr_cached;
393  oh4->length =
394  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b[0]));
395  oh4->ttl = pd->ttl;
396  oh4->tos = pd->tos;
397  oh4->checksum = ip4_header_checksum (oh4);
398  }
399  }
400 
401  vnet_buffer (b[0])->sw_if_index[VLIB_TX] = (u32) ~ 0;
402  trace:
403  if (PREDICT_FALSE (b[0]->flags & VLIB_BUFFER_IS_TRACED))
404  {
405  sa0 = ipsec_sa_get (vnet_buffer (b[0])->ipsec.sad_index);
406  ah_decrypt_trace_t *tr =
407  vlib_add_trace (vm, node, b[0], sizeof (*tr));
408  tr->integ_alg = sa0->integ_alg;
409  tr->seq_num = pd->seq;
410  }
411 
412  n_left -= 1;
413  pd += 1;
414  next += 1;
415  b += 1;
416  }
417 
418  n_left = from_frame->n_vectors;
420 
421  return n_left;
422 }
423 
427 {
428  return ah_decrypt_inline (vm, node, from_frame, 0 /* is_ip6 */ );
429 }
430 
431 /* *INDENT-OFF* */
433  .name = "ah4-decrypt",
434  .vector_size = sizeof (u32),
435  .format_trace = format_ah_decrypt_trace,
437 
438  .n_errors = ARRAY_LEN(ah_decrypt_error_strings),
439  .error_strings = ah_decrypt_error_strings,
440 
441  .n_next_nodes = AH_DECRYPT_N_NEXT,
442  .next_nodes = {
443  [AH_DECRYPT_NEXT_DROP] = "ip4-drop",
444  [AH_DECRYPT_NEXT_IP4_INPUT] = "ip4-input-no-checksum",
445  [AH_DECRYPT_NEXT_IP6_INPUT] = "ip6-input",
446  [AH_DECRYPT_NEXT_HANDOFF] = "ah4-decrypt-handoff",
447  },
448 };
449 /* *INDENT-ON* */
450 
454 {
455  return ah_decrypt_inline (vm, node, from_frame, 1 /* is_ip6 */ );
456 }
457 
458 /* *INDENT-OFF* */
460  .name = "ah6-decrypt",
461  .vector_size = sizeof (u32),
462  .format_trace = format_ah_decrypt_trace,
464 
465  .n_errors = ARRAY_LEN(ah_decrypt_error_strings),
466  .error_strings = ah_decrypt_error_strings,
467 
468  .n_next_nodes = AH_DECRYPT_N_NEXT,
469  .next_nodes = {
470  [AH_DECRYPT_NEXT_DROP] = "ip6-drop",
471  [AH_DECRYPT_NEXT_IP4_INPUT] = "ip4-input-no-checksum",
472  [AH_DECRYPT_NEXT_IP6_INPUT] = "ip6-input",
473  [AH_DECRYPT_NEXT_HANDOFF] = "ah6-decrypt-handoff",
474  },
475 };
476 /* *INDENT-ON* */
477 
478 #ifndef CLIB_MARCH_VARIANT
479 
480 static clib_error_t *
482 {
484 
485  im->ah4_dec_fq_index =
487  im->ah6_dec_fq_index =
489 
490  return 0;
491 }
492 
494 
495 #endif
496 
497 /*
498  * fd.io coding-style-patch-verification: ON
499  *
500  * Local Variables:
501  * eval: (c-set-style "gnu")
502  * End:
503  */
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
ipsec.h
ipsec_per_thread_data_t::integ_ops
vnet_crypto_op_t * integ_ops
Definition: ipsec.h:101
vnet_crypto_op_t::digest
u8 * digest
Definition: crypto.h:299
ah_decrypt_packet_data_t::icv_size
u8 icv_size
Definition: ah_decrypt.c:103
vnet_crypto_op_init
static_always_inline void vnet_crypto_op_init(vnet_crypto_op_t *op, vnet_crypto_op_id_t type)
Definition: crypto.h:528
im
vnet_interface_main_t * im
Definition: interface_output.c:415
ah_decrypt_packet_data_t::current_data
i16 current_data
Definition: ah_decrypt.c:105
vnet_crypto_op_t::digest_len
u8 digest_len
Definition: crypto.h:268
ah4_decrypt_node
vlib_node_registration_t ah4_decrypt_node
(constructor) VLIB_REGISTER_NODE (ah4_decrypt_node)
Definition: ah_decrypt.c:432
trace
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
Definition: vlib_api_cli.c:870
ipsec_sa_t::integ_key_index
vnet_crypto_key_index_t integ_key_index
Definition: ipsec_sa.h:139
thread_index
u32 thread_index
Definition: nat44_ei_hairpinning.c:495
bufs
vlib_buffer_t * bufs[VLIB_FRAME_SIZE]
Definition: nat44_ei_out2in.c:717
ipsec_sa_anti_replay_and_sn_advance
static int ipsec_sa_anti_replay_and_sn_advance(const ipsec_sa_t *sa, u32 seq, u32 hi_seq_used, bool post_decrypt, u32 *hi_seq_req)
Definition: ipsec_sa.h:338
ah_decrypt_next_t
ah_decrypt_next_t
Definition: ah_decrypt.c:34
format_ipsec_integ_alg
u8 * format_ipsec_integ_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:111
ah_decrypt_packet_data_t::nexthdr
u8 nexthdr
Definition: ah_decrypt.c:89
clib_memcpy
#define clib_memcpy(d, s, n)
Definition: string.h:197
ah_decrypt_packet_data_t
Definition: ah_decrypt.c:82
ah_header_t
Definition: ah.h:21
ipsec_sa_t::thread_index
u32 thread_index
Definition: ipsec_sa.h:129
clib_memset_u16
static_always_inline void clib_memset_u16(void *p, u16 val, uword count)
Definition: string.h:395
ah_decrypt_packet_data_t::seq
u32 seq
Definition: ah_decrypt.c:100
vnet_crypto_op_t::status
vnet_crypto_op_status_t status
Definition: crypto.h:260
ip6_header_t::protocol
u8 protocol
Definition: ip6_packet.h:304
vlib_get_buffers
vlib_get_buffers(vm, from, b, n_left_from)
next
u16 * next
Definition: nat44_ei_out2in.c:718
VLIB_NODE_TYPE_INTERNAL
@ VLIB_NODE_TYPE_INTERNAL
Definition: node.h:72
VLIB_FRAME_SIZE
#define VLIB_FRAME_SIZE
Definition: node.h:368
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
ip6_header_t::hop_limit
u8 hop_limit
Definition: ip6_packet.h:307
ah_decrypt_packet_data_t::ttl
u8 ttl
Definition: ah_decrypt.c:95
vnet_crypto_op_t::src
u8 * src
Definition: crypto.h:277
u16
unsigned short u16
Definition: types.h:57
vnet_crypto_op_t::user_data
uword user_data
Definition: crypto.h:258
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
from_frame
vlib_main_t vlib_node_runtime_t vlib_frame_t * from_frame
Definition: esp_encrypt.c:1328
vlib_buffer_enqueue_to_next
vlib_buffer_enqueue_to_next(vm, node, from,(u16 *) nexts, frame->n_vectors)
ipsec_sa_t::integ_icv_size
u8 integ_icv_size
Definition: ipsec_sa.h:125
ah_decrypt_error_strings
static char * ah_decrypt_error_strings[]
Definition: ah_decrypt.c:57
vnet_crypto_op_t::len
u32 len
Definition: crypto.h:287
vlib_frame_t
Definition: node.h:372
vlib_buffer_length_in_chain
static uword vlib_buffer_length_in_chain(vlib_main_t *vm, vlib_buffer_t *b)
Get length in bytes of the buffer chain.
Definition: buffer_funcs.h:433
ip4_header_t
Definition: ip4_packet.h:87
ip4_header_t::tos
ip_dscp_t tos
Definition: ip4_packet.h:96
ip4_header_t::length
u16 length
Definition: ip4_packet.h:99
vnet_crypto_op_t
Definition: crypto.h:255
vnet_crypto_op_t::flags
u8 flags
Definition: crypto.h:261
vlib_frame_queue_main_init
u32 vlib_frame_queue_main_init(u32 node_index, u32 frame_queue_nelts)
Definition: threads.c:1561
vnet_crypto_op_t::key_index
u32 key_index
Definition: crypto.h:292
esp.h
VNET_CRYPTO_OP_FLAG_HMAC_CHECK
#define VNET_CRYPTO_OP_FLAG_HMAC_CHECK
Definition: crypto.h:263
i16
signed short i16
Definition: types.h:46
vlib_buffer_t::current_data
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:119
vlib_buffer_advance
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:276
vnet_crypto_process_ops
u32 vnet_crypto_process_ops(vlib_main_t *vm, vnet_crypto_op_t ops[], u32 n_ops)
Definition: crypto.c:99
ah_decrypt_trace_t::seq_num
u32 seq_num
Definition: ah_decrypt.c:66
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
vlib_buffer_t::error
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:145
ah_process_ops
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)
Definition: ah_decrypt.c:110
VLIB_NODE_FN
#define VLIB_NODE_FN(node)
Definition: node.h:202
ah_decrypt_init
static clib_error_t * ah_decrypt_init(vlib_main_t *vm)
Definition: ah_decrypt.c:481
ipsec_sa_get
static ipsec_sa_t * ipsec_sa_get(u32 sa_index)
Definition: ipsec_sa.h:605
ip4_is_fragment
static int ip4_is_fragment(const ip4_header_t *i)
Definition: ip4_packet.h:168
ah_header_t::auth_data
unsigned char auth_data[0]
Definition: ah.h:28
CLIB_UNUSED
#define CLIB_UNUSED(x)
Definition: clib.h:90
vnet_buffer
#define vnet_buffer(b)
Definition: buffer.h:441
vec_elt_at_index
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
Definition: vec_bootstrap.h:203
ah_decrypt_packet_data_t::hop_limit
u8 hop_limit
Definition: ah_decrypt.c:88
ipsec_per_thread_data_t
Definition: ipsec.h:97
ipsec_sa_counters
vlib_combined_counter_main_t ipsec_sa_counters
SA packet & bytes counters.
Definition: ipsec_sa.c:27
PREDICT_FALSE
#define PREDICT_FALSE(x)
Definition: clib.h:124
ah_decrypt_inline
static uword ah_decrypt_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, int is_ip6)
Definition: ah_decrypt.c:137
ARRAY_LEN
#define ARRAY_LEN(x)
Definition: clib.h:70
vlib_frame_vector_args
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:301
ipsec_main_t
Definition: ipsec.h:108
vlib_prefetch_combined_counter
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.
Definition: counter.h:248
ah_header_t::nexthdr
unsigned char nexthdr
Definition: ah.h:23
ip6_ext_header_find
static void * ip6_ext_header_find(vlib_main_t *vm, vlib_buffer_t *b, ip6_header_t *ip6_header, u8 header_type, ip6_ext_header_t **prev_ext_header)
Definition: ip6_packet.h:575
static_always_inline
#define static_always_inline
Definition: clib.h:112
uword
u64 uword
Definition: types.h:112
if
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
ipsec_main
ipsec_main_t ipsec_main
Definition: ipsec.c:29
vlib_main_t::thread_index
u32 thread_index
Definition: main.h:215
vlib_node_increment_counter
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1244
ah_decrypt_packet_data_t::seq_hi
u32 seq_hi
Definition: ah_decrypt.c:101
ah_decrypt_trace_t::integ_alg
ipsec_integ_alg_t integ_alg
Definition: ah_decrypt.c:65
foreach_ah_decrypt_error
#define foreach_ah_decrypt_error
Definition: ah_decrypt.c:41
ip4_header_t::checksum
u16 checksum
Definition: ip4_packet.h:118
ah_calc_icv_padding_len
static u8 ah_calc_icv_padding_len(u8 icv_size, int is_ipv6)
Definition: ah.h:47
ipsec_sa_assign_thread
static u32 ipsec_sa_assign_thread(u32 thread_id)
Definition: ipsec_sa.h:598
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:58
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
ah_decrypt_packet_data_t::ip_hdr_size
u8 ip_hdr_size
Definition: ah_decrypt.c:104
vlib_buffer_t::current_length
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:122
ah.h
ip4_header_t::fragment_id
u16 fragment_id
Definition: ip4_packet.h:102
AH_DECRYPT_N_NEXT
@ AH_DECRYPT_N_NEXT
Definition: ah_decrypt.c:38
data
u8 data[128]
Definition: ipsec_types.api:95
vec_add2_aligned
#define vec_add2_aligned(V, P, N, A)
Add N elements to end of vector V, return pointer to new elements in P.
Definition: vec.h:656
ipsec_sa_t
Definition: ipsec_sa.h:116
AH_DECRYPT_N_ERROR
@ AH_DECRYPT_N_ERROR
Definition: ah_decrypt.c:54
is_ip6
bool is_ip6
Definition: ip.api:43
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
ah_header_t::seq_no
unsigned int seq_no
Definition: ah.h:27
ah_decrypt_packet_data_t::sa_index
u32 sa_index
Definition: ah_decrypt.c:99
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
vlib_buffer_get_default_data_size
static_always_inline u32 vlib_buffer_get_default_data_size(vlib_main_t *vm)
Definition: buffer_funcs.h:122
ip.h
u32
unsigned int u32
Definition: types.h:88
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
ip4_header_t::ttl
u8 ttl
Definition: ip4_packet.h:112
clib_atomic_cmp_and_swap
#define clib_atomic_cmp_and_swap(addr, old, new)
Definition: atomics.h:37
ipsec_sa_t::integ_op_id
vnet_crypto_op_id_t integ_op_id
Definition: ipsec_sa.h:149
n_left
u32 n_left
Definition: interface_output.c:1096
ip6_header_t
Definition: ip6_packet.h:294
ip4_header_t::flags_and_fragment_offset
u16 flags_and_fragment_offset
Definition: ip4_packet.h:106
foreach_ah_decrypt_next
#define foreach_ah_decrypt_next
Definition: ah_decrypt.c:27
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
vlib_main_t
Definition: main.h:102
ip4_header_t::ip_version_and_header_length
u8 ip_version_and_header_length
Definition: ip4_packet.h:93
vlib_node_t
Definition: node.h:247
vlib_add_trace
void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace.c:628
b
vlib_buffer_t ** b
Definition: nat44_ei_out2in.c:717
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
format_ah_decrypt_trace
static u8 * format_ah_decrypt_trace(u8 *s, va_list *args)
Definition: ah_decrypt.c:71
vlib_buffer_get_current
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:257
ip4_header_checksum
static u16 ip4_header_checksum(ip4_header_t *i)
Definition: ip4_packet.h:314
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
ipsec_sa_t::integ_alg
ipsec_integ_alg_t integ_alg
Definition: ipsec_sa.h:216
ah_decrypt_packet_data_t::ip_version_traffic_class_and_flow_label
u32 ip_version_traffic_class_and_flow_label
Definition: ah_decrypt.c:90
nexts
u16 nexts[VLIB_FRAME_SIZE]
Definition: nat44_ei_out2in.c:718
ip4_header_bytes
static int ip4_header_bytes(const ip4_header_t *i)
Definition: ip4_packet.h:190
ah_decrypt_packet_data_t::tos
u8 tos
Definition: ah_decrypt.c:96
ah_decrypt_packet_data_t::nexthdr_cached
u8 nexthdr_cached
Definition: ah_decrypt.c:106
vnet.h
api_errno.h
ip6_header_t::payload_length
u16 payload_length
Definition: ip6_packet.h:301
ah_decrypt_packet_data_t::icv_padding_len
u8 icv_padding_len
Definition: ah_decrypt.c:102
vlib_node_runtime_t
Definition: node.h:454
ah_decrypt_trace_t
Definition: ah_decrypt.c:63
from
from
Definition: nat44_ei_hairpinning.c:415
PREDICT_TRUE
#define PREDICT_TRUE(x)
Definition: clib.h:125
ipsec_io.h
VLIB_TX
@ VLIB_TX
Definition: defs.h:47
ip6_header_t::ip_version_traffic_class_and_flow_label
u32 ip_version_traffic_class_and_flow_label
Definition: ip6_packet.h:297
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
ip4_header_t::protocol
u8 protocol
Definition: ip4_packet.h:115
vlib_increment_combined_counter
vlib_increment_combined_counter(ccm, ti, sw_if_index, n_buffers, n_bytes)
ah_decrypt_error_t
ah_decrypt_error_t
Definition: ah_decrypt.c:49
vlib_buffer_t::flags
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index,...
Definition: buffer.h:133
ah6_decrypt_node
vlib_node_registration_t ah6_decrypt_node
(constructor) VLIB_REGISTER_NODE (ah6_decrypt_node)
Definition: ah_decrypt.c:459
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
ipsec_sa_anti_replay_advance
static void ipsec_sa_anti_replay_advance(ipsec_sa_t *sa, u32 seq, u32 hi_seq)
Definition: ipsec_sa.h:535
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105