FD.io VPP  v17.07.01-10-g3be13f0
Vector Packet Processing
esp_decrypt.c
Go to the documentation of this file.
1 /*
2  * esp_decrypt.c : IPSec ESP Decrypt node using DPDK Cryptodev
3  *
4  * Copyright (c) 2016 Intel 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 <dpdk/ipsec/ipsec.h>
24 #include <dpdk/ipsec/esp.h>
25 #include <dpdk/device/dpdk.h>
26 #include <dpdk/device/dpdk_priv.h>
27 
28 #define foreach_esp_decrypt_next \
29 _(DROP, "error-drop") \
30 _(IP4_INPUT, "ip4-input") \
31 _(IP6_INPUT, "ip6-input")
32 
33 #define _(v, s) ESP_DECRYPT_NEXT_##v,
34 typedef enum {
36 #undef _
39 
40 #define foreach_esp_decrypt_error \
41  _(RX_PKTS, "ESP pkts received") \
42  _(DECRYPTION_FAILED, "ESP decryption failed") \
43  _(REPLAY, "SA replayed packet") \
44  _(NOT_IP, "Not IP packet (dropped)") \
45  _(ENQ_FAIL, "Enqueue failed (buffer full)") \
46  _(NO_CRYPTODEV, "Cryptodev not configured") \
47  _(BAD_LEN, "Invalid ciphertext length") \
48  _(UNSUPPORTED, "Cipher/Auth not supported")
49 
50 
51 typedef enum {
52 #define _(sym,str) ESP_DECRYPT_ERROR_##sym,
54 #undef _
57 
58 static char * esp_decrypt_error_strings[] = {
59 #define _(sym,string) string,
61 #undef _
62 };
63 
65 
66 typedef struct {
67  ipsec_crypto_alg_t crypto_alg;
68  ipsec_integ_alg_t integ_alg;
70 
71 /* packet trace format function */
72 static u8 * format_esp_decrypt_trace (u8 * s, va_list * args)
73 {
74  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
75  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
76  esp_decrypt_trace_t * t = va_arg (*args, esp_decrypt_trace_t *);
77 
78  s = format (s, "esp: crypto %U integrity %U",
81  return s;
82 }
83 
84 static uword
86  vlib_node_runtime_t * node,
87  vlib_frame_t * from_frame)
88 {
89  u32 n_left_from, *from, *to_next, next_index;
90  ipsec_main_t *im = &ipsec_main;
91  u32 thread_index = vlib_get_thread_index();
94  u32 i;
95 
96  from = vlib_frame_vector_args (from_frame);
97  n_left_from = from_frame->n_vectors;
98 
100  vec_elt_at_index(dcm->workers_main, thread_index);
101  u32 n_qps = vec_len(cwm->qp_data);
102  struct rte_crypto_op ** cops_to_enq[n_qps];
103  u32 n_cop_qp[n_qps], * bi_to_enq[n_qps];
104 
105  for (i = 0; i < n_qps; i++)
106  {
107  bi_to_enq[i] = cwm->qp_data[i].bi;
108  cops_to_enq[i] = cwm->qp_data[i].cops;
109  }
110 
111  memset(n_cop_qp, 0, n_qps * sizeof(u32));
112 
114 
115  next_index = ESP_DECRYPT_NEXT_DROP;
116 
117  while (n_left_from > 0)
118  {
119  u32 n_left_to_next;
120 
121  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
122 
123  while (n_left_from > 0 && n_left_to_next > 0)
124  {
125  u32 bi0, sa_index0 = ~0, seq, icv_size, iv_size;
126  vlib_buffer_t * b0;
127  esp_header_t * esp0;
128  ipsec_sa_t * sa0;
129  struct rte_mbuf * mb0 = 0;
130  const int BLOCK_SIZE = 16;
131  crypto_sa_session_t * sa_sess;
132  void * sess;
133  u16 qp_index;
134  struct rte_crypto_op * cop = 0;
135 
136  bi0 = from[0];
137  from += 1;
138  n_left_from -= 1;
139 
140  b0 = vlib_get_buffer (vm, bi0);
141  esp0 = vlib_buffer_get_current (b0);
142 
143  sa_index0 = vnet_buffer(b0)->ipsec.sad_index;
144  sa0 = pool_elt_at_index (im->sad, sa_index0);
145 
146  seq = clib_host_to_net_u32(esp0->seq);
147 
148  /* anti-replay check */
149  if (sa0->use_anti_replay)
150  {
151  int rv = 0;
152 
153  if (PREDICT_TRUE(sa0->use_esn))
154  rv = esp_replay_check_esn(sa0, seq);
155  else
156  rv = esp_replay_check(sa0, seq);
157 
158  if (PREDICT_FALSE(rv))
159  {
160  clib_warning ("anti-replay SPI %u seq %u", sa0->spi, seq);
162  ESP_DECRYPT_ERROR_REPLAY, 1);
163  to_next[0] = bi0;
164  to_next += 1;
165  n_left_to_next -= 1;
166  goto trace;
167  }
168  }
169 
170  sa0->total_data_size += b0->current_length;
171 
172  if (PREDICT_FALSE(sa0->integ_alg == IPSEC_INTEG_ALG_NONE) ||
173  PREDICT_FALSE(sa0->crypto_alg == IPSEC_CRYPTO_ALG_NONE))
174  {
175  clib_warning ("SPI %u : only cipher + auth supported", sa0->spi);
177  ESP_DECRYPT_ERROR_UNSUPPORTED, 1);
178  to_next[0] = bi0;
179  to_next += 1;
180  n_left_to_next -= 1;
181  goto trace;
182  }
183 
184  sa_sess = pool_elt_at_index(cwm->sa_sess_d[0], sa_index0);
185 
186  if (PREDICT_FALSE(!sa_sess->sess))
187  {
188  int ret = create_sym_sess(sa0, sa_sess, 0);
189 
190  if (PREDICT_FALSE (ret))
191  {
192  to_next[0] = bi0;
193  to_next += 1;
194  n_left_to_next -= 1;
195  goto trace;
196  }
197  }
198 
199  sess = sa_sess->sess;
200  qp_index = sa_sess->qp_index;
201 
202  ASSERT (vec_len (vec_elt (cwm->qp_data, qp_index).free_cops) > 0);
203  cop = vec_pop (vec_elt (cwm->qp_data, qp_index).free_cops);
204  ASSERT (cop->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED);
205 
206  cops_to_enq[qp_index][0] = cop;
207  cops_to_enq[qp_index] += 1;
208  n_cop_qp[qp_index] += 1;
209  bi_to_enq[qp_index][0] = bi0;
210  bi_to_enq[qp_index] += 1;
211 
212  rte_crypto_op_attach_sym_session(cop, sess);
213 
214  icv_size = em->esp_integ_algs[sa0->integ_alg].trunc_size;
215  iv_size = em->esp_crypto_algs[sa0->crypto_alg].iv_len;
216 
217  /* Convert vlib buffer to mbuf */
218  mb0 = rte_mbuf_from_vlib_buffer(b0);
219  mb0->data_len = b0->current_length;
220  mb0->pkt_len = b0->current_length;
221  mb0->data_off = RTE_PKTMBUF_HEADROOM + b0->current_data;
222 
223  /* Outer IP header has already been stripped */
224  u16 payload_len = rte_pktmbuf_pkt_len(mb0) - sizeof (esp_header_t) -
225  iv_size - icv_size;
226 
227  if ((payload_len & (BLOCK_SIZE - 1)) || (payload_len <= 0))
228  {
229  clib_warning ("payload %u not multiple of %d\n",
230  payload_len, BLOCK_SIZE);
232  ESP_DECRYPT_ERROR_BAD_LEN, 1);
233  vec_add (vec_elt (cwm->qp_data, qp_index).free_cops, &cop, 1);
234  bi_to_enq[qp_index] -= 1;
235  cops_to_enq[qp_index] -= 1;
236  n_cop_qp[qp_index] -= 1;
237  to_next[0] = bi0;
238  to_next += 1;
239  n_left_to_next -= 1;
240  goto trace;
241  }
242 
243  struct rte_crypto_sym_op *sym_cop = (struct rte_crypto_sym_op *)(cop + 1);
244 
245  sym_cop->m_src = mb0;
246  sym_cop->cipher.data.offset = sizeof (esp_header_t) + iv_size;
247  sym_cop->cipher.data.length = payload_len;
248 
249  u8 *iv = rte_pktmbuf_mtod_offset(mb0, void*, sizeof (esp_header_t));
250  dpdk_cop_priv_t * priv = (dpdk_cop_priv_t *)(sym_cop + 1);
251 
252  if (sa0->crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
253  {
254  dpdk_gcm_cnt_blk *icb = &priv->cb;
255  icb->salt = sa0->salt;
256  clib_memcpy(icb->iv, iv, 8);
257  icb->cnt = clib_host_to_net_u32(1);
258  sym_cop->cipher.iv.data = (u8 *)icb;
259  sym_cop->cipher.iv.phys_addr = cop->phys_addr +
260  (uintptr_t)icb - (uintptr_t)cop;
261  sym_cop->cipher.iv.length = 16;
262 
263  u8 *aad = priv->aad;
264  clib_memcpy(aad, iv - sizeof(esp_header_t), 8);
265  sym_cop->auth.aad.data = aad;
266  sym_cop->auth.aad.phys_addr = cop->phys_addr +
267  (uintptr_t)aad - (uintptr_t)cop;
268  if (sa0->use_esn)
269  {
270  *((u32*)&aad[8]) = sa0->seq_hi;
271  sym_cop->auth.aad.length = 12;
272  }
273  else
274  {
275  sym_cop->auth.aad.length = 8;
276  }
277 
278  sym_cop->auth.digest.data = rte_pktmbuf_mtod_offset(mb0, void*,
279  rte_pktmbuf_pkt_len(mb0) - icv_size);
280  sym_cop->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(mb0,
281  rte_pktmbuf_pkt_len(mb0) - icv_size);
282  sym_cop->auth.digest.length = icv_size;
283 
284  }
285  else
286  {
287  sym_cop->cipher.iv.data = rte_pktmbuf_mtod_offset(mb0, void*,
288  sizeof (esp_header_t));
289  sym_cop->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(mb0,
290  sizeof (esp_header_t));
291  sym_cop->cipher.iv.length = iv_size;
292 
293  if (sa0->use_esn)
294  {
295  dpdk_cop_priv_t* priv = (dpdk_cop_priv_t*) (sym_cop + 1);
296  u8* payload_end = rte_pktmbuf_mtod_offset(
297  mb0, u8*, sizeof(esp_header_t) + iv_size + payload_len);
298 
299  clib_memcpy (priv->icv, payload_end, icv_size);
300  *((u32*) payload_end) = sa0->seq_hi;
301  sym_cop->auth.data.offset = 0;
302  sym_cop->auth.data.length = sizeof(esp_header_t) + iv_size
303  + payload_len + sizeof(sa0->seq_hi);
304  sym_cop->auth.digest.data = priv->icv;
305  sym_cop->auth.digest.phys_addr = cop->phys_addr
306  + (uintptr_t) priv->icv - (uintptr_t) cop;
307  sym_cop->auth.digest.length = icv_size;
308  }
309  else
310  {
311  sym_cop->auth.data.offset = 0;
312  sym_cop->auth.data.length = sizeof(esp_header_t) +
313  iv_size + payload_len;
314 
315  sym_cop->auth.digest.data = rte_pktmbuf_mtod_offset(mb0, void*,
316  rte_pktmbuf_pkt_len(mb0) - icv_size);
317  sym_cop->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(mb0,
318  rte_pktmbuf_pkt_len(mb0) - icv_size);
319  sym_cop->auth.digest.length = icv_size;
320  }
321  }
322 
323 trace:
325  {
326  esp_decrypt_trace_t *tr = vlib_add_trace (vm, node, b0, sizeof (*tr));
327  tr->crypto_alg = sa0->crypto_alg;
328  tr->integ_alg = sa0->integ_alg;
329  }
330  }
331  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
332  }
334  ESP_DECRYPT_ERROR_RX_PKTS,
335  from_frame->n_vectors);
336  crypto_qp_data_t *qpd;
337  /* *INDENT-OFF* */
338  vec_foreach_index (i, cwm->qp_data)
339  {
340  u32 enq;
341 
342  qpd = vec_elt_at_index(cwm->qp_data, i);
343  enq = rte_cryptodev_enqueue_burst(qpd->dev_id, qpd->qp_id,
344  qpd->cops, n_cop_qp[i]);
345  qpd->inflights += enq;
346 
347  if (PREDICT_FALSE(enq < n_cop_qp[i]))
348  {
349  crypto_free_cop (qpd, &qpd->cops[enq], n_cop_qp[i] - enq);
350  vlib_buffer_free (vm, &qpd->bi[enq], n_cop_qp[i] - enq);
351 
353  ESP_DECRYPT_ERROR_ENQ_FAIL,
354  n_cop_qp[i] - enq);
355  }
356  }
357  /* *INDENT-ON* */
358 
359  return from_frame->n_vectors;
360 }
361 
362 /* *INDENT-OFF* */
364  .function = dpdk_esp_decrypt_node_fn,
365  .name = "dpdk-esp-decrypt",
366  .vector_size = sizeof (u32),
367  .format_trace = format_esp_decrypt_trace,
368  .type = VLIB_NODE_TYPE_INTERNAL,
369 
371  .error_strings = esp_decrypt_error_strings,
372 
373  .n_next_nodes = ESP_DECRYPT_N_NEXT,
374  .next_nodes = {
375 #define _(s,n) [ESP_DECRYPT_NEXT_##s] = n,
377 #undef _
378  },
379 };
380 /* *INDENT-ON* */
381 
383 
384 /*
385  * Decrypt Post Node
386  */
387 
388 #define foreach_esp_decrypt_post_error \
389  _(PKTS, "ESP post pkts")
390 
391 typedef enum {
392 #define _(sym,str) ESP_DECRYPT_POST_ERROR_##sym,
394 #undef _
397 
399 #define _(sym,string) string,
401 #undef _
402 };
403 
405 
406 static u8 * format_esp_decrypt_post_trace (u8 * s, va_list * args)
407 {
408  return s;
409 }
410 
411 static uword
413  vlib_node_runtime_t * node,
414  vlib_frame_t * from_frame)
415 {
416  u32 n_left_from, *from, *to_next = 0, next_index;
417  ipsec_sa_t * sa0;
418  u32 sa_index0 = ~0;
419  ipsec_main_t *im = &ipsec_main;
421 
422  from = vlib_frame_vector_args (from_frame);
423  n_left_from = from_frame->n_vectors;
424 
425  next_index = node->cached_next_index;
426 
427  while (n_left_from > 0)
428  {
429  u32 n_left_to_next;
430 
431  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
432 
433  while (n_left_from > 0 && n_left_to_next > 0)
434  {
435  esp_footer_t * f0;
436  u32 bi0, next0, icv_size, iv_size;
437  vlib_buffer_t * b0 = 0;
438  ip4_header_t *ih4 = 0, *oh4 = 0;
439  ip6_header_t *ih6 = 0, *oh6 = 0;
440  u8 tunnel_mode = 1;
441  u8 transport_ip6 = 0;
442 
443  next0 = ESP_DECRYPT_NEXT_DROP;
444 
445  bi0 = from[0];
446  from += 1;
447  n_left_from -= 1;
448  n_left_to_next -= 1;
449 
450  b0 = vlib_get_buffer (vm, bi0);
451 
452  sa_index0 = vnet_buffer(b0)->ipsec.sad_index;
453  sa0 = pool_elt_at_index (im->sad, sa_index0);
454 
455  to_next[0] = bi0;
456  to_next += 1;
457 
458  icv_size = em->esp_integ_algs[sa0->integ_alg].trunc_size;
459  iv_size = em->esp_crypto_algs[sa0->crypto_alg].iv_len;
460 
461  if (sa0->use_anti_replay)
462  {
464  u32 seq;
465  seq = clib_host_to_net_u32(esp0->seq);
466  if (PREDICT_TRUE(sa0->use_esn))
467  esp_replay_advance_esn(sa0, seq);
468  else
469  esp_replay_advance(sa0, seq);
470  }
471 
472  ih4 = (ip4_header_t *) (b0->data + sizeof(ethernet_header_t));
473  vlib_buffer_advance (b0, sizeof (esp_header_t) + iv_size);
474 
475  b0->current_length -= (icv_size + 2);
477  f0 = (esp_footer_t *) ((u8 *) vlib_buffer_get_current (b0) +
478  b0->current_length);
479  b0->current_length -= f0->pad_length;
480 
481  /* transport mode */
482  if (PREDICT_FALSE(!sa0->is_tunnel && !sa0->is_tunnel_ip6))
483  {
484  tunnel_mode = 0;
485 
486  if (PREDICT_TRUE((ih4->ip_version_and_header_length & 0xF0) != 0x40))
487  {
488  if (PREDICT_TRUE((ih4->ip_version_and_header_length & 0xF0) == 0x60))
489  transport_ip6 = 1;
490  else
491  {
492  clib_warning("next header: 0x%x", f0->next_header);
494  ESP_DECRYPT_ERROR_NOT_IP, 1);
495  goto trace;
496  }
497  }
498  }
499 
500  if (PREDICT_TRUE (tunnel_mode))
501  {
502  if (PREDICT_TRUE(f0->next_header == IP_PROTOCOL_IP_IN_IP))
503  next0 = ESP_DECRYPT_NEXT_IP4_INPUT;
504  else if (f0->next_header == IP_PROTOCOL_IPV6)
505  next0 = ESP_DECRYPT_NEXT_IP6_INPUT;
506  else
507  {
508  clib_warning("next header: 0x%x", f0->next_header);
510  ESP_DECRYPT_ERROR_DECRYPTION_FAILED,
511  1);
512  goto trace;
513  }
514  }
515  /* transport mode */
516  else
517  {
518  if (PREDICT_FALSE(transport_ip6))
519  {
520  ih6 = (ip6_header_t *) (b0->data + sizeof(ethernet_header_t));
521  vlib_buffer_advance (b0, -sizeof(ip6_header_t));
522  oh6 = vlib_buffer_get_current (b0);
523  memmove(oh6, ih6, sizeof(ip6_header_t));
524 
525  next0 = ESP_DECRYPT_NEXT_IP6_INPUT;
526  oh6->protocol = f0->next_header;
527  oh6->payload_length =
528  clib_host_to_net_u16 (
530  sizeof (ip6_header_t));
531  }
532  else
533  {
534  vlib_buffer_advance (b0, -sizeof(ip4_header_t));
535  oh4 = vlib_buffer_get_current (b0);
536  memmove(oh4, ih4, sizeof(ip4_header_t));
537 
538  next0 = ESP_DECRYPT_NEXT_IP4_INPUT;
539  oh4->ip_version_and_header_length = 0x45;
540  oh4->fragment_id = 0;
541  oh4->flags_and_fragment_offset = 0;
542  oh4->protocol = f0->next_header;
543  oh4->length = clib_host_to_net_u16 (
544  vlib_buffer_length_in_chain (vm, b0));
545  oh4->checksum = ip4_header_checksum (oh4);
546  }
547  }
548 
549  vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32)~0;
550 
551 trace:
553  {
554  esp_decrypt_trace_t *tr = vlib_add_trace (vm, node, b0, sizeof (*tr));
555  tr->crypto_alg = sa0->crypto_alg;
556  tr->integ_alg = sa0->integ_alg;
557  }
558 
559  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
560  to_next, n_left_to_next, bi0, next0);
561  }
562  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
563  }
565  ESP_DECRYPT_POST_ERROR_PKTS,
566  from_frame->n_vectors);
567 
568  return from_frame->n_vectors;
569 }
570 
571 /* *INDENT-OFF* */
573  .function = dpdk_esp_decrypt_post_node_fn,
574  .name = "dpdk-esp-decrypt-post",
575  .vector_size = sizeof (u32),
576  .format_trace = format_esp_decrypt_post_trace,
577  .type = VLIB_NODE_TYPE_INTERNAL,
578 
580  .error_strings = esp_decrypt_post_error_strings,
581 
582  .n_next_nodes = ESP_DECRYPT_N_NEXT,
583  .next_nodes = {
584 #define _(s,n) [ESP_DECRYPT_NEXT_##s] = n,
586 #undef _
587  },
588 };
589 /* *INDENT-ON* */
590 
u32 bi[VLIB_FRAME_SIZE]
Definition: ipsec.h:64
#define vec_foreach_index(var, v)
Iterate over vector indices.
sll srl srl sll sra u16x4 i
Definition: vector_sse2.h:337
static void esp_replay_advance(ipsec_sa_t *sa, u32 seq)
Definition: esp.h:149
#define CLIB_UNUSED(x)
Definition: clib.h:79
static void vlib_buffer_free(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Free buffers Frees the entire buffer chain for each buffer.
Definition: buffer_funcs.h:290
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
Definition: memory_vlib.c:1173
static char * esp_decrypt_post_error_strings[]
Definition: esp_decrypt.c:398
u8 aad[12]
Definition: ipsec.h:46
static u8 * format_esp_decrypt_post_trace(u8 *s, va_list *args)
Definition: esp_decrypt.c:406
#define PREDICT_TRUE(x)
Definition: clib.h:98
static int esp_replay_check(ipsec_sa_t *sa, u32 seq)
Definition: esp.h:87
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:459
ipsec_integ_alg_t integ_alg
Definition: ipsec.h:110
ipsec_crypto_alg_t crypto_alg
Definition: esp_decrypt.c:65
vlib_node_registration_t dpdk_esp_decrypt_post_node
(constructor) VLIB_REGISTER_NODE (dpdk_esp_decrypt_post_node)
Definition: esp_decrypt.c:404
u8 is_tunnel
Definition: ipsec.h:117
struct _vlib_node_registration vlib_node_registration_t
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
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:100
esp_decrypt_next_t
Definition: esp_decrypt.c:32
static void esp_replay_advance_esn(ipsec_sa_t *sa, u32 seq)
Definition: esp.h:170
#define vec_pop(V)
Returns last element of a vector and decrements its length.
Definition: vec.h:616
static_always_inline void crypto_free_cop(crypto_qp_data_t *qpd, struct rte_crypto_op **cops, u32 n)
Definition: ipsec.h:128
static char * esp_decrypt_error_strings[]
Definition: esp_decrypt.c:58
dpdk_crypto_main_t dpdk_crypto_main
Definition: ipsec.h:89
u32 spi
Definition: ipsec.h:103
u32 seq_hi
Definition: ipsec.h:126
#define vec_add(V, E, N)
Add N elements to end of vector V (no header, unspecified alignment)
Definition: vec.h:599
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:67
#define foreach_esp_decrypt_next
Definition: esp_decrypt.c:28
static_always_inline void crypto_alloc_cops()
Definition: ipsec.h:96
ipsec_main_t ipsec_main
Definition: ipsec.h:282
#define foreach_esp_decrypt_post_error
Definition: esp_decrypt.c:388
u8 use_esn
Definition: ipsec.h:114
#define VLIB_BUFFER_TOTAL_LENGTH_VALID
Definition: buffer.h:89
dpdk_esp_main_t dpdk_esp_main
Definition: esp.h:41
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
dpdk_esp_integ_alg_t * esp_integ_algs
Definition: esp.h:38
i16 inflights
Definition: ipsec.h:63
u8 * format_ipsec_crypto_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:58
dpdk_esp_crypto_alg_t * esp_crypto_algs
Definition: esp.h:37
u32 iv[2]
Definition: ipsec.h:37
static uword dpdk_esp_decrypt_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: esp_decrypt.c:85
#define rte_mbuf_from_vlib_buffer(x)
Definition: dpdk_priv.h:16
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:397
ipsec_integ_alg_t
Definition: ipsec.h:86
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:71
u8 is_tunnel_ip6
Definition: ipsec.h:118
u32 salt
Definition: ipsec.h:122
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:188
static uword dpdk_esp_decrypt_post_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: esp_decrypt.c:412
#define PREDICT_FALSE(x)
Definition: clib.h:97
struct rte_crypto_op * cops[VLIB_FRAME_SIZE]
Definition: ipsec.h:65
#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:216
#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:366
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1131
esp_decrypt_post_error_t
Definition: esp_decrypt.c:391
static int esp_replay_check_esn(ipsec_sa_t *sa, u32 seq)
Definition: esp.h:105
dpdk_gcm_cnt_blk cb
Definition: ipsec.h:43
u16 n_vectors
Definition: node.h:345
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:185
#define clib_warning(format, args...)
Definition: error.h:59
#define VLIB_BUFFER_IS_TRACED
Definition: buffer.h:85
#define clib_memcpy(a, b, c)
Definition: string.h:69
#define ARRAY_LEN(x)
Definition: clib.h:59
u8 icv[64]
Definition: ipsec.h:47
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
Definition: node.h:460
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
esp_decrypt_error_t
Definition: esp_decrypt.c:49
ipsec_sa_t * sad
Definition: ipsec.h:247
ipsec_crypto_alg_t
Definition: ipsec.h:68
crypto_worker_main_t * workers_main
Definition: ipsec.h:85
u64 total_data_size
Definition: ipsec.h:132
u32 seq
Definition: esp.h:25
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:201
crypto_qp_data_t * qp_data
Definition: ipsec.h:78
crypto_sa_session_t * sa_sess_d[2]
Definition: ipsec.h:77
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
#define vec_elt(v, i)
Get vector value at index i.
u8 * format_ipsec_integ_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:90
Definition: defs.h:47
unsigned short u16
Definition: types.h:57
#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:269
static u8 * format_esp_decrypt_trace(u8 *s, va_list *args)
Definition: esp_decrypt.c:72
#define vnet_buffer(b)
Definition: buffer.h:304
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
Definition: node.h:159
ipsec_crypto_alg_t crypto_alg
Definition: ipsec.h:106
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:144
u8 data[0]
Packet data.
Definition: buffer.h:152
u8 ip_version_and_header_length
Definition: ip4_packet.h:132
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:74
#define foreach_esp_decrypt_error
Definition: esp_decrypt.c:40
u8 use_anti_replay
Definition: ipsec.h:115
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:57
static u16 ip4_header_checksum(ip4_header_t *i)
Definition: ip4_packet.h:239
ipsec_integ_alg_t integ_alg
Definition: esp_decrypt.c:66
static_always_inline int create_sym_sess(ipsec_sa_t *sa, crypto_sa_session_t *sa_sess, u8 is_outbound)
Definition: esp.h:170
vlib_node_registration_t dpdk_esp_decrypt_node
(constructor) VLIB_REGISTER_NODE (dpdk_esp_decrypt_node)
Definition: esp_decrypt.c:64