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