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