FD.io VPP  v19.04-6-g6f05f72
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) 2017 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 opy 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 <dpdk/buffer.h>
25 #include <dpdk/ipsec/ipsec.h>
26 #include <dpdk/device/dpdk.h>
27 #include <dpdk/device/dpdk_priv.h>
28 
29 #define foreach_esp_decrypt_next \
30 _(DROP, "error-drop") \
31 _(IP4_INPUT, "ip4-input-no-checksum") \
32 _(IP6_INPUT, "ip6-input")
33 
34 #define _(v, s) ESP_DECRYPT_NEXT_##v,
35 typedef enum
36 {
38 #undef _
41 
42 #define foreach_esp_decrypt_error \
43  _(RX_PKTS, "ESP pkts received") \
44  _(DECRYPTION_FAILED, "ESP decryption failed") \
45  _(REPLAY, "SA replayed packet") \
46  _(NOT_IP, "Not IP packet (dropped)") \
47  _(ENQ_FAIL, "Enqueue failed (buffer full)") \
48  _(DISCARD, "Not enough crypto operations, discarding frame") \
49  _(BAD_LEN, "Invalid ciphertext length") \
50  _(SESSION, "Failed to get crypto session") \
51  _(NOSUP, "Cipher/Auth not supported")
52 
53 
54 typedef enum
55 {
56 #define _(sym,str) ESP_DECRYPT_ERROR_##sym,
58 #undef _
61 
62 static char *esp_decrypt_error_strings[] = {
63 #define _(sym,string) string,
65 #undef _
66 };
67 
70 
71 typedef struct
72 {
73  ipsec_crypto_alg_t crypto_alg;
74  ipsec_integ_alg_t integ_alg;
75  u8 packet_data[64];
77 
78 /* packet trace format function */
79 static u8 *
80 format_esp_decrypt_trace (u8 * s, va_list * args)
81 {
82  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
83  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
84  esp_decrypt_trace_t *t = va_arg (*args, esp_decrypt_trace_t *);
85  u32 indent = format_get_indent (s);
86 
87  s = format (s, "cipher %U auth %U\n",
90  s = format (s, "%U%U",
92  return s;
93 }
94 
97  vlib_node_runtime_t * node,
98  vlib_frame_t * from_frame, int is_ip6)
99 {
100  u32 n_left_from, *from, *to_next, next_index, thread_index;
101  ipsec_main_t *im = &ipsec_main;
102  u32 thread_idx = vlib_get_thread_index ();
104  crypto_resource_t *res = 0;
105  ipsec_sa_t *sa0 = 0;
106  crypto_alg_t *cipher_alg = 0, *auth_alg = 0;
107  struct rte_cryptodev_sym_session *session = 0;
108  u32 ret, last_sa_index = ~0;
109  u8 numa = rte_socket_id ();
110  u8 is_aead = 0;
111  crypto_worker_main_t *cwm =
112  vec_elt_at_index (dcm->workers_main, thread_idx);
113  struct rte_crypto_op **ops = cwm->ops;
114 
115  from = vlib_frame_vector_args (from_frame);
116  n_left_from = from_frame->n_vectors;
117  thread_index = vm->thread_index;
118 
119  ret = crypto_alloc_ops (numa, ops, n_left_from);
120  if (ret)
121  {
122  if (is_ip6)
124  ESP_DECRYPT_ERROR_DISCARD, 1);
125  else
127  ESP_DECRYPT_ERROR_DISCARD, 1);
128  /* Discard whole frame */
129  return n_left_from;
130  }
131 
132  next_index = ESP_DECRYPT_NEXT_DROP;
133 
134  while (n_left_from > 0)
135  {
136  u32 n_left_to_next;
137 
138  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
139 
140  while (n_left_from > 0 && n_left_to_next > 0)
141  {
142  clib_error_t *error;
143  u32 bi0, sa_index0, iv_size;
144  u8 trunc_size;
145  vlib_buffer_t *b0;
146  esp_header_t *esp0;
147  struct rte_mbuf *mb0;
148  struct rte_crypto_op *op;
149  u16 res_idx;
150 
151  bi0 = from[0];
152  from += 1;
153  n_left_from -= 1;
154 
155  b0 = vlib_get_buffer (vm, bi0);
156  mb0 = rte_mbuf_from_vlib_buffer (b0);
157  esp0 = vlib_buffer_get_current (b0);
158 
159  /* ih0/ih6_0 */
160  CLIB_PREFETCH (esp0, sizeof (esp0[0]) + 16, LOAD);
161  /* mb0 */
162  CLIB_PREFETCH (mb0, CLIB_CACHE_LINE_BYTES, STORE);
163 
164  op = ops[0];
165  ops += 1;
166  ASSERT (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED);
167 
168  dpdk_op_priv_t *priv = crypto_op_get_priv (op);
169  /* store bi in op private */
170  priv->bi = bi0;
171 
172  u16 op_len =
173  sizeof (op[0]) + sizeof (op[0].sym[0]) + sizeof (priv[0]);
174  CLIB_PREFETCH (op, op_len, STORE);
175 
176  sa_index0 = vnet_buffer (b0)->ipsec.sad_index;
178  thread_index, sa_index0);
179 
180  if (sa_index0 != last_sa_index)
181  {
182  sa0 = pool_elt_at_index (im->sad, sa_index0);
183 
184  cipher_alg =
186  auth_alg = vec_elt_at_index (dcm->auth_algs, sa0->integ_alg);
187 
188  is_aead = (cipher_alg->type == RTE_CRYPTO_SYM_XFORM_AEAD);
189  if (is_aead)
190  auth_alg = cipher_alg;
191 
192  res_idx = get_resource (cwm, sa0);
193 
194  if (PREDICT_FALSE (res_idx == (u16) ~ 0))
195  {
196  clib_warning ("unsupported SA by thread index %u",
197  thread_idx);
198  if (is_ip6)
201  ESP_DECRYPT_ERROR_NOSUP, 1);
202  else
205  ESP_DECRYPT_ERROR_NOSUP, 1);
206  to_next[0] = bi0;
207  to_next += 1;
208  n_left_to_next -= 1;
209  goto trace;
210  }
211  res = vec_elt_at_index (dcm->resource, res_idx);
212 
213  error = crypto_get_session (&session, sa_index0, res, cwm, 0);
214  if (PREDICT_FALSE (error || !session))
215  {
216  clib_warning ("failed to get crypto session");
217  if (is_ip6)
220  ESP_DECRYPT_ERROR_SESSION,
221  1);
222  else
225  ESP_DECRYPT_ERROR_SESSION,
226  1);
227  to_next[0] = bi0;
228  to_next += 1;
229  n_left_to_next -= 1;
230  goto trace;
231  }
232 
233  last_sa_index = sa_index0;
234  }
235 
236  /* anti-replay check */
237  if (ipsec_sa_anti_replay_check (sa0, &esp0->seq))
238  {
239  clib_warning ("failed anti-replay check");
240  if (is_ip6)
243  ESP_DECRYPT_ERROR_REPLAY, 1);
244  else
247  ESP_DECRYPT_ERROR_REPLAY, 1);
248  to_next[0] = bi0;
249  to_next += 1;
250  n_left_to_next -= 1;
251  goto trace;
252  }
253 
254  if (is_ip6)
255  priv->next = DPDK_CRYPTO_INPUT_NEXT_DECRYPT6_POST;
256  else
257  priv->next = DPDK_CRYPTO_INPUT_NEXT_DECRYPT4_POST;
258 
259  /* FIXME multi-seg */
261  (&ipsec_sa_counters, thread_index, sa_index0,
262  1, b0->current_length);
263 
264  res->ops[res->n_ops] = op;
265  res->bi[res->n_ops] = bi0;
266  res->n_ops += 1;
267 
268  /* Convert vlib buffer to mbuf */
269  mb0->data_len = b0->current_length;
270  mb0->pkt_len = b0->current_length;
271  mb0->data_off = RTE_PKTMBUF_HEADROOM + b0->current_data;
272 
273  trunc_size = auth_alg->trunc_size;
274  iv_size = cipher_alg->iv_len;
275 
276  /* Outer IP header has already been stripped */
277  u16 payload_len =
278  b0->current_length - sizeof (esp_header_t) - iv_size - trunc_size;
279 
280  ASSERT (payload_len >= 4);
281 
282  if (payload_len & (cipher_alg->boundary - 1))
283  {
284  clib_warning ("payload %u not multiple of %d\n",
285  payload_len, cipher_alg->boundary);
286  if (is_ip6)
288  ESP_DECRYPT_ERROR_BAD_LEN, 1);
289  else
291  ESP_DECRYPT_ERROR_BAD_LEN, 1);
292  res->n_ops -= 1;
293  to_next[0] = bi0;
294  to_next += 1;
295  n_left_to_next -= 1;
296  goto trace;
297  }
298 
299  u32 cipher_off, cipher_len;
300  u32 auth_len = 0;
301  u8 *aad = NULL;
302 
303  u8 *iv = (u8 *) (esp0 + 1);
304 
305  dpdk_gcm_cnt_blk *icb = &priv->cb;
306 
307  cipher_off = sizeof (esp_header_t) + iv_size;
308  cipher_len = payload_len;
309 
310  u8 *digest = vlib_buffer_get_tail (b0) - trunc_size;
311  u64 digest_paddr =
312  mb0->buf_physaddr + digest - ((u8 *) mb0->buf_addr);
313 
314  if (!is_aead && cipher_alg->alg == RTE_CRYPTO_CIPHER_AES_CBC)
315  clib_memcpy_fast (icb, iv, 16);
316  else /* CTR/GCM */
317  {
318  u32 *_iv = (u32 *) iv;
319 
320  crypto_set_icb (icb, sa0->salt, _iv[0], _iv[1]);
321  }
322 
323  if (is_aead)
324  {
325  aad = priv->aad;
326  u32 *_aad = (u32 *) aad;
327  clib_memcpy_fast (aad, esp0, 8);
328 
329  /* _aad[3] should always be 0 */
330  if (PREDICT_FALSE (ipsec_sa_is_set_USE_ESN (sa0)))
331  _aad[2] = clib_host_to_net_u32 (sa0->seq_hi);
332  else
333  _aad[2] = 0;
334  }
335  else
336  {
337  auth_len = sizeof (esp_header_t) + iv_size + payload_len;
338 
339  if (ipsec_sa_is_set_USE_ESN (sa0))
340  {
341  clib_memcpy_fast (priv->icv, digest, trunc_size);
342  u32 *_digest = (u32 *) digest;
343  _digest[0] = clib_host_to_net_u32 (sa0->seq_hi);
344  auth_len += sizeof (sa0->seq_hi);
345 
346  digest = priv->icv;
347  digest_paddr =
348  op->phys_addr + (uintptr_t) priv->icv - (uintptr_t) op;
349  }
350  }
351 
352  crypto_op_setup (is_aead, mb0, op, session, cipher_off, cipher_len,
353  0, auth_len, aad, digest, digest_paddr);
354  trace:
355  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
356  {
357  esp_decrypt_trace_t *tr =
358  vlib_add_trace (vm, node, b0, sizeof (*tr));
359  tr->crypto_alg = sa0->crypto_alg;
360  tr->integ_alg = sa0->integ_alg;
362  sizeof (esp_header_t));
363  }
364  }
365  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
366  }
367 
368  if (is_ip6)
369  {
371  ESP_DECRYPT_ERROR_RX_PKTS,
372  from_frame->n_vectors);
373 
375  ESP_DECRYPT_ERROR_ENQ_FAIL, numa);
376  }
377  else
378  {
380  ESP_DECRYPT_ERROR_RX_PKTS,
381  from_frame->n_vectors);
382 
384  ESP_DECRYPT_ERROR_ENQ_FAIL, numa);
385  }
386 
387  crypto_free_ops (numa, ops, cwm->ops + from_frame->n_vectors - ops);
388 
389  return from_frame->n_vectors;
390 }
391 
393  vlib_node_runtime_t * node,
394  vlib_frame_t * from_frame)
395 {
396  return dpdk_esp_decrypt_inline (vm, node, from_frame, 0 /*is_ip6 */ );
397 }
398 
399 /* *INDENT-OFF* */
401  .name = "dpdk-esp4-decrypt",
402  .vector_size = sizeof (u32),
403  .format_trace = format_esp_decrypt_trace,
404  .type = VLIB_NODE_TYPE_INTERNAL,
405 
407  .error_strings = esp_decrypt_error_strings,
408 
409  .n_next_nodes = ESP_DECRYPT_N_NEXT,
410  .next_nodes = {
411 #define _(s,n) [ESP_DECRYPT_NEXT_##s] = n,
413 #undef _
414  },
415 };
416 /* *INDENT-ON* */
417 
419  vlib_node_runtime_t * node,
420  vlib_frame_t * from_frame)
421 {
422  return dpdk_esp_decrypt_inline (vm, node, from_frame, 1 /*is_ip6 */ );
423 }
424 
425 /* *INDENT-OFF* */
427  .name = "dpdk-esp6-decrypt",
428  .vector_size = sizeof (u32),
429  .format_trace = format_esp_decrypt_trace,
430  .type = VLIB_NODE_TYPE_INTERNAL,
431 
433  .error_strings = esp_decrypt_error_strings,
434 
435  .n_next_nodes = ESP_DECRYPT_N_NEXT,
436  .next_nodes = {
437 #define _(s,n) [ESP_DECRYPT_NEXT_##s] = n,
439 #undef _
440  },
441 };
442 /* *INDENT-ON* */
443 
444 /*
445  * Decrypt Post Node
446  */
447 
448 #define foreach_esp_decrypt_post_error \
449  _(PKTS, "ESP post pkts")
450 
451 typedef enum
452 {
453 #define _(sym,str) ESP_DECRYPT_POST_ERROR_##sym,
455 #undef _
458 
460 #define _(sym,string) string,
462 #undef _
463 };
464 
467 
468 static u8 *
469 format_esp_decrypt_post_trace (u8 * s, va_list * args)
470 {
471  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
472  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
473  esp_decrypt_trace_t *t = va_arg (*args, esp_decrypt_trace_t *);
474  u32 indent = format_get_indent (s);
475 
476  s = format (s, "cipher %U auth %U\n",
479 
480  ip4_header_t *ih4 = (ip4_header_t *) t->packet_data;
481  if ((ih4->ip_version_and_header_length & 0xF0) == 0x60)
482  s =
483  format (s, "%U%U", format_white_space, indent, format_ip6_header, ih4);
484  else
485  s =
486  format (s, "%U%U", format_white_space, indent, format_ip4_header, ih4);
487 
488  return s;
489 }
490 
493  vlib_node_runtime_t * node,
494  vlib_frame_t * from_frame, int is_ip6)
495 {
496  u32 n_left_from, *from, *to_next = 0, next_index;
497  ipsec_sa_t *sa0;
498  u32 sa_index0 = ~0;
499  ipsec_main_t *im = &ipsec_main;
501 
502  from = vlib_frame_vector_args (from_frame);
503  n_left_from = from_frame->n_vectors;
504 
505  next_index = node->cached_next_index;
506 
507  while (n_left_from > 0)
508  {
509  u32 n_left_to_next;
510 
511  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
512 
513  while (n_left_from > 0 && n_left_to_next > 0)
514  {
515  esp_footer_t *f0;
516  u32 bi0, iv_size, next0;
517  vlib_buffer_t *b0 = 0;
518  ip4_header_t *ih4 = 0, *oh4 = 0;
519  ip6_header_t *ih6 = 0, *oh6 = 0;
520  crypto_alg_t *cipher_alg, *auth_alg;
521  esp_header_t *esp0;
522  u8 trunc_size, is_aead;
523  u16 udp_encap_adv = 0;
524 
525  next0 = ESP_DECRYPT_NEXT_DROP;
526 
527  bi0 = from[0];
528  from += 1;
529  n_left_from -= 1;
530  n_left_to_next -= 1;
531 
532  b0 = vlib_get_buffer (vm, bi0);
533  esp0 = vlib_buffer_get_current (b0);
534 
535  sa_index0 = vnet_buffer (b0)->ipsec.sad_index;
536  sa0 = pool_elt_at_index (im->sad, sa_index0);
537 
538  to_next[0] = bi0;
539  to_next += 1;
540 
541  cipher_alg = vec_elt_at_index (dcm->cipher_algs, sa0->crypto_alg);
542  auth_alg = vec_elt_at_index (dcm->auth_algs, sa0->integ_alg);
543  is_aead = cipher_alg->type == RTE_CRYPTO_SYM_XFORM_AEAD;
544  if (is_aead)
545  auth_alg = cipher_alg;
546 
547  trunc_size = auth_alg->trunc_size;
548 
549  iv_size = cipher_alg->iv_len;
550 
551  ipsec_sa_anti_replay_advance (sa0, &esp0->seq);
552 
553  /* if UDP encapsulation is used adjust the address of the IP header */
554  if (ipsec_sa_is_set_UDP_ENCAP (sa0)
555  && (b0->flags & VNET_BUFFER_F_IS_IP4))
556  {
557  udp_encap_adv = sizeof (udp_header_t);
558  }
559 
560  if (b0->flags & VNET_BUFFER_F_IS_IP4)
561  ih4 = (ip4_header_t *)
562  ((u8 *) esp0 - udp_encap_adv - sizeof (ip4_header_t));
563  else
564  ih4 = (ip4_header_t *) ((u8 *) esp0 - sizeof (ip6_header_t));
565 
566  vlib_buffer_advance (b0, sizeof (esp_header_t) + iv_size);
567 
568  b0->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
569  f0 = (esp_footer_t *) (vlib_buffer_get_tail (b0) - trunc_size - 2);
570  b0->current_length -= (f0->pad_length + trunc_size + 2);
571 #if 0
572  /* check padding */
573  const u8 *padding = vlib_buffer_get_tail (b0);
574  if (PREDICT_FALSE (memcmp (padding, pad_data, f0->pad_length)))
575  {
576  clib_warning ("bad padding");
577  vlib_node_increment_counter (vm, dpdk_esp_decrypt_node.index,
578  ESP_DECRYPT_ERROR_DECRYPTION_FAILED,
579  1);
580  goto trace;
581  }
582 #endif
583  if (ipsec_sa_is_set_IS_TUNNEL (sa0))
584  {
585  if (f0->next_header == IP_PROTOCOL_IP_IN_IP)
586  next0 = ESP_DECRYPT_NEXT_IP4_INPUT;
587  else if (ipsec_sa_is_set_IS_TUNNEL_V6 (sa0)
588  && f0->next_header == IP_PROTOCOL_IPV6)
589  next0 = ESP_DECRYPT_NEXT_IP6_INPUT;
590  else
591  {
592  clib_warning ("next header: 0x%x", f0->next_header);
593  if (is_ip6)
596  ESP_DECRYPT_ERROR_DECRYPTION_FAILED,
597  1);
598  else
601  ESP_DECRYPT_ERROR_DECRYPTION_FAILED,
602  1);
603  goto trace;
604  }
605  }
606  else /* transport mode */
607  {
608  if ((ih4->ip_version_and_header_length & 0xF0) == 0x40)
609  {
610  u16 ih4_len = ip4_header_bytes (ih4);
611  vlib_buffer_advance (b0, -ih4_len - udp_encap_adv);
612  next0 = ESP_DECRYPT_NEXT_IP4_INPUT;
613  if (!ipsec_sa_is_set_UDP_ENCAP (sa0))
614  {
615  oh4 = vlib_buffer_get_current (b0);
616  memmove (oh4, ih4, ih4_len);
617  oh4->protocol = f0->next_header;
618  oh4->length = clib_host_to_net_u16 (b0->current_length);
619  oh4->checksum = ip4_header_checksum (oh4);
620  }
621  }
622  else if ((ih4->ip_version_and_header_length & 0xF0) == 0x60)
623  {
624  ih6 = (ip6_header_t *) ih4;
625  vlib_buffer_advance (b0, -sizeof (ip6_header_t));
626  oh6 = vlib_buffer_get_current (b0);
627  memmove (oh6, ih6, sizeof (ip6_header_t));
628 
629  next0 = ESP_DECRYPT_NEXT_IP6_INPUT;
630  oh6->protocol = f0->next_header;
631  u16 len = b0->current_length - sizeof (ip6_header_t);
632  oh6->payload_length = clib_host_to_net_u16 (len);
633  }
634  else
635  {
636  clib_warning ("next header: 0x%x", f0->next_header);
637  if (is_ip6)
640  ESP_DECRYPT_ERROR_DECRYPTION_FAILED,
641  1);
642  else
645  ESP_DECRYPT_ERROR_DECRYPTION_FAILED,
646  1);
647  goto trace;
648  }
649  }
650 
651  vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32) ~ 0;
652 
653  trace:
654  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
655  {
656  esp_decrypt_trace_t *tr =
657  vlib_add_trace (vm, node, b0, sizeof (*tr));
658  tr->crypto_alg = sa0->crypto_alg;
659  tr->integ_alg = sa0->integ_alg;
660  ih4 = vlib_buffer_get_current (b0);
661  clib_memcpy_fast (tr->packet_data, ih4, sizeof (ip6_header_t));
662  }
663 
664  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
665  to_next, n_left_to_next, bi0,
666  next0);
667  }
668  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
669  }
670 
671  if (is_ip6)
673  ESP_DECRYPT_POST_ERROR_PKTS,
674  from_frame->n_vectors);
675  else
677  ESP_DECRYPT_POST_ERROR_PKTS,
678  from_frame->n_vectors);
679 
680  return from_frame->n_vectors;
681 }
682 
684  vlib_node_runtime_t * node,
685  vlib_frame_t * from_frame)
686 {
687  return dpdk_esp_decrypt_post_inline (vm, node, from_frame, 0 /*is_ip6 */ );
688 }
689 
690 /* *INDENT-OFF* */
692  .name = "dpdk-esp4-decrypt-post",
693  .vector_size = sizeof (u32),
694  .format_trace = format_esp_decrypt_post_trace,
695  .type = VLIB_NODE_TYPE_INTERNAL,
696 
698  .error_strings = esp_decrypt_post_error_strings,
699 
700  .n_next_nodes = ESP_DECRYPT_N_NEXT,
701  .next_nodes = {
702 #define _(s,n) [ESP_DECRYPT_NEXT_##s] = n,
704 #undef _
705  },
706 };
707 /* *INDENT-ON* */
708 
710  vlib_node_runtime_t * node,
711  vlib_frame_t * from_frame)
712 {
713  return dpdk_esp_decrypt_post_inline (vm, node, from_frame, 0 /*is_ip6 */ );
714 }
715 
716 /* *INDENT-OFF* */
718  .name = "dpdk-esp6-decrypt-post",
719  .vector_size = sizeof (u32),
720  .format_trace = format_esp_decrypt_post_trace,
721  .type = VLIB_NODE_TYPE_INTERNAL,
722 
724  .error_strings = esp_decrypt_post_error_strings,
725 
726  .n_next_nodes = ESP_DECRYPT_N_NEXT,
727  .next_nodes = {
728 #define _(s,n) [ESP_DECRYPT_NEXT_##s] = n,
730 #undef _
731  },
732 };
733 /* *INDENT-ON* */
734 
735 /*
736  * fd.io coding-style-patch-verification: ON
737  *
738  * Local Variables:
739  * eval: (c-set-style "gnu")
740  * End:
741  */
u32 alg
Definition: ipsec.h:81
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:124
u8 * format_ipsec_integ_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:109
static_always_inline void crypto_op_setup(u8 is_aead, struct rte_mbuf *mb0, struct rte_crypto_op *op, void *session, u32 cipher_off, u32 cipher_len, u32 auth_off, u32 auth_len, u8 *aad, u8 *digest, u64 digest_paddr)
Definition: ipsec.h:347
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
Definition: vlib_api_cli.c:862
static int ipsec_sa_anti_replay_check(ipsec_sa_t *sa, u32 *seqp)
Definition: ipsec_sa.h:230
static u8 * vlib_buffer_get_tail(vlib_buffer_t *b)
Get pointer to the end of buffer&#39;s data.
Definition: buffer.h:310
#define CLIB_UNUSED(x)
Definition: clib.h:82
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.
Definition: counter.h:220
static char * esp_decrypt_post_error_strings[]
Definition: esp_decrypt.c:459
static u8 * format_esp_decrypt_post_trace(u8 *s, va_list *args)
Definition: esp_decrypt.c:469
format_function_t format_ip4_header
Definition: format.h:83
ipsec_integ_alg_t
Definition: ipsec_sa.h:60
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:110
unsigned long u64
Definition: types.h:89
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
#define NULL
Definition: clib.h:58
static_always_inline i32 crypto_alloc_ops(u8 numa, struct rte_crypto_op **ops, u32 n)
Definition: ipsec.h:277
ipsec_integ_alg_t integ_alg
Definition: ipsec_sa.h:153
u32 thread_index
Definition: main.h:197
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:113
static_always_inline void crypto_set_icb(dpdk_gcm_cnt_blk *icb, u32 salt, u32 seq, u32 seq_hi)
Definition: ipsec.h:339
ipsec_crypto_alg_t crypto_alg
Definition: esp_decrypt.c:69
static u32 format_get_indent(u8 *s)
Definition: format.h:72
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
#define VLIB_NODE_FN(node)
Definition: node.h:201
static void ipsec_sa_anti_replay_advance(ipsec_sa_t *sa, u32 *seqp)
Definition: ipsec_sa.h:295
esp_decrypt_next_t
Definition: esp_decrypt.c:33
unsigned char u8
Definition: types.h:56
static_always_inline void crypto_enqueue_ops(vlib_main_t *vm, crypto_worker_main_t *cwm, u32 node_index, u32 error, u8 numa)
Definition: ipsec.h:305
static char * esp_decrypt_error_strings[]
Definition: esp_decrypt.c:62
u32 bi[VLIB_FRAME_SIZE]
Definition: ipsec.h:122
u32 seq_hi
Definition: ipsec_sa.h:123
static_always_inline clib_error_t * crypto_get_session(struct rte_cryptodev_sym_session **session, u32 sa_idx, crypto_resource_t *res, crypto_worker_main_t *cwm, u8 is_outbound)
Definition: ipsec.h:231
static_always_inline void crypto_free_ops(u8 numa, struct rte_crypto_op **ops, u32 n)
Definition: ipsec.h:293
vlib_node_registration_t dpdk_esp4_decrypt_post_node
(constructor) VLIB_REGISTER_NODE (dpdk_esp4_decrypt_post_node)
Definition: esp_decrypt.c:691
#define foreach_esp_decrypt_next
Definition: esp_decrypt.c:29
dpdk_crypto_main_t dpdk_crypto_main
Definition: ipsec.c:25
ipsec_main_t ipsec_main
Definition: ipsec.c:28
#define always_inline
Definition: clib.h:98
#define foreach_esp_decrypt_post_error
Definition: esp_decrypt.c:448
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:113
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
u8 * format_ipsec_crypto_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:77
unsigned int u32
Definition: types.h:88
u32 padding
Definition: vhost_user.h:115
crypto_alg_t * auth_algs
Definition: ipsec.h:160
static const u8 pad_data[]
Definition: ipsec.h:169
u8 trunc_size
Definition: ipsec.h:84
u32 next
Definition: ipsec.h:60
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:514
static u8 iv[]
Definition: aes_cbc.c:24
crypto_alg_t * cipher_algs
Definition: ipsec.h:159
u32 salt
Definition: ipsec_sa.h:163
unsigned short u16
Definition: types.h:57
#define rte_mbuf_from_vlib_buffer(x)
Definition: buffer.h:19
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:229
#define PREDICT_FALSE(x)
Definition: clib.h:111
vlib_node_registration_t dpdk_esp4_decrypt_node
(constructor) VLIB_REGISTER_NODE (dpdk_esp4_decrypt_node)
Definition: esp_decrypt.c:400
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:235
vlib_node_registration_t dpdk_esp6_decrypt_post_node
(constructor) VLIB_REGISTER_NODE (dpdk_esp6_decrypt_post_node)
Definition: esp_decrypt.c:717
#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:218
#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:368
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1180
u8 len
Definition: ip_types.api:49
esp_decrypt_post_error_t
Definition: esp_decrypt.c:451
u8 aad[16]
Definition: ipsec.h:63
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
u16 n_vectors
Definition: node.h:395
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:212
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:80
vlib_main_t * vm
Definition: buffer.c:312
dpdk_gcm_cnt_blk cb
Definition: ipsec.h:62
static uword dpdk_esp_decrypt_post_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, int is_ip6)
Definition: esp_decrypt.c:492
#define clib_warning(format, args...)
Definition: error.h:59
static uword dpdk_esp_decrypt_inline(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame, int is_ip6)
Definition: esp_decrypt.c:96
#define ARRAY_LEN(x)
Definition: clib.h:62
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:465
u8 * format_esp_header(u8 *s, va_list *args)
Definition: esp_format.c:23
u8 iv_len
Definition: ipsec.h:83
vlib_combined_counter_main_t ipsec_sa_counters
SA packet & bytes counters.
Definition: ipsec_sa.c:25
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
Definition: node.h:514
#define ASSERT(truth)
esp_decrypt_error_t
Definition: esp_decrypt.c:52
u8 icv[32]
Definition: ipsec.h:64
ipsec_sa_t * sad
Definition: ipsec.h:95
crypto_worker_main_t * workers_main
Definition: ipsec.h:156
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:248
format_function_t format_ip6_header
Definition: format.h:97
u8 boundary
Definition: ipsec.h:85
crypto_resource_t * resource
Definition: ipsec.h:158
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:57
struct _vlib_node_registration vlib_node_registration_t
Definition: defs.h:47
vlib_node_registration_t dpdk_esp6_decrypt_node
(constructor) VLIB_REGISTER_NODE (dpdk_esp6_decrypt_node)
Definition: esp_decrypt.c:426
VLIB buffer representation.
Definition: buffer.h:102
u64 uword
Definition: types.h:112
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:274
ipsec_crypto_alg_t
Definition: ipsec_sa.h:38
struct rte_crypto_op ** ops
Definition: ipsec.h:70
static u8 * format_esp_decrypt_trace(u8 *s, va_list *args)
Definition: esp_decrypt.c:80
enum rte_crypto_sym_xform_type type
Definition: ipsec.h:80
#define vnet_buffer(b)
Definition: buffer.h:369
static_always_inline u16 get_resource(crypto_worker_main_t *cwm, ipsec_sa_t *sa)
Definition: ipsec.h:252
ipsec_crypto_alg_t crypto_alg
Definition: ipsec_sa.h:150
static int ip4_header_bytes(const ip4_header_t *i)
Definition: ip4_packet.h:235
u8 ip_version_and_header_length
Definition: ip4_packet.h:138
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
#define foreach_esp_decrypt_error
Definition: esp_decrypt.c:42
struct rte_crypto_op * ops[VLIB_FRAME_SIZE]
Definition: ipsec.h:121
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:85
static u16 ip4_header_checksum(ip4_header_t *i)
Definition: ip4_packet.h:247
ipsec_integ_alg_t integ_alg
Definition: esp_decrypt.c:70
static_always_inline dpdk_op_priv_t * crypto_op_get_priv(struct rte_crypto_op *op)
Definition: ipsec.h:201