FD.io VPP  v16.09
Vector Packet Processing
esp_decrypt.c
Go to the documentation of this file.
1 /*
2  * esp_decrypt.c : IPSec ESP 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 
25 #define ESP_WINDOW_SIZE 64
26 
27 #define foreach_esp_decrypt_next \
28 _(DROP, "error-drop") \
29 _(IP4_INPUT, "ip4-input") \
30 _(IP6_INPUT, "ip6-input") \
31 _(IPSEC_GRE_INPUT, "ipsec-gre-input")
32 
33 #define _(v, s) ESP_DECRYPT_NEXT_##v,
34 typedef enum
35 {
37 #undef _
40 
41 
42 #define foreach_esp_decrypt_error \
43  _(RX_PKTS, "ESP pkts received") \
44  _(NO_BUFFER, "No buffer (packed dropped)") \
45  _(DECRYPTION_FAILED, "ESP decryption failed") \
46  _(INTEG_ERROR, "Integrity check failed") \
47  _(REPLAY, "SA replayed packet") \
48  _(NOT_IP, "Not IP packet (dropped)")
49 
50 
51 typedef enum
52 {
53 #define _(sym,str) ESP_DECRYPT_ERROR_##sym,
55 #undef _
58 
59 static char *esp_decrypt_error_strings[] = {
60 #define _(sym,string) string,
62 #undef _
63 };
64 
65 typedef struct
66 {
70 
71 /* packet trace format function */
72 static u8 *
73 format_esp_decrypt_trace (u8 * s, va_list * args)
74 {
75  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
76  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
77  esp_decrypt_trace_t *t = va_arg (*args, esp_decrypt_trace_t *);
78 
79  s = format (s, "esp: crypto %U integrity %U",
82  return s;
83 }
84 
85 always_inline void
87  u8 * in, u8 * out, size_t in_len, u8 * key, u8 * iv)
88 {
89  esp_main_t *em = &esp_main;
90  u32 cpu_index = os_get_cpu_number ();
91  EVP_CIPHER_CTX *ctx = &(em->per_thread_data[cpu_index].decrypt_ctx);
92  const EVP_CIPHER *cipher = NULL;
93  int out_len;
94 
95  ASSERT (alg < IPSEC_CRYPTO_N_ALG);
96 
97  if (PREDICT_FALSE (em->esp_crypto_algs[alg].type == 0))
98  return;
99 
100  if (PREDICT_FALSE (alg != em->per_thread_data[cpu_index].last_decrypt_alg))
101  {
102  cipher = em->esp_crypto_algs[alg].type;
103  em->per_thread_data[cpu_index].last_decrypt_alg = alg;
104  }
105 
106  EVP_DecryptInit_ex (ctx, cipher, NULL, key, iv);
107 
108  EVP_DecryptUpdate (ctx, out, &out_len, in, in_len);
109  EVP_DecryptFinal_ex (ctx, out + out_len, &out_len);
110 }
111 
112 always_inline int
114 {
115  u32 diff;
116 
117  if (PREDICT_TRUE (seq > sa->last_seq))
118  return 0;
119 
120  diff = sa->last_seq - seq;
121 
122  if (ESP_WINDOW_SIZE > diff)
123  return (sa->replay_window & (1ULL << diff)) ? 1 : 0;
124  else
125  return 1;
126 
127  return 0;
128 }
129 
130 always_inline int
132 {
133  u32 tl = sa->last_seq;
134  u32 th = sa->last_seq_hi;
135  u32 diff = tl - seq;
136 
137  if (PREDICT_TRUE (tl >= (ESP_WINDOW_SIZE - 1)))
138  {
139  if (seq >= (tl - ESP_WINDOW_SIZE + 1))
140  {
141  sa->seq_hi = th;
142  if (seq <= tl)
143  return (sa->replay_window & (1ULL << diff)) ? 1 : 0;
144  else
145  return 0;
146  }
147  else
148  {
149  sa->seq_hi = th + 1;
150  return 0;
151  }
152  }
153  else
154  {
155  if (seq >= (tl - ESP_WINDOW_SIZE + 1))
156  {
157  sa->seq_hi = th - 1;
158  return (sa->replay_window & (1ULL << diff)) ? 1 : 0;
159  }
160  else
161  {
162  sa->seq_hi = th;
163  if (seq <= tl)
164  return (sa->replay_window & (1ULL << diff)) ? 1 : 0;
165  else
166  return 0;
167  }
168  }
169 
170  return 0;
171 }
172 
173 always_inline void
175 {
176  u32 pos;
177 
178  if (seq > sa->last_seq)
179  {
180  pos = seq - sa->last_seq;
181  if (pos < ESP_WINDOW_SIZE)
182  sa->replay_window = ((sa->replay_window) << pos) | 1;
183  else
184  sa->replay_window = 1;
185  sa->last_seq = seq;
186  }
187  else
188  {
189  pos = sa->last_seq - seq;
190  sa->replay_window |= (1ULL << pos);
191  }
192 }
193 
194 always_inline void
196 {
197  int wrap = sa->seq_hi - sa->last_seq_hi;
198  u32 pos;
199 
200  if (wrap == 0 && seq > sa->last_seq)
201  {
202  pos = seq - sa->last_seq;
203  if (pos < ESP_WINDOW_SIZE)
204  sa->replay_window = ((sa->replay_window) << pos) | 1;
205  else
206  sa->replay_window = 1;
207  sa->last_seq = seq;
208  }
209  else if (wrap > 0)
210  {
211  pos = ~seq + sa->last_seq + 1;
212  if (pos < ESP_WINDOW_SIZE)
213  sa->replay_window = ((sa->replay_window) << pos) | 1;
214  else
215  sa->replay_window = 1;
216  sa->last_seq = seq;
217  sa->last_seq_hi = sa->seq_hi;
218  }
219  else if (wrap < 0)
220  {
221  pos = ~seq + sa->last_seq + 1;
222  sa->replay_window |= (1ULL << pos);
223  }
224  else
225  {
226  pos = sa->last_seq - seq;
227  sa->replay_window |= (1ULL << pos);
228  }
229 }
230 
231 static uword
233  vlib_node_runtime_t * node, vlib_frame_t * from_frame)
234 {
235  u32 n_left_from, *from, next_index, *to_next;
236  ipsec_main_t *im = &ipsec_main;
237  esp_main_t *em = &esp_main;
238  u32 *recycle = 0;
239  from = vlib_frame_vector_args (from_frame);
240  n_left_from = from_frame->n_vectors;
241  u32 cpu_index = os_get_cpu_number ();
242 
243  ipsec_alloc_empty_buffers (vm, im);
244 
245  u32 *empty_buffers = im->empty_buffers[cpu_index];
246 
247  if (PREDICT_FALSE (vec_len (empty_buffers) < n_left_from))
248  {
250  ESP_DECRYPT_ERROR_NO_BUFFER, n_left_from);
251  goto free_buffers_and_exit;
252  }
253 
254  next_index = node->cached_next_index;
255 
256  while (n_left_from > 0)
257  {
258  u32 n_left_to_next;
259 
260  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
261 
262  while (n_left_from > 0 && n_left_to_next > 0)
263  {
264  u32 i_bi0, o_bi0 = (u32) ~ 0, next0;
265  vlib_buffer_t *i_b0;
266  vlib_buffer_t *o_b0 = 0;
267  esp_header_t *esp0;
268  ipsec_sa_t *sa0;
269  u32 sa_index0 = ~0;
270  u32 seq;
271  ip4_header_t *ih4 = 0, *oh4 = 0;
272  ip6_header_t *ih6 = 0, *oh6 = 0;
273  u8 tunnel_mode = 1;
274  u8 transport_ip6 = 0;
275 
276 
277  i_bi0 = from[0];
278  from += 1;
279  n_left_from -= 1;
280  n_left_to_next -= 1;
281 
282  next0 = ESP_DECRYPT_NEXT_DROP;
283 
284  i_b0 = vlib_get_buffer (vm, i_bi0);
285  esp0 = vlib_buffer_get_current (i_b0);
286 
287  sa_index0 = vnet_buffer (i_b0)->output_features.ipsec_sad_index;
288  sa0 = pool_elt_at_index (im->sad, sa_index0);
289 
290  seq = clib_host_to_net_u32 (esp0->seq);
291 
292  /* anti-replay check */
293  if (sa0->use_anti_replay)
294  {
295  int rv = 0;
296 
297  if (PREDICT_TRUE (sa0->use_esn))
298  rv = esp_replay_check_esn (sa0, seq);
299  else
300  rv = esp_replay_check (sa0, seq);
301 
302  if (PREDICT_FALSE (rv))
303  {
304  clib_warning ("anti-replay SPI %u seq %u", sa0->spi, seq);
306  ESP_DECRYPT_ERROR_REPLAY, 1);
307  o_bi0 = i_bi0;
308  goto trace;
309  }
310  }
311 
312  if (PREDICT_TRUE (sa0->integ_alg != IPSEC_INTEG_ALG_NONE))
313  {
314  u8 sig[64];
315  int icv_size = em->esp_integ_algs[sa0->integ_alg].trunc_size;
316  memset (sig, 0, sizeof (sig));
317  u8 *icv =
318  vlib_buffer_get_current (i_b0) + i_b0->current_length -
319  icv_size;
320  i_b0->current_length -= icv_size;
321 
322  hmac_calc (sa0->integ_alg, sa0->integ_key, sa0->integ_key_len,
323  (u8 *) esp0, i_b0->current_length, sig, sa0->use_esn,
324  sa0->seq_hi);
325 
326  if (PREDICT_FALSE (memcmp (icv, sig, icv_size)))
327  {
329  ESP_DECRYPT_ERROR_INTEG_ERROR,
330  1);
331  o_bi0 = i_bi0;
332  goto trace;
333  }
334  }
335 
336  if (PREDICT_TRUE (sa0->use_anti_replay))
337  {
338  if (PREDICT_TRUE (sa0->use_esn))
339  esp_replay_advance_esn (sa0, seq);
340  else
341  esp_replay_advance (sa0, seq);
342  }
343 
344  /* grab free buffer */
345  uword last_empty_buffer = vec_len (empty_buffers) - 1;
346  o_bi0 = empty_buffers[last_empty_buffer];
347  o_b0 = vlib_get_buffer (vm, o_bi0);
349  empty_buffers[last_empty_buffer -
350  1], STORE);
351  _vec_len (empty_buffers) = last_empty_buffer;
352 
353  /* add old buffer to the recycle list */
354  vec_add1 (recycle, i_bi0);
355 
356  if (sa0->crypto_alg >= IPSEC_CRYPTO_ALG_AES_CBC_128 &&
357  sa0->crypto_alg <= IPSEC_CRYPTO_ALG_AES_CBC_256)
358  {
359  const int BLOCK_SIZE = 16;
360  const int IV_SIZE = 16;
361  esp_footer_t *f0;
362  u8 ip_hdr_size = 0;
363 
364  int blocks =
365  (i_b0->current_length - sizeof (esp_header_t) -
366  IV_SIZE) / BLOCK_SIZE;
367 
368  o_b0->current_data = sizeof (ethernet_header_t);
369 
370  /* transport mode */
371  if (PREDICT_FALSE (!sa0->is_tunnel && !sa0->is_tunnel_ip6))
372  {
373  tunnel_mode = 0;
374  ih4 =
375  (ip4_header_t *) (i_b0->data +
376  sizeof (ethernet_header_t));
377  if (PREDICT_TRUE
378  ((ih4->ip_version_and_header_length & 0xF0) != 0x40))
379  {
380  if (PREDICT_TRUE
381  ((ih4->ip_version_and_header_length & 0xF0) ==
382  0x60))
383  {
384  transport_ip6 = 1;
385  ip_hdr_size = sizeof (ip6_header_t);
386  ih6 =
387  (ip6_header_t *) (i_b0->data +
388  sizeof (ethernet_header_t));
389  oh6 = vlib_buffer_get_current (o_b0);
390  }
391  else
392  {
394  esp_decrypt_node.index,
395  ESP_DECRYPT_ERROR_NOT_IP,
396  1);
397  o_b0 = 0;
398  goto trace;
399  }
400  }
401  else
402  {
403  oh4 = vlib_buffer_get_current (o_b0);
404  ip_hdr_size = sizeof (ip4_header_t);
405  }
406  }
407 
409  esp0->data + IV_SIZE,
410  (u8 *) vlib_buffer_get_current (o_b0) +
411  ip_hdr_size, BLOCK_SIZE * blocks,
412  sa0->crypto_key, esp0->data);
413 
414  o_b0->current_length = (blocks * 16) - 2 + ip_hdr_size;
416  f0 =
417  (esp_footer_t *) ((u8 *) vlib_buffer_get_current (o_b0) +
418  o_b0->current_length);
419  o_b0->current_length -= f0->pad_length;
420 
421  /* tunnel mode */
422  if (PREDICT_TRUE (tunnel_mode))
423  {
424  if (PREDICT_TRUE (f0->next_header == IP_PROTOCOL_IP_IN_IP))
425  {
426  next0 = ESP_DECRYPT_NEXT_IP4_INPUT;
427  oh4 = vlib_buffer_get_current (o_b0);
428  }
429  else if (f0->next_header == IP_PROTOCOL_IPV6)
430  next0 = ESP_DECRYPT_NEXT_IP6_INPUT;
431  else
432  {
433  clib_warning ("next header: 0x%x", f0->next_header);
435  ESP_DECRYPT_ERROR_DECRYPTION_FAILED,
436  1);
437  o_b0 = 0;
438  goto trace;
439  }
440  }
441  /* transport mode */
442  else
443  {
444  if (PREDICT_FALSE (transport_ip6))
445  {
446  next0 = ESP_DECRYPT_NEXT_IP6_INPUT;
447  oh6->ip_version_traffic_class_and_flow_label =
449  oh6->protocol = f0->next_header;
450  oh6->hop_limit = ih6->hop_limit;
451  oh6->src_address.as_u64[0] = ih6->src_address.as_u64[0];
452  oh6->src_address.as_u64[1] = ih6->src_address.as_u64[1];
453  oh6->dst_address.as_u64[0] = ih6->dst_address.as_u64[0];
454  oh6->dst_address.as_u64[1] = ih6->dst_address.as_u64[1];
455  oh6->payload_length =
456  clib_host_to_net_u16 (vlib_buffer_length_in_chain
457  (vm,
458  o_b0) - sizeof (ip6_header_t));
459  }
460  else
461  {
462  next0 = ESP_DECRYPT_NEXT_IP4_INPUT;
463  oh4->ip_version_and_header_length = 0x45;
464  oh4->tos = ih4->tos;
465  oh4->fragment_id = 0;
466  oh4->flags_and_fragment_offset = 0;
467  oh4->ttl = ih4->ttl;
468  oh4->protocol = f0->next_header;
469  oh4->src_address.as_u32 = ih4->src_address.as_u32;
470  oh4->dst_address.as_u32 = ih4->dst_address.as_u32;
471  oh4->length =
472  clib_host_to_net_u16 (vlib_buffer_length_in_chain
473  (vm, o_b0));
474  oh4->checksum = ip4_header_checksum (oh4);
475  }
476  }
477 
478  /* for IPSec-GRE tunnel next node is ipsec-gre-input */
479  if (PREDICT_FALSE
480  ((vnet_buffer (i_b0)->output_features.ipsec_flags) &
482  next0 = ESP_DECRYPT_NEXT_IPSEC_GRE_INPUT;
483 
484  to_next[0] = o_bi0;
485  to_next += 1;
486 
487  vnet_buffer (o_b0)->sw_if_index[VLIB_TX] = (u32) ~ 0;
488  }
489 
490  trace:
492  {
493  if (o_b0)
494  {
495  o_b0->flags |= VLIB_BUFFER_IS_TRACED;
496  o_b0->trace_index = i_b0->trace_index;
497  esp_decrypt_trace_t *tr =
498  vlib_add_trace (vm, node, o_b0, sizeof (*tr));
499  tr->crypto_alg = sa0->crypto_alg;
500  tr->integ_alg = sa0->integ_alg;
501  }
502  }
503 
504  vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
505  n_left_to_next, o_bi0, next0);
506  }
507  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
508  }
510  ESP_DECRYPT_ERROR_RX_PKTS,
511  from_frame->n_vectors);
512 
513 free_buffers_and_exit:
514  if (recycle)
515  vlib_buffer_free (vm, recycle, vec_len (recycle));
516  vec_free (recycle);
517  return from_frame->n_vectors;
518 }
519 
520 
521 /* *INDENT-OFF* */
523  .function = esp_decrypt_node_fn,
524  .name = "esp-decrypt",
525  .vector_size = sizeof (u32),
526  .format_trace = format_esp_decrypt_trace,
528 
530  .error_strings = esp_decrypt_error_strings,
531 
532  .n_next_nodes = ESP_DECRYPT_N_NEXT,
533  .next_nodes = {
534 #define _(s,n) [ESP_DECRYPT_NEXT_##s] = n,
536 #undef _
537  },
538 };
539 /* *INDENT-ON* */
540 
542 /*
543  * fd.io coding-style-patch-verification: ON
544  *
545  * Local Variables:
546  * eval: (c-set-style "gnu")
547  * End:
548  */
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.
Definition: main.c:457
ipsec_crypto_alg_t last_decrypt_alg
Definition: esp.h:70
#define CLIB_UNUSED(x)
Definition: clib.h:79
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
Definition: memory_vlib.c:1168
ip4_address_t src_address
Definition: ip4_packet.h:138
bad routing header type(not 4)") sr_error (NO_MORE_SEGMENTS
#define PREDICT_TRUE(x)
Definition: clib.h:98
u64 as_u64[2]
Definition: ip6_packet.h:50
esp_decrypt_error_t
Definition: esp_decrypt.c:51
#define NULL
Definition: clib.h:55
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)
Definition: esp.h:132
ipsec_integ_alg_t integ_alg
Definition: ipsec.h:82
const EVP_CIPHER * type
Definition: esp.h:52
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:482
static void esp_replay_advance(ipsec_sa_t *sa, u32 seq)
Definition: esp_decrypt.c:174
ipsec_main_t ipsec_main
Definition: ipsec.h:238
ipsec_crypto_alg_t crypto_alg
Definition: esp_decrypt.c:67
static char * esp_decrypt_error_strings[]
Definition: esp_decrypt.c:59
u8 is_tunnel
Definition: ipsec.h:89
vlib_node_registration_t esp_decrypt_node
(constructor) VLIB_REGISTER_NODE (esp_decrypt_node)
Definition: esp_decrypt.c:522
static void ipsec_alloc_empty_buffers(vlib_main_t *vm, ipsec_main_t *im)
Definition: ipsec.h:281
esp_crypto_alg_t * esp_crypto_algs
Definition: esp.h:76
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:112
esp_integ_alg_t * esp_integ_algs
Definition: esp.h:77
ip6_address_t src_address
Definition: ip6_packet.h:298
esp_main_t esp_main
Definition: esp.h:81
u8 crypto_key[128]
Definition: ipsec.h:80
u32 spi
Definition: ipsec.h:75
u32 seq_hi
Definition: ipsec.h:96
u8 trunc_size
Definition: esp.h:58
u64 replay_window
Definition: ipsec.h:99
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:78
u8 integ_key[128]
Definition: ipsec.h:84
#define vlib_prefetch_buffer_with_index(vm, bi, type)
Prefetch buffer metadata by buffer index The first 64 bytes of buffer contains most header informatio...
Definition: buffer_funcs.h:182
#define always_inline
Definition: clib.h:84
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:187
ip4_address_t dst_address
Definition: ip4_packet.h:138
u8 use_esn
Definition: ipsec.h:86
static u8 * format_esp_decrypt_trace(u8 *s, va_list *args)
Definition: esp_decrypt.c:73
#define clib_warning(format, args...)
Definition: error.h:59
u8 data[0]
Definition: esp.h:27
u8 * format_ipsec_integ_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:90
u32 last_seq
Definition: ipsec.h:97
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:369
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:82
u8 is_tunnel_ip6
Definition: ipsec.h:90
static int esp_replay_check(ipsec_sa_t *sa, u32 seq)
Definition: esp_decrypt.c:113
uword os_get_cpu_number(void)
Definition: unix-misc.c:224
u32 last_seq_hi
Definition: ipsec.h:98
#define PREDICT_FALSE(x)
Definition: clib.h:97
#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.
Definition: buffer_node.h:130
#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).
Definition: node_funcs.h:348
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1111
#define ESP_WINDOW_SIZE
Definition: esp_decrypt.c:25
esp_decrypt_next_t
Definition: esp_decrypt.c:34
static void esp_replay_advance_esn(ipsec_sa_t *sa, u32 seq)
Definition: esp_decrypt.c:195
u16 n_vectors
Definition: node.h:344
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:300
static int esp_replay_check_esn(ipsec_sa_t *sa, u32 seq)
Definition: esp_decrypt.c:131
#define VLIB_BUFFER_TOTAL_LENGTH_VALID
Definition: buffer.h:97
#define ARRAY_LEN(x)
Definition: clib.h:59
static uword esp_decrypt_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: esp_decrypt.c:232
#define foreach_esp_decrypt_next
Definition: esp_decrypt.c:27
u16 cached_next_index
Definition: node.h:462
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
#define vnet_buffer(b)
Definition: buffer.h:335
ipsec_sa_t * sad
Definition: ipsec.h:208
u8 * format(u8 *s, char *fmt,...)
Definition: format.c:418
void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
Definition: dpdk_buffer.c:766
ipsec_crypto_alg_t
Definition: ipsec.h:41
u8 integ_key_len
Definition: ipsec.h:83
u32 seq
Definition: esp.h:26
#define VLIB_BUFFER_IS_TRACED
Definition: buffer.h:93
u64 uword
Definition: types.h:112
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace_funcs.h:55
u32 ip_version_traffic_class_and_flow_label
Definition: ip6_packet.h:285
Definition: defs.h:47
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:251
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
Definition: node.h:158
ipsec_crypto_alg_t crypto_alg
Definition: ipsec.h:78
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:143
u8 data[0]
Packet data.
Definition: buffer.h:151
Definition: esp.h:74
u8 ip_version_and_header_length
Definition: ip4_packet.h:108
static void esp_decrypt_aes_cbc(ipsec_crypto_alg_t alg, u8 *in, u8 *out, size_t in_len, u8 *key, u8 *iv)
Definition: esp_decrypt.c:86
#define foreach_esp_decrypt_error
Definition: esp_decrypt.c:42
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:85
u32 ** empty_buffers
Definition: ipsec.h:214
u8 * format_ipsec_crypto_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:58
u8 use_anti_replay
Definition: ipsec.h:87
esp_main_per_thread_data_t * per_thread_data
Definition: esp.h:78
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:69
u32 trace_index
Specifies index into trace buffer if VLIB_PACKET_IS_TRACED flag is set.
Definition: buffer.h:135
static u16 ip4_header_checksum(ip4_header_t *i)
Definition: ip4_packet.h:194
EVP_CIPHER_CTX decrypt_ctx
Definition: esp.h:66
#define IPSEC_FLAG_IPSEC_GRE_TUNNEL
Definition: ipsec.h:19
ipsec_integ_alg_t integ_alg
Definition: esp_decrypt.c:68
ip6_address_t dst_address
Definition: ip6_packet.h:298
ipsec_integ_alg_t
Definition: ipsec.h:58