FD.io VPP  v21.10.1-2-g0a485f517
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 decrypt failed (queue full)") \
48  _(DISCARD, "Not enough crypto operations") \
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 
99 {
103  crypto_resource_t *res = 0;
104  ipsec_sa_t *sa0 = 0;
105  crypto_alg_t *cipher_alg = 0, *auth_alg = 0;
106  struct rte_cryptodev_sym_session *session = 0;
107  u32 ret, last_sa_index = ~0;
108  u8 numa = rte_socket_id ();
109  u8 is_aead = 0;
110  crypto_worker_main_t *cwm =
112  struct rte_crypto_op **ops = cwm->ops;
113 
115  n_left_from = from_frame->n_vectors;
117 
118  ret = crypto_alloc_ops (numa, ops, n_left_from);
119  if (ret)
120  {
121  if (is_ip6)
123  ESP_DECRYPT_ERROR_DISCARD, n_left_from);
124  else
126  ESP_DECRYPT_ERROR_DISCARD, n_left_from);
127  /* 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  {
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  priv->encrypt = 0;
172 
173  u16 op_len =
174  sizeof (op[0]) + sizeof (op[0].sym[0]) + sizeof (priv[0]);
175  CLIB_PREFETCH (op, op_len, STORE);
176 
177  sa_index0 = vnet_buffer (b0)->ipsec.sad_index;
179  thread_index, sa_index0);
180 
181  if (sa_index0 != last_sa_index)
182  {
183  sa0 = ipsec_sa_get (sa_index0);
184 
185  cipher_alg =
187  auth_alg = vec_elt_at_index (dcm->auth_algs, sa0->integ_alg);
188 
189  is_aead = (cipher_alg->type == RTE_CRYPTO_SYM_XFORM_AEAD);
190  if (is_aead)
191  auth_alg = cipher_alg;
192 
193  res_idx = get_resource (cwm, sa0);
194 
195  if (PREDICT_FALSE (res_idx == (u16) ~ 0))
196  {
197  if (is_ip6)
200  ESP_DECRYPT_ERROR_NOSUP, 1);
201  else
204  ESP_DECRYPT_ERROR_NOSUP, 1);
205  to_next[0] = bi0;
206  to_next += 1;
207  n_left_to_next -= 1;
208  goto trace;
209  }
210  res = vec_elt_at_index (dcm->resource, res_idx);
211 
212  error = crypto_get_session (&session, sa_index0, res, cwm, 0);
213  if (PREDICT_FALSE (error || !session))
214  {
215  if (is_ip6)
218  ESP_DECRYPT_ERROR_SESSION,
219  1);
220  else
223  ESP_DECRYPT_ERROR_SESSION,
224  1);
225  to_next[0] = bi0;
226  to_next += 1;
227  n_left_to_next -= 1;
228  goto trace;
229  }
230 
231  last_sa_index = sa_index0;
232  }
233 
234  /* anti-replay check */
236  (sa0, clib_host_to_net_u32 (esp0->seq)))
237  {
238  if (is_ip6)
241  ESP_DECRYPT_ERROR_REPLAY, 1);
242  else
245  ESP_DECRYPT_ERROR_REPLAY, 1);
246  to_next[0] = bi0;
247  to_next += 1;
248  n_left_to_next -= 1;
249  goto trace;
250  }
251 
252  if (is_ip6)
253  priv->next = DPDK_CRYPTO_INPUT_NEXT_DECRYPT6_POST;
254  else
255  {
256  priv->next = DPDK_CRYPTO_INPUT_NEXT_DECRYPT4_POST;
257  b0->flags |= VNET_BUFFER_F_IS_IP4;
258  }
259 
260  /* FIXME multi-seg */
262  (&ipsec_sa_counters, thread_index, sa_index0,
263  1, b0->current_length);
264 
265  res->ops[res->n_ops] = op;
266  res->bi[res->n_ops] = bi0;
267  res->n_ops += 1;
268 
269  /* Convert vlib buffer to mbuf */
270  mb0->data_len = b0->current_length;
271  mb0->pkt_len = b0->current_length;
272  mb0->data_off = RTE_PKTMBUF_HEADROOM + b0->current_data;
273 
274  trunc_size = auth_alg->trunc_size;
275  iv_size = cipher_alg->iv_len;
276 
277  /* Outer IP header has already been stripped */
278  u16 payload_len =
279  b0->current_length - sizeof (esp_header_t) - iv_size - trunc_size;
280 
281  ASSERT (payload_len >= 4);
282 
283  if (payload_len & (cipher_alg->boundary - 1))
284  {
285  if (is_ip6)
287  ESP_DECRYPT_ERROR_BAD_LEN, 1);
288  else
290  ESP_DECRYPT_ERROR_BAD_LEN, 1);
291  res->n_ops -= 1;
292  to_next[0] = bi0;
293  to_next += 1;
294  n_left_to_next -= 1;
295  goto trace;
296  }
297 
298  u32 cipher_off, cipher_len;
299  u32 auth_len = 0;
300  u8 *aad = NULL;
301 
302  u8 *iv = (u8 *) (esp0 + 1);
303 
304  dpdk_gcm_cnt_blk *icb = &priv->cb;
305 
306  cipher_off = sizeof (esp_header_t) + iv_size;
307  cipher_len = payload_len;
308 
309  u8 *digest = vlib_buffer_get_tail (b0) - trunc_size;
310  u64 digest_paddr = mb0->buf_iova + digest - ((u8 *) mb0->buf_addr);
311 
312  if (!is_aead && cipher_alg->alg == RTE_CRYPTO_CIPHER_AES_CBC)
313  clib_memcpy_fast (icb, iv, 16);
314  else /* CTR/GCM */
315  {
316  u32 *_iv = (u32 *) iv;
317 
318  crypto_set_icb (icb, sa0->salt, _iv[0], _iv[1]);
319  }
320 
321  if (is_aead)
322  {
323  aad = priv->aad;
324  u32 *_aad = (u32 *) aad;
325  clib_memcpy_fast (aad, esp0, 8);
326 
327  /* _aad[3] should always be 0 */
328  if (PREDICT_FALSE (ipsec_sa_is_set_USE_ESN (sa0)))
329  {
330  _aad[2] = _aad[1];
331  _aad[1] = clib_host_to_net_u32 (sa0->seq_hi);
332  }
333  else
334  _aad[2] = 0;
335  }
336  else
337  {
338  auth_len = sizeof (esp_header_t) + iv_size + payload_len;
339 
340  if (ipsec_sa_is_set_USE_ESN (sa0))
341  {
342  clib_memcpy_fast (priv->icv, digest, trunc_size);
343  u32 *_digest = (u32 *) digest;
344  _digest[0] = clib_host_to_net_u32 (sa0->seq_hi);
345  auth_len += sizeof (sa0->seq_hi);
346 
347  digest = priv->icv;
348  digest_paddr =
349  op->phys_addr + (uintptr_t) priv->icv - (uintptr_t) op;
350  }
351  }
352 
353  crypto_op_setup (is_aead, mb0, op, session, cipher_off, cipher_len,
354  0, auth_len, aad, digest, digest_paddr);
355  trace:
356  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
357  {
358  esp_decrypt_trace_t *tr =
359  vlib_add_trace (vm, node, b0, sizeof (*tr));
360  tr->crypto_alg = sa0->crypto_alg;
361  tr->integ_alg = sa0->integ_alg;
363  sizeof (esp_header_t));
364  }
365  }
366  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
367  }
368 
369  if (is_ip6)
370  {
372  ESP_DECRYPT_ERROR_RX_PKTS,
373  from_frame->n_vectors);
374 
376  ESP_DECRYPT_ERROR_ENQ_FAIL, numa, 0 /* encrypt */ );
377  }
378  else
379  {
381  ESP_DECRYPT_ERROR_RX_PKTS,
382  from_frame->n_vectors);
383 
385  ESP_DECRYPT_ERROR_ENQ_FAIL, numa, 0 /* encrypt */ );
386  }
387 
388  crypto_free_ops (numa, ops, cwm->ops + from_frame->n_vectors - ops);
389 
390  return from_frame->n_vectors;
391 }
392 
396 {
397  return dpdk_esp_decrypt_inline (vm, node, from_frame, 0 /*is_ip6 */ );
398 }
399 
400 /* *INDENT-OFF* */
402  .name = "dpdk-esp4-decrypt",
403  .vector_size = sizeof (u32),
404  .format_trace = format_esp_decrypt_trace,
406 
408  .error_strings = esp_decrypt_error_strings,
409 
410  .n_next_nodes = ESP_DECRYPT_N_NEXT,
411  .next_nodes = {
412 #define _(s,n) [ESP_DECRYPT_NEXT_##s] = n,
414 #undef _
415  },
416 };
417 /* *INDENT-ON* */
418 
422 {
423  return dpdk_esp_decrypt_inline (vm, node, from_frame, 1 /*is_ip6 */ );
424 }
425 
426 /* *INDENT-OFF* */
428  .name = "dpdk-esp6-decrypt",
429  .vector_size = sizeof (u32),
430  .format_trace = format_esp_decrypt_trace,
432 
434  .error_strings = esp_decrypt_error_strings,
435 
436  .n_next_nodes = ESP_DECRYPT_N_NEXT,
437  .next_nodes = {
438 #define _(s,n) [ESP_DECRYPT_NEXT_##s] = n,
440 #undef _
441  },
442 };
443 /* *INDENT-ON* */
444 
445 /*
446  * Decrypt Post Node
447  */
448 
449 #define foreach_esp_decrypt_post_error \
450  _(PKTS, "ESP post pkts")
451 
452 typedef enum
453 {
454 #define _(sym,str) ESP_DECRYPT_POST_ERROR_##sym,
456 #undef _
459 
461 #define _(sym,string) string,
463 #undef _
464 };
465 
468 
469 static u8 *
470 format_esp_decrypt_post_trace (u8 * s, va_list * args)
471 {
472  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
473  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
474  esp_decrypt_trace_t *t = va_arg (*args, esp_decrypt_trace_t *);
475  u32 indent = format_get_indent (s);
476 
477  s = format (s, "cipher %U auth %U\n",
480 
481  ip4_header_t *ih4 = (ip4_header_t *) t->packet_data;
482  if ((ih4->ip_version_and_header_length & 0xF0) == 0x60)
483  s =
484  format (s, "%U%U", format_white_space, indent, format_ip6_header, ih4);
485  else
486  s =
487  format (s, "%U%U", format_white_space, indent, format_ip4_header, ih4);
488 
489  return s;
490 }
491 
496 {
497  u32 n_left_from, *from, *to_next = 0, next_index;
498  ipsec_sa_t *sa0;
499  u32 sa_index0 = ~0;
501 
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 = ipsec_sa_get (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 
552  clib_host_to_net_u32 (esp0->seq));
553 
554  /* if UDP encapsulation is used adjust the address of the IP header */
555  if (ipsec_sa_is_set_UDP_ENCAP (sa0)
556  && (b0->flags & VNET_BUFFER_F_IS_IP4))
557  {
558  udp_encap_adv = sizeof (udp_header_t);
559  }
560 
561  if (b0->flags & VNET_BUFFER_F_IS_IP4)
562  ih4 = (ip4_header_t *)
563  ((u8 *) esp0 - udp_encap_adv - sizeof (ip4_header_t));
564  else
565  ih4 = (ip4_header_t *) ((u8 *) esp0 - sizeof (ip6_header_t));
566 
567  vlib_buffer_advance (b0, sizeof (esp_header_t) + iv_size);
568 
569  b0->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
570  f0 = (esp_footer_t *) (vlib_buffer_get_tail (b0) - trunc_size - 2);
571  b0->current_length -= (f0->pad_length + trunc_size + 2);
572 #if 0
573  /* check padding */
574  const u8 *padding = vlib_buffer_get_tail (b0);
575  if (PREDICT_FALSE (memcmp (padding, pad_data, f0->pad_length)))
576  {
577  clib_warning ("bad padding");
578  vlib_node_increment_counter (vm, dpdk_esp_decrypt_node.index,
579  ESP_DECRYPT_ERROR_DECRYPTION_FAILED,
580  1);
581  goto trace;
582  }
583 #endif
584  if (ipsec_sa_is_set_IS_TUNNEL (sa0))
585  {
586  if (f0->next_header == IP_PROTOCOL_IP_IN_IP)
587  next0 = ESP_DECRYPT_NEXT_IP4_INPUT;
588  else if (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);
612  next0 = ESP_DECRYPT_NEXT_IP4_INPUT;
613 
614  oh4 = vlib_buffer_get_current (b0);
615  memmove (oh4, ih4, ih4_len);
616  oh4->protocol = f0->next_header;
617  oh4->length = clib_host_to_net_u16 (b0->current_length);
618  oh4->checksum = ip4_header_checksum (oh4);
619  }
620  else if ((ih4->ip_version_and_header_length & 0xF0) == 0x60)
621  {
622  ih6 = (ip6_header_t *) ih4;
623  vlib_buffer_advance (b0, -sizeof (ip6_header_t));
624  oh6 = vlib_buffer_get_current (b0);
625  memmove (oh6, ih6, sizeof (ip6_header_t));
626 
627  next0 = ESP_DECRYPT_NEXT_IP6_INPUT;
628  oh6->protocol = f0->next_header;
629  u16 len = b0->current_length - sizeof (ip6_header_t);
630  oh6->payload_length = clib_host_to_net_u16 (len);
631  }
632  else
633  {
634  clib_warning ("next header: 0x%x", f0->next_header);
635  if (is_ip6)
638  ESP_DECRYPT_ERROR_DECRYPTION_FAILED,
639  1);
640  else
643  ESP_DECRYPT_ERROR_DECRYPTION_FAILED,
644  1);
645  goto trace;
646  }
647  }
648 
649  vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32) ~ 0;
650 
651  trace:
652  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
653  {
654  esp_decrypt_trace_t *tr =
655  vlib_add_trace (vm, node, b0, sizeof (*tr));
656  tr->crypto_alg = sa0->crypto_alg;
657  tr->integ_alg = sa0->integ_alg;
658  ih4 = vlib_buffer_get_current (b0);
659  clib_memcpy_fast (tr->packet_data, ih4, sizeof (ip6_header_t));
660  }
661 
663  to_next, n_left_to_next, bi0,
664  next0);
665  }
666  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
667  }
668 
669  if (is_ip6)
671  ESP_DECRYPT_POST_ERROR_PKTS,
672  from_frame->n_vectors);
673  else
675  ESP_DECRYPT_POST_ERROR_PKTS,
676  from_frame->n_vectors);
677 
678  return from_frame->n_vectors;
679 }
680 
684 {
685  return dpdk_esp_decrypt_post_inline (vm, node, from_frame, 0 /*is_ip6 */ );
686 }
687 
688 /* *INDENT-OFF* */
690  .name = "dpdk-esp4-decrypt-post",
691  .vector_size = sizeof (u32),
692  .format_trace = format_esp_decrypt_post_trace,
694 
696  .error_strings = esp_decrypt_post_error_strings,
697 
698  .n_next_nodes = ESP_DECRYPT_N_NEXT,
699  .next_nodes = {
700 #define _(s,n) [ESP_DECRYPT_NEXT_##s] = n,
702 #undef _
703  },
704 };
705 /* *INDENT-ON* */
706 
710 {
711  return dpdk_esp_decrypt_post_inline (vm, node, from_frame, 0 /*is_ip6 */ );
712 }
713 
714 /* *INDENT-OFF* */
716  .name = "dpdk-esp6-decrypt-post",
717  .vector_size = sizeof (u32),
718  .format_trace = format_esp_decrypt_post_trace,
720 
722  .error_strings = esp_decrypt_post_error_strings,
723 
724  .n_next_nodes = ESP_DECRYPT_N_NEXT,
725  .next_nodes = {
726 #define _(s,n) [ESP_DECRYPT_NEXT_##s] = n,
728 #undef _
729  },
730 };
731 /* *INDENT-ON* */
732 
733 /*
734  * fd.io coding-style-patch-verification: ON
735  *
736  * Local Variables:
737  * eval: (c-set-style "gnu")
738  * End:
739  */
ipsec.h
dpdk.h
vlib_buffer_free
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:979
esp_decrypt_trace_t::integ_alg
ipsec_integ_alg_t integ_alg
Definition: esp_decrypt.c:97
trace
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
Definition: vlib_api_cli.c:870
crypto_get_session
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:239
thread_index
u32 thread_index
Definition: nat44_ei_hairpinning.c:495
format_ipsec_integ_alg
u8 * format_ipsec_integ_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:111
next_index
nat44_ei_hairpin_src_next_t next_index
Definition: nat44_ei_hairpinning.c:412
vlib_get_buffer
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:111
format_ip6_header
format_function_t format_ip6_header
Definition: format.h:95
crypto_alg_t::trunc_size
u8 trunc_size
Definition: ipsec.h:91
dpdk_crypto_main_t
Definition: ipsec.h:162
dpdk_esp6_decrypt_post_node
vlib_node_registration_t dpdk_esp6_decrypt_post_node
(constructor) VLIB_REGISTER_NODE (dpdk_esp6_decrypt_post_node)
Definition: esp_decrypt.c:715
dpdk_op_priv_t::encrypt
u8 encrypt
Definition: ipsec.h:67
VLIB_NODE_TYPE_INTERNAL
@ VLIB_NODE_TYPE_INTERNAL
Definition: node.h:72
node
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
padding
u32 padding
Definition: vhost_user.h:124
dpdk_op_priv_t::icv
u8 icv[32]
Definition: ipsec.h:71
dpdk_crypto_main_t::cipher_algs
crypto_alg_t * cipher_algs
Definition: ipsec.h:167
dpdk_op_priv_t::bi
u32 bi
Definition: ipsec.h:66
u16
unsigned short u16
Definition: types.h:57
esp_decrypt_trace_t::crypto_alg
ipsec_crypto_alg_t crypto_alg
Definition: esp_decrypt.c:96
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
crypto_resource_t::n_ops
u16 n_ops
Definition: ipsec.h:126
vlib_frame_t
Definition: node.h:372
esp_decrypt_post_error_strings
static char * esp_decrypt_post_error_strings[]
Definition: esp_decrypt.c:460
esp_header_t::seq
u32 seq
Definition: esp.h:29
clib_memcpy_fast
static_always_inline void * clib_memcpy_fast(void *restrict dst, const void *restrict src, size_t n)
Definition: string.h:92
format_esp_decrypt_trace
static u8 * format_esp_decrypt_trace(u8 *s, va_list *args)
Definition: esp_decrypt.c:80
crypto_alg_t
Definition: ipsec.h:83
ipsec_sa_anti_replay_check
static int ipsec_sa_anti_replay_check(const ipsec_sa_t *sa, u32 seq)
Definition: ipsec_sa.h:314
udp_header_t
Definition: udp_packet.h:45
ESP_DECRYPT_N_ERROR
@ ESP_DECRYPT_N_ERROR
Definition: esp_decrypt.c:81
ip4_header_t
Definition: ip4_packet.h:87
error
Definition: cJSON.c:88
dpdk_crypto_main
dpdk_crypto_main_t dpdk_crypto_main
Definition: ipsec.c:26
esp.h
CLIB_PREFETCH
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:76
dpdk_crypto_main_t::auth_algs
crypto_alg_t * auth_algs
Definition: ipsec.h:168
crypto_worker_main_t
Definition: ipsec.h:74
vlib_buffer_t::current_data
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:119
crypto_set_icb
static_always_inline void crypto_set_icb(dpdk_gcm_cnt_blk *icb, u32 salt, u32 seq, u32 seq_hi)
Definition: ipsec.h:350
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
format_esp_decrypt_post_trace
static u8 * format_esp_decrypt_post_trace(u8 *s, va_list *args)
Definition: esp_decrypt.c:470
dpdk_op_priv_t::next
u32 next
Definition: ipsec.h:65
dpdk_esp4_decrypt_post_node
vlib_node_registration_t dpdk_esp4_decrypt_post_node
(constructor) VLIB_REGISTER_NODE (dpdk_esp4_decrypt_post_node)
Definition: esp_decrypt.c:689
len
u8 len
Definition: ip_types.api:103
VLIB_NODE_FN
#define VLIB_NODE_FN(node)
Definition: node.h:202
format_ipsec_crypto_alg
u8 * format_ipsec_crypto_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:79
ipsec_sa_get
static ipsec_sa_t * ipsec_sa_get(u32 sa_index)
Definition: ipsec_sa.h:605
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
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
vlib_get_thread_index
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:187
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
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
ESP_DECRYPT_POST_N_ERROR
@ ESP_DECRYPT_POST_N_ERROR
Definition: esp_decrypt.c:457
uword
u64 uword
Definition: types.h:112
if
if(node->flags &VLIB_NODE_FLAG_TRACE) vnet_interface_output_trace(vm
buffer.h
esp_decrypt_next_t
esp_decrypt_next_t
Definition: esp_decrypt.c:39
crypto_resource_t::ops
struct rte_crypto_op * ops[VLIB_FRAME_SIZE]
Definition: ipsec.h:128
vlib_main_t::thread_index
u32 thread_index
Definition: main.h:215
crypto_alg_t::iv_len
u8 iv_len
Definition: ipsec.h:90
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
dpdk_esp_decrypt_post_inline
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:493
dpdk_crypto_main_t::resource
crypto_resource_t * resource
Definition: ipsec.h:166
esp_header_t
Definition: esp.h:22
foreach_esp_decrypt_error
#define foreach_esp_decrypt_error
Definition: esp_decrypt.c:42
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
ESP_DECRYPT_N_NEXT
@ ESP_DECRYPT_N_NEXT
Definition: esp_decrypt.c:43
ipsec_sa_t::crypto_alg
ipsec_crypto_alg_t crypto_alg
Definition: ipsec_sa.h:215
vlib_buffer_t::current_length
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:122
dpdk_op_priv_t
Definition: ipsec.h:63
esp_decrypt_post_error_t
esp_decrypt_post_error_t
Definition: esp_decrypt.c:452
dpdk_op_priv_t::cb
dpdk_gcm_cnt_blk cb
Definition: ipsec.h:69
rte_mbuf_from_vlib_buffer
#define rte_mbuf_from_vlib_buffer(x)
Definition: buffer.h:19
foreach_esp_decrypt_next
#define foreach_esp_decrypt_next
Definition: esp_decrypt.c:29
dpdk_gcm_cnt_blk
Definition: ipsec.h:56
crypto_alg_t::type
enum rte_crypto_sym_xform_type type
Definition: ipsec.h:87
ipsec_sa_t
Definition: ipsec_sa.h:116
crypto_free_ops
static_always_inline void crypto_free_ops(u8 numa, struct rte_crypto_op **ops, u32 n)
Definition: ipsec.h:301
is_ip6
bool is_ip6
Definition: ip.api:43
dpdk_esp4_decrypt_node
vlib_node_registration_t dpdk_esp4_decrypt_node
(constructor) VLIB_REGISTER_NODE (dpdk_esp4_decrypt_node)
Definition: esp_decrypt.c:401
esp_decrypt_error_t
esp_decrypt_error_t
Definition: esp_decrypt.c:76
vlib_validate_buffer_enqueue_x1
#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:224
dpdk_crypto_main_t::workers_main
crypto_worker_main_t * workers_main
Definition: ipsec.h:164
esp_decrypt_error_strings
static char * esp_decrypt_error_strings[]
Definition: esp_decrypt.c:62
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
u64
unsigned long u64
Definition: types.h:89
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
format_get_indent
static u32 format_get_indent(u8 *s)
Definition: format.h:72
vlib_buffer_get_tail
static u8 * vlib_buffer_get_tail(vlib_buffer_t *b)
Get pointer to the end of buffer's data.
Definition: buffer.h:338
vlib_put_next_frame
vlib_put_next_frame(vm, node, next_index, 0)
crypto_op_setup
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:358
ip.h
u32
unsigned int u32
Definition: types.h:88
integ_alg
u8 integ_alg
Definition: ikev2_types.api:59
dpdk_op_priv_t::aad
u8 aad[16]
Definition: ipsec.h:70
crypto_alg_t::boundary
u8 boundary
Definition: ipsec.h:92
pad_data
static const u8 pad_data[]
Definition: ipsec.h:177
iv
static u8 iv[]
Definition: aes_cbc.c:24
ipsec_sa_t::salt
u32 salt
Definition: ipsec_sa.h:172
ipsec_sa_t::seq_hi
u32 seq_hi
Definition: ipsec_sa.h:133
ip6_header_t
Definition: ip6_packet.h:294
dpdk_esp6_decrypt_node
vlib_node_registration_t dpdk_esp6_decrypt_node
(constructor) VLIB_REGISTER_NODE (dpdk_esp6_decrypt_node)
Definition: esp_decrypt.c:427
format_ip4_header
format_function_t format_ip4_header
Definition: format.h:81
crypto_worker_main_t::ops
struct rte_crypto_op ** ops
Definition: ipsec.h:77
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
crypto_enqueue_ops
static_always_inline void crypto_enqueue_ops(vlib_main_t *vm, crypto_worker_main_t *cwm, u32 node_index, u32 error, u8 numa, u8 encrypt)
Definition: ipsec.h:313
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
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
ipsec_sa_t::integ_alg
ipsec_integ_alg_t integ_alg
Definition: ipsec_sa.h:216
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
esp_decrypt_trace_t
Definition: esp_decrypt.c:90
ip4_header_bytes
static int ip4_header_bytes(const ip4_header_t *i)
Definition: ip4_packet.h:190
dpdk_esp_decrypt_inline
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
esp_decrypt_trace_t::packet_data
u8 packet_data[64]
Definition: esp_decrypt.c:75
crypto_alloc_ops
static_always_inline i32 crypto_alloc_ops(u8 numa, struct rte_crypto_op **ops, u32 n)
Definition: ipsec.h:285
vnet.h
api_errno.h
crypto_resource_t::bi
u32 bi[VLIB_FRAME_SIZE]
Definition: ipsec.h:129
vlib_node_runtime_t
Definition: node.h:454
format_esp_header
u8 * format_esp_header(u8 *s, va_list *args)
Definition: esp_format.c:23
from
from
Definition: nat44_ei_hairpinning.c:415
thread_idx
#define thread_idx
Definition: tls_async.c:40
vlib_get_next_frame
#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:395
VLIB_TX
@ VLIB_TX
Definition: defs.h:47
n_left_from
n_left_from
Definition: nat44_ei_hairpinning.c:416
crypto_resource_t
Definition: ipsec.h:117
crypto_op_get_priv
static_always_inline dpdk_op_priv_t * crypto_op_get_priv(struct rte_crypto_op *op)
Definition: ipsec.h:209
type
vl_api_fib_path_type_t type
Definition: fib_types.api:123
foreach_esp_decrypt_post_error
#define foreach_esp_decrypt_post_error
Definition: esp_decrypt.c:449
vlib_increment_combined_counter
vlib_increment_combined_counter(ccm, ti, sw_if_index, n_buffers, n_bytes)
format_white_space
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:129
dpdk_priv.h
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
vlib_buffer_t
VLIB buffer representation.
Definition: buffer.h:111
VLIB_REGISTER_NODE
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:169
crypto_alg_t::alg
u32 alg
Definition: ipsec.h:88
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
get_resource
static_always_inline u16 get_resource(crypto_worker_main_t *cwm, ipsec_sa_t *sa)
Definition: ipsec.h:260