FD.io VPP  v17.04-9-g99c0734
Vector Packet Processing
esp_encrypt.c
Go to the documentation of this file.
1 /*
2  * esp_encrypt.c : IPSec ESP encrypt 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_encrypt_next \
29 _(DROP, "error-drop") \
30 _(IP4_LOOKUP, "ip4-lookup") \
31 _(IP6_LOOKUP, "ip6-lookup") \
32 _(INTERFACE_OUTPUT, "interface-output")
33 
34 #define _(v, s) ESP_ENCRYPT_NEXT_##v,
35 typedef enum
36 {
38 #undef _
41 
42 #define foreach_esp_encrypt_error \
43  _(RX_PKTS, "ESP pkts received") \
44  _(SEQ_CYCLED, "sequence number cycled") \
45  _(ENQ_FAIL, "Enqueue failed (buffer full)") \
46  _(NO_CRYPTODEV, "Cryptodev not configured") \
47  _(UNSUPPORTED, "Cipher/Auth not supported")
48 
49 
50 typedef enum
51 {
52 #define _(sym,str) ESP_ENCRYPT_ERROR_##sym,
54 #undef _
57 
58 static char *esp_encrypt_error_strings[] = {
59 #define _(sym,string) string,
61 #undef _
62 };
63 
65 
66 typedef struct
67 {
68  u32 spi;
69  u32 seq;
70  ipsec_crypto_alg_t crypto_alg;
71  ipsec_integ_alg_t integ_alg;
73 
74 /* packet trace format function */
75 static u8 *
76 format_esp_encrypt_trace (u8 * s, va_list * args)
77 {
78  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
79  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
80  esp_encrypt_trace_t *t = va_arg (*args, esp_encrypt_trace_t *);
81 
82  s = format (s, "esp: spi %u seq %u crypto %U integrity %U",
83  t->spi, t->seq,
86  return s;
87 }
88 
89 static uword
91  vlib_node_runtime_t * node,
92  vlib_frame_t * from_frame)
93 {
94  u32 n_left_from, *from, *to_next, next_index;
95  ipsec_main_t *im = &ipsec_main;
96  u32 cpu_index = os_get_cpu_number ();
99  u32 i;
100 
101  from = vlib_frame_vector_args (from_frame);
102  n_left_from = from_frame->n_vectors;
103 
104  if (PREDICT_FALSE (!dcm->workers_main))
105  {
106  /* Likely there are not enough cryptodevs, so drop frame */
108  ESP_ENCRYPT_ERROR_NO_CRYPTODEV,
109  n_left_from);
110  vlib_buffer_free (vm, from, n_left_from);
111  return n_left_from;
112  }
113 
114  crypto_worker_main_t *cwm = vec_elt_at_index (dcm->workers_main, cpu_index);
115  u32 n_qps = vec_len (cwm->qp_data);
116  struct rte_crypto_op **cops_to_enq[n_qps];
117  u32 n_cop_qp[n_qps], *bi_to_enq[n_qps];
118 
119  for (i = 0; i < n_qps; i++)
120  {
121  bi_to_enq[i] = cwm->qp_data[i].bi;
122  cops_to_enq[i] = cwm->qp_data[i].cops;
123  }
124 
125  memset (n_cop_qp, 0, n_qps * sizeof (u32));
126 
128 
129  next_index = ESP_ENCRYPT_NEXT_DROP;
130 
131  while (n_left_from > 0)
132  {
133  u32 n_left_to_next;
134 
135  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
136 
137  while (n_left_from > 0 && n_left_to_next > 0)
138  {
139  u32 bi0, next0;
140  vlib_buffer_t *b0 = 0;
141  u32 sa_index0;
142  ipsec_sa_t *sa0;
143  ip4_and_esp_header_t *ih0, *oh0 = 0;
144  ip6_and_esp_header_t *ih6_0, *oh6_0 = 0;
145  struct rte_mbuf *mb0 = 0;
146  esp_footer_t *f0;
147  u8 is_ipv6;
148  u8 ip_hdr_size;
149  u8 next_hdr_type;
150  u8 transport_mode = 0;
151  const int BLOCK_SIZE = 16;
152  u32 iv_size;
153  u16 orig_sz;
154  crypto_sa_session_t *sa_sess;
155  void *sess;
156  struct rte_crypto_op *cop = 0;
157  u16 qp_index;
158 
159  bi0 = from[0];
160  from += 1;
161  n_left_from -= 1;
162 
163  b0 = vlib_get_buffer (vm, bi0);
164  sa_index0 = vnet_buffer (b0)->ipsec.sad_index;
165  sa0 = pool_elt_at_index (im->sad, sa_index0);
166 
167  if (PREDICT_FALSE (esp_seq_advance (sa0)))
168  {
169  clib_warning ("sequence number counter has cycled SPI %u",
170  sa0->spi);
172  ESP_ENCRYPT_ERROR_SEQ_CYCLED, 1);
173  //TODO: rekey SA
174  to_next[0] = bi0;
175  to_next += 1;
176  n_left_to_next -= 1;
177  goto trace;
178  }
179 
180  sa0->total_data_size += b0->current_length;
181 
182  sa_sess = pool_elt_at_index (cwm->sa_sess_d[1], sa_index0);
183  if (PREDICT_FALSE (!sa_sess->sess))
184  {
185  int ret = create_sym_sess (sa0, sa_sess, 1);
186 
187  if (PREDICT_FALSE (ret))
188  {
189  to_next[0] = bi0;
190  to_next += 1;
191  n_left_to_next -= 1;
192  goto trace;
193  }
194  }
195 
196  qp_index = sa_sess->qp_index;
197  sess = sa_sess->sess;
198 
199  ASSERT (vec_len (vec_elt (cwm->qp_data, qp_index).free_cops) > 0);
200  cop = vec_pop (vec_elt (cwm->qp_data, qp_index).free_cops);
201  ASSERT (cop->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED);
202 
203  cops_to_enq[qp_index][0] = cop;
204  cops_to_enq[qp_index] += 1;
205  n_cop_qp[qp_index] += 1;
206  bi_to_enq[qp_index][0] = bi0;
207  bi_to_enq[qp_index] += 1;
208 
209  ssize_t adv;
210  iv_size = em->esp_crypto_algs[sa0->crypto_alg].iv_len;
211  ih0 = vlib_buffer_get_current (b0);
212  orig_sz = b0->current_length;
213  is_ipv6 = (ih0->ip4.ip_version_and_header_length & 0xF0) == 0x60;
214  /* is ipv6 */
215  if (PREDICT_TRUE (sa0->is_tunnel))
216  {
217  if (PREDICT_TRUE (!is_ipv6))
218  adv = -sizeof (ip4_and_esp_header_t);
219  else
220  adv = -sizeof (ip6_and_esp_header_t);
221  }
222  else
223  {
224  adv = -sizeof (esp_header_t);
225  if (PREDICT_TRUE (!is_ipv6))
226  orig_sz -= sizeof (ip4_header_t);
227  else
228  orig_sz -= sizeof (ip6_header_t);
229  }
230 
231  /*transport mode save the eth header before it is overwritten */
232  if (PREDICT_FALSE (!sa0->is_tunnel))
233  {
235  ((u8 *) vlib_buffer_get_current (b0) -
236  sizeof (ethernet_header_t));
237  ethernet_header_t *oeh0 =
238  (ethernet_header_t *) ((u8 *) ieh0 + (adv - iv_size));
239  clib_memcpy (oeh0, ieh0, sizeof (ethernet_header_t));
240  }
241 
242  vlib_buffer_advance (b0, adv - iv_size);
243 
244  /* XXX IP6/ip4 and IP4/IP6 not supported, only IP4/IP4 and IP6/IP6 */
245 
246  /* is ipv6 */
247  if (PREDICT_FALSE (is_ipv6))
248  {
249  ih6_0 = (ip6_and_esp_header_t *) ih0;
250  ip_hdr_size = sizeof (ip6_header_t);
251  oh6_0 = vlib_buffer_get_current (b0);
252 
253  if (PREDICT_TRUE (sa0->is_tunnel))
254  {
255  next_hdr_type = IP_PROTOCOL_IPV6;
256  oh6_0->ip6.ip_version_traffic_class_and_flow_label =
257  ih6_0->ip6.ip_version_traffic_class_and_flow_label;
258  }
259  else
260  {
261  next_hdr_type = ih6_0->ip6.protocol;
262  memmove (oh6_0, ih6_0, sizeof (ip6_header_t));
263  }
264 
265  oh6_0->ip6.protocol = IP_PROTOCOL_IPSEC_ESP;
266  oh6_0->ip6.hop_limit = 254;
267  oh6_0->esp.spi = clib_net_to_host_u32 (sa0->spi);
268  oh6_0->esp.seq = clib_net_to_host_u32 (sa0->seq);
269  }
270  else
271  {
272  ip_hdr_size = sizeof (ip4_header_t);
273  oh0 = vlib_buffer_get_current (b0);
274 
275  if (PREDICT_TRUE (sa0->is_tunnel))
276  {
277  next_hdr_type = IP_PROTOCOL_IP_IN_IP;
278  oh0->ip4.tos = ih0->ip4.tos;
279  }
280  else
281  {
282  next_hdr_type = ih0->ip4.protocol;
283  memmove (oh0, ih0, sizeof (ip4_header_t));
284  }
285 
286  oh0->ip4.ip_version_and_header_length = 0x45;
287  oh0->ip4.fragment_id = 0;
288  oh0->ip4.flags_and_fragment_offset = 0;
289  oh0->ip4.ttl = 254;
290  oh0->ip4.protocol = IP_PROTOCOL_IPSEC_ESP;
291  oh0->esp.spi = clib_net_to_host_u32 (sa0->spi);
292  oh0->esp.seq = clib_net_to_host_u32 (sa0->seq);
293  }
294 
295  if (PREDICT_TRUE (sa0->is_tunnel && !sa0->is_tunnel_ip6))
296  {
297  oh0->ip4.src_address.as_u32 = sa0->tunnel_src_addr.ip4.as_u32;
298  oh0->ip4.dst_address.as_u32 = sa0->tunnel_dst_addr.ip4.as_u32;
299 
300  /* in tunnel mode send it back to FIB */
301  next0 = ESP_ENCRYPT_NEXT_IP4_LOOKUP;
302  vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32) ~ 0;
303  }
304  else if (sa0->is_tunnel && sa0->is_tunnel_ip6)
305  {
306  oh6_0->ip6.src_address.as_u64[0] =
307  sa0->tunnel_src_addr.ip6.as_u64[0];
308  oh6_0->ip6.src_address.as_u64[1] =
309  sa0->tunnel_src_addr.ip6.as_u64[1];
310  oh6_0->ip6.dst_address.as_u64[0] =
311  sa0->tunnel_dst_addr.ip6.as_u64[0];
312  oh6_0->ip6.dst_address.as_u64[1] =
313  sa0->tunnel_dst_addr.ip6.as_u64[1];
314 
315  /* in tunnel mode send it back to FIB */
316  next0 = ESP_ENCRYPT_NEXT_IP6_LOOKUP;
317  vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32) ~ 0;
318  }
319  else
320  {
321  next0 = ESP_ENCRYPT_NEXT_INTERFACE_OUTPUT;
322  transport_mode = 1;
323  }
324 
326  ASSERT (sa0->crypto_alg != IPSEC_CRYPTO_ALG_NONE);
327 
328  int blocks = 1 + (orig_sz + 1) / BLOCK_SIZE;
329 
330  /* pad packet in input buffer */
331  u8 pad_bytes = BLOCK_SIZE * blocks - 2 - orig_sz;
332  u8 i;
334 
335  for (i = 0; i < pad_bytes; ++i)
336  padding[i] = i + 1;
337 
338  f0 = vlib_buffer_get_current (b0) + b0->current_length + pad_bytes;
339  f0->pad_length = pad_bytes;
340  f0->next_header = next_hdr_type;
341  b0->current_length += pad_bytes + 2 +
343 
344  vnet_buffer (b0)->sw_if_index[VLIB_RX] =
345  vnet_buffer (b0)->sw_if_index[VLIB_RX];
347 
348  struct rte_crypto_sym_op *sym_cop;
349  sym_cop = (struct rte_crypto_sym_op *) (cop + 1);
350 
351  dpdk_cop_priv_t *priv = (dpdk_cop_priv_t *) (sym_cop + 1);
352 
353  vnet_buffer (b0)->unused[0] = next0;
354 
355  mb0 = rte_mbuf_from_vlib_buffer (b0);
356  mb0->data_len = b0->current_length;
357  mb0->pkt_len = b0->current_length;
358  mb0->data_off = RTE_PKTMBUF_HEADROOM + b0->current_data;
359 
360  rte_crypto_op_attach_sym_session (cop, sess);
361 
362  sym_cop->m_src = mb0;
363 
364  dpdk_gcm_cnt_blk *icb = &priv->cb;
365  icb->salt = sa0->salt;
366  icb->iv[0] = sa0->seq;
367  icb->iv[1] = sa0->seq_hi;
368 
369  if (sa0->crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
370  {
371  icb->cnt = clib_host_to_net_u32 (1);
372  clib_memcpy (vlib_buffer_get_current (b0) + ip_hdr_size +
373  sizeof (esp_header_t), icb->iv, 8);
374  sym_cop->cipher.data.offset =
375  ip_hdr_size + sizeof (esp_header_t) + iv_size;
376  sym_cop->cipher.data.length = BLOCK_SIZE * blocks;
377  sym_cop->cipher.iv.length = 16;
378  }
379  else
380  {
381  sym_cop->cipher.data.offset =
382  ip_hdr_size + sizeof (esp_header_t);
383  sym_cop->cipher.data.length = BLOCK_SIZE * blocks + iv_size;
384  sym_cop->cipher.iv.length = iv_size;
385  }
386 
387  sym_cop->cipher.iv.data = (u8 *) icb;
388  sym_cop->cipher.iv.phys_addr = cop->phys_addr + (uintptr_t) icb
389  - (uintptr_t) cop;
390 
391 
393  ASSERT (sa0->integ_alg != IPSEC_INTEG_ALG_NONE);
394 
395  if (PREDICT_FALSE (sa0->integ_alg == IPSEC_INTEG_ALG_AES_GCM_128))
396  {
397  u8 *aad = priv->aad;
398  clib_memcpy (aad, vlib_buffer_get_current (b0) + ip_hdr_size,
399  8);
400  sym_cop->auth.aad.data = aad;
401  sym_cop->auth.aad.phys_addr = cop->phys_addr +
402  (uintptr_t) aad - (uintptr_t) cop;
403 
404  if (PREDICT_FALSE (sa0->use_esn))
405  {
406  *((u32 *) & aad[8]) = sa0->seq_hi;
407  sym_cop->auth.aad.length = 12;
408  }
409  else
410  {
411  sym_cop->auth.aad.length = 8;
412  }
413  }
414  else
415  {
416  sym_cop->auth.data.offset = ip_hdr_size;
417  sym_cop->auth.data.length = b0->current_length - ip_hdr_size
418  - em->esp_integ_algs[sa0->integ_alg].trunc_size;
419 
420  if (PREDICT_FALSE (sa0->use_esn))
421  {
422  u8 *payload_end =
424  *((u32 *) payload_end) = sa0->seq_hi;
425  sym_cop->auth.data.length += sizeof (sa0->seq_hi);
426  }
427  }
428  sym_cop->auth.digest.data = vlib_buffer_get_current (b0) +
429  b0->current_length -
431  sym_cop->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset (mb0,
432  b0->current_length
433  -
434  em->esp_integ_algs
435  [sa0->integ_alg].trunc_size);
436  sym_cop->auth.digest.length =
438 
439 
440  if (PREDICT_FALSE (is_ipv6))
441  {
442  oh6_0->ip6.payload_length =
443  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0) -
444  sizeof (ip6_header_t));
445  }
446  else
447  {
448  oh0->ip4.length =
449  clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b0));
450  oh0->ip4.checksum = ip4_header_checksum (&oh0->ip4);
451  }
452 
453  if (transport_mode)
454  vlib_buffer_advance (b0, -sizeof (ethernet_header_t));
455 
456  trace:
458  {
459  esp_encrypt_trace_t *tr =
460  vlib_add_trace (vm, node, b0, sizeof (*tr));
461  tr->spi = sa0->spi;
462  tr->seq = sa0->seq - 1;
463  tr->crypto_alg = sa0->crypto_alg;
464  tr->integ_alg = sa0->integ_alg;
465  }
466  }
467  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
468  }
470  ESP_ENCRYPT_ERROR_RX_PKTS,
471  from_frame->n_vectors);
472  crypto_qp_data_t *qpd;
473  /* *INDENT-OFF* */
474  vec_foreach_index (i, cwm->qp_data)
475  {
476  u32 enq;
477 
478  qpd = vec_elt_at_index(cwm->qp_data, i);
479  enq = rte_cryptodev_enqueue_burst(qpd->dev_id, qpd->qp_id,
480  qpd->cops, n_cop_qp[i]);
481  qpd->inflights += enq;
482 
483  if (PREDICT_FALSE(enq < n_cop_qp[i]))
484  {
485  crypto_free_cop (qpd, &qpd->cops[enq], n_cop_qp[i] - enq);
486  vlib_buffer_free (vm, &qpd->bi[enq], n_cop_qp[i] - enq);
487 
489  ESP_ENCRYPT_ERROR_ENQ_FAIL,
490  n_cop_qp[i] - enq);
491  }
492  }
493  /* *INDENT-ON* */
494 
495  return from_frame->n_vectors;
496 }
497 
499 {
500  .function = dpdk_esp_encrypt_node_fn,.name = "dpdk-esp-encrypt",.flags =
501  VLIB_NODE_FLAG_IS_OUTPUT,.vector_size = sizeof (u32),.format_trace =
502  format_esp_encrypt_trace,.n_errors =
503  ARRAY_LEN (esp_encrypt_error_strings),.error_strings =
504  esp_encrypt_error_strings,.n_next_nodes = 1,.next_nodes =
505  {
506  [ESP_ENCRYPT_NEXT_DROP] = "error-drop",}
507 };
508 
510 /*
511  * ESP Encrypt Post Node
512  */
513 #define foreach_esp_encrypt_post_error \
514  _(PKTS, "ESP post pkts")
515  typedef enum
516  {
517 #define _(sym,str) ESP_ENCRYPT_POST_ERROR_##sym,
519 #undef _
522 
524 #define _(sym,string) string,
526 #undef _
527  };
528 
530 
531 static u8 *
532 format_esp_encrypt_post_trace (u8 * s, va_list * args)
533 {
534  return s;
535 }
536 
537 static uword
539  vlib_node_runtime_t * node,
540  vlib_frame_t * from_frame)
541 {
542  u32 n_left_from, *from, *to_next = 0, next_index;
543 
544  from = vlib_frame_vector_args (from_frame);
545  n_left_from = from_frame->n_vectors;
546 
547  next_index = node->cached_next_index;
548 
549  while (n_left_from > 0)
550  {
551  u32 n_left_to_next;
552 
553  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
554 
555  while (n_left_from > 0 && n_left_to_next > 0)
556  {
557  u32 bi0, next0;
558  vlib_buffer_t *b0 = 0;
559 
560  bi0 = from[0];
561  from += 1;
562  n_left_from -= 1;
563  n_left_to_next -= 1;
564 
565  b0 = vlib_get_buffer (vm, bi0);
566 
567  to_next[0] = bi0;
568  to_next += 1;
569 
570  next0 = vnet_buffer (b0)->unused[0];
571 
572  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
573  to_next, n_left_to_next, bi0,
574  next0);
575  }
576  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
577  }
578 
580  ESP_ENCRYPT_POST_ERROR_PKTS,
581  from_frame->n_vectors);
582 
583  return from_frame->n_vectors;
584 }
585 
587 {
588  .function = dpdk_esp_encrypt_post_node_fn,.name =
589  "dpdk-esp-encrypt-post",.vector_size = sizeof (u32),.format_trace =
591  ARRAY_LEN (esp_encrypt_post_error_strings),.error_strings =
592  esp_encrypt_post_error_strings,.n_next_nodes =
593  ESP_ENCRYPT_N_NEXT,.next_nodes =
594  {
595 #define _(s,n) [ESP_ENCRYPT_NEXT_##s] = n,
597 #undef _
598  }
599 };
600 
603 /*
604  * fd.io coding-style-patch-verification: ON
605  *
606  * Local Variables:
607  * eval: (c-set-style "gnu")
608  * End:
609  */
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:343
#define CLIB_UNUSED(x)
Definition: clib.h:79
ip46_address_t tunnel_src_addr
Definition: ipsec.h:119
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:1172
u8 aad[12]
Definition: ipsec.h:46
#define PREDICT_TRUE(x)
Definition: clib.h:98
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
static u8 * format_esp_encrypt_trace(u8 *s, va_list *args)
Definition: esp_encrypt.c:76
u32 padding
Definition: vhost-user.h:78
u8 is_tunnel
Definition: ipsec.h:117
struct _vlib_node_registration vlib_node_registration_t
ipsec_integ_alg_t integ_alg
Definition: esp_encrypt.c:68
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:418
ipsec_crypto_alg_t crypto_alg
Definition: esp_encrypt.c:67
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
#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:127
dpdk_crypto_main_t dpdk_crypto_main
Definition: ipsec.h:88
u32 spi
Definition: ipsec.h:103
u32 seq_hi
Definition: ipsec.h:126
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:67
vlib_node_registration_t dpdk_esp_encrypt_post_node
(constructor) VLIB_REGISTER_NODE (dpdk_esp_encrypt_post_node)
Definition: esp_encrypt.c:529
static_always_inline void crypto_alloc_cops()
Definition: ipsec.h:95
ipsec_main_t ipsec_main
Definition: ipsec.h:282
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.
vlib_node_registration_t dpdk_esp_encrypt_node
(constructor) VLIB_REGISTER_NODE (dpdk_esp_encrypt_node)
Definition: esp_encrypt.c:64
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
esp_encrypt_error_t
Definition: esp_encrypt.c:47
#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
uword os_get_cpu_number(void)
Definition: unix-misc.c:224
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:188
#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:350
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1112
ip46_address_t tunnel_dst_addr
Definition: ipsec.h:120
dpdk_gcm_cnt_blk cb
Definition: ipsec.h:43
u16 n_vectors
Definition: node.h:344
vlib_main_t * vm
Definition: buffer.c:276
#define foreach_esp_encrypt_error
Definition: esp_encrypt.c:42
#define clib_warning(format, args...)
Definition: error.h:59
#define VLIB_BUFFER_IS_TRACED
Definition: buffer.h:85
#define foreach_esp_encrypt_post_error
Definition: esp_encrypt.c:513
#define clib_memcpy(a, b, c)
Definition: string.h:69
static char * esp_encrypt_error_strings[]
Definition: esp_encrypt.c:58
#define ARRAY_LEN(x)
Definition: clib.h:59
esp_encrypt_next_t
Definition: esp_encrypt.c:33
esp_encrypt_post_error_t
Definition: esp_encrypt.c:515
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
Definition: node.h:455
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
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
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
u32 seq
Definition: ipsec.h:125
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
#define VLIB_NODE_FLAG_IS_OUTPUT
Definition: node.h:253
Definition: defs.h:47
unsigned short u16
Definition: types.h:57
static char * esp_encrypt_post_error_strings[]
Definition: esp_encrypt.c:523
#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:253
static uword dpdk_esp_encrypt_post_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: esp_encrypt.c:538
#define vnet_buffer(b)
Definition: buffer.h:294
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
Definition: node.h:158
ipsec_crypto_alg_t crypto_alg
Definition: ipsec.h:106
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:143
static uword dpdk_esp_encrypt_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *from_frame)
Definition: esp_encrypt.c:90
#define foreach_esp_encrypt_next
Definition: esp_encrypt.c:28
static int esp_seq_advance(ipsec_sa_t *sa)
Definition: esp.h:207
u32 flags
buffer flags: VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:74
static u8 * format_esp_encrypt_post_trace(u8 *s, va_list *args)
Definition: esp_encrypt.c:532
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:238
Definition: defs.h:46
static_always_inline int create_sym_sess(ipsec_sa_t *sa, crypto_sa_session_t *sa_sess, u8 is_outbound)
Definition: esp.h:170