FD.io VPP  v18.04-17-g3a0d853
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/ipsec/ipsec.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-no-checksum") \
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  _(DISCARD, "Not enough crypto operations, discarding frame") \
47  _(BAD_LEN, "Invalid ciphertext length") \
48  _(SESSION, "Failed to get crypto session") \
49  _(NOSUP, "Cipher/Auth not supported")
50 
51 
52 typedef enum {
53 #define _(sym,str) ESP_DECRYPT_ERROR_##sym,
55 #undef _
58 
59 static char * esp_decrypt_error_strings[] = {
60 #define _(sym,string) string,
62 #undef _
63 };
64 
66 
67 typedef struct {
68  ipsec_crypto_alg_t crypto_alg;
69  ipsec_integ_alg_t integ_alg;
70  u8 packet_data[64];
72 
73 /* packet trace format function */
74 static u8 * format_esp_decrypt_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_decrypt_trace_t * t = va_arg (*args, esp_decrypt_trace_t *);
79  u32 indent = format_get_indent (s);
80 
81  s = format (s, "cipher %U auth %U\n",
84  s = format (s, "%U%U",
85  format_white_space, indent,
87  return s;
88 }
89 
90 static uword
92  vlib_node_runtime_t * node,
93  vlib_frame_t * from_frame)
94 {
95  u32 n_left_from, *from, *to_next, next_index;
96  ipsec_main_t *im = &ipsec_main;
97  u32 thread_idx = vlib_get_thread_index();
99  crypto_resource_t *res = 0;
100  ipsec_sa_t *sa0 = 0;
101  crypto_alg_t *cipher_alg = 0, *auth_alg = 0;
102  struct rte_cryptodev_sym_session *session = 0;
103  u32 ret, last_sa_index = ~0;
104  u8 numa = rte_socket_id ();
105  u8 is_aead = 0;
106  crypto_worker_main_t *cwm =
107  vec_elt_at_index (dcm->workers_main, thread_idx);
108  struct rte_crypto_op **ops = cwm->ops;
109 
110  from = vlib_frame_vector_args (from_frame);
111  n_left_from = from_frame->n_vectors;
112 
113  ret = crypto_alloc_ops (numa, ops, n_left_from);
114  if (ret)
115  {
117  ESP_DECRYPT_ERROR_DISCARD, 1);
118  /* Discard whole frame */
119  return n_left_from;
120  }
121 
122  next_index = ESP_DECRYPT_NEXT_DROP;
123 
124  while (n_left_from > 0)
125  {
126  u32 n_left_to_next;
127 
128  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
129 
130  while (n_left_from > 0 && n_left_to_next > 0)
131  {
132  clib_error_t *error;
133  u32 bi0, sa_index0, seq, iv_size;
134  u8 trunc_size;
135  vlib_buffer_t *b0;
136  esp_header_t *esp0;
137  struct rte_mbuf *mb0;
138  struct rte_crypto_op *op;
139  u16 res_idx;
140 
141  bi0 = from[0];
142  from += 1;
143  n_left_from -= 1;
144 
145  b0 = vlib_get_buffer (vm, bi0);
146  mb0 = rte_mbuf_from_vlib_buffer(b0);
147  esp0 = vlib_buffer_get_current (b0);
148 
149  /* ih0/ih6_0 */
150  CLIB_PREFETCH (esp0, sizeof (esp0[0]) + 16, LOAD);
151  /* mb0 */
152  CLIB_PREFETCH (mb0, CLIB_CACHE_LINE_BYTES, STORE);
153 
154  op = ops[0];
155  ops += 1;
156  ASSERT (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED);
157 
158  dpdk_op_priv_t *priv = crypto_op_get_priv (op);
159 
160  u16 op_len =
161  sizeof (op[0]) + sizeof (op[0].sym[0]) + sizeof (priv[0]);
162  CLIB_PREFETCH (op, op_len, STORE);
163 
164  sa_index0 = vnet_buffer(b0)->ipsec.sad_index;
165 
166  if (sa_index0 != last_sa_index)
167  {
168  sa0 = pool_elt_at_index (im->sad, sa_index0);
169 
170  cipher_alg = vec_elt_at_index (dcm->cipher_algs, sa0->crypto_alg);
171  auth_alg = vec_elt_at_index (dcm->auth_algs, sa0->integ_alg);
172 
173  is_aead = (cipher_alg->type == RTE_CRYPTO_SYM_XFORM_AEAD);
174  if (is_aead)
175  auth_alg = cipher_alg;
176 
177  res_idx = get_resource (cwm, sa0);
178 
179  if (PREDICT_FALSE (res_idx == (u16) ~0))
180  {
181  clib_warning ("unsupported SA by thread index %u", thread_idx);
183  ESP_DECRYPT_ERROR_NOSUP, 1);
184  to_next[0] = bi0;
185  to_next += 1;
186  n_left_to_next -= 1;
187  goto trace;
188  }
189  res = vec_elt_at_index (dcm->resource, res_idx);
190 
191  error = crypto_get_session (&session, sa_index0, res, cwm, 0);
192  if (PREDICT_FALSE (error || !session))
193  {
194  clib_warning ("failed to get crypto session");
196  ESP_DECRYPT_ERROR_SESSION, 1);
197  to_next[0] = bi0;
198  to_next += 1;
199  n_left_to_next -= 1;
200  goto trace;
201  }
202 
203  last_sa_index = sa_index0;
204  }
205 
206  /* anti-replay check */
207  if (sa0->use_anti_replay)
208  {
209  int rv = 0;
210 
211  seq = clib_net_to_host_u32 (esp0->seq);
212 
213  if (PREDICT_TRUE(sa0->use_esn))
214  rv = esp_replay_check_esn (sa0, seq);
215  else
216  rv = esp_replay_check (sa0, seq);
217 
218  if (PREDICT_FALSE (rv))
219  {
220  clib_warning ("failed anti-replay check");
222  ESP_DECRYPT_ERROR_REPLAY, 1);
223  to_next[0] = bi0;
224  to_next += 1;
225  n_left_to_next -= 1;
226  goto trace;
227  }
228  }
229 
230  priv->next = DPDK_CRYPTO_INPUT_NEXT_DECRYPT_POST;
231 
232  /* FIXME multi-seg */
233  sa0->total_data_size += b0->current_length;
234 
235  res->ops[res->n_ops] = op;
236  res->bi[res->n_ops] = bi0;
237  res->n_ops += 1;
238 
239  /* Convert vlib buffer to mbuf */
240  mb0->data_len = b0->current_length;
241  mb0->pkt_len = b0->current_length;
242  mb0->data_off = RTE_PKTMBUF_HEADROOM + b0->current_data;
243 
244  trunc_size = auth_alg->trunc_size;
245  iv_size = cipher_alg->iv_len;
246 
247  /* Outer IP header has already been stripped */
248  u16 payload_len =
249  b0->current_length - sizeof (esp_header_t) - iv_size - trunc_size;
250 
251  ASSERT (payload_len >= 4);
252 
253  if (payload_len & (cipher_alg->boundary - 1))
254  {
255  clib_warning ("payload %u not multiple of %d\n",
256  payload_len, cipher_alg->boundary);
258  ESP_DECRYPT_ERROR_BAD_LEN, 1);
259  res->n_ops -= 1;
260  to_next[0] = bi0;
261  to_next += 1;
262  n_left_to_next -= 1;
263  goto trace;
264  }
265 
266  u32 cipher_off, cipher_len;
267  u32 auth_len = 0;
268  u8 *aad = NULL;
269 
270  u8 *iv = (u8 *) (esp0 + 1);
271 
272  dpdk_gcm_cnt_blk *icb = &priv->cb;
273 
274  cipher_off = sizeof (esp_header_t) + iv_size;
275  cipher_len = payload_len;
276 
277  u8 *digest = vlib_buffer_get_tail (b0) - trunc_size;
278  u64 digest_paddr =
279  mb0->buf_physaddr + digest - ((u8 *) mb0->buf_addr);
280 
281  if (!is_aead && cipher_alg->alg == RTE_CRYPTO_CIPHER_AES_CBC)
282  clib_memcpy(icb, iv, 16);
283  else /* CTR/GCM */
284  {
285  u32 *_iv = (u32 *) iv;
286 
287  crypto_set_icb (icb, sa0->salt, _iv[0], _iv[1]);
288  }
289 
290  if (is_aead)
291  {
292  aad = priv->aad;
293  u32 * _aad = (u32 *) aad;
294  clib_memcpy (aad, esp0, 8);
295 
296  /* _aad[3] should always be 0 */
297  if (PREDICT_FALSE (sa0->use_esn))
298  _aad[2] = clib_host_to_net_u32 (sa0->seq_hi);
299  else
300  _aad[2] = 0;
301  }
302  else
303  {
304  auth_len = sizeof(esp_header_t) + iv_size + payload_len;
305 
306  if (sa0->use_esn)
307  {
308  clib_memcpy (priv->icv, digest, trunc_size);
309  u32 *_digest = (u32 *) digest;
310  _digest[0] = clib_host_to_net_u32 (sa0->seq_hi);
311  auth_len += sizeof(sa0->seq_hi);
312 
313  digest = priv->icv;
314  digest_paddr =
315  op->phys_addr + (uintptr_t) priv->icv - (uintptr_t) op;
316  }
317  }
318 
319  crypto_op_setup (is_aead, mb0, op, session, cipher_off, cipher_len,
320  0, auth_len, aad, digest, digest_paddr);
321 trace:
322  if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
323  {
324  esp_decrypt_trace_t *tr = vlib_add_trace (vm, node, b0, sizeof (*tr));
325  tr->crypto_alg = sa0->crypto_alg;
326  tr->integ_alg = sa0->integ_alg;
328  sizeof (esp_header_t));
329  }
330  }
331  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
332  }
333 
335  ESP_DECRYPT_ERROR_RX_PKTS,
336  from_frame->n_vectors);
337 
338  crypto_enqueue_ops (vm, cwm, 0, dpdk_esp_decrypt_node.index,
339  ESP_DECRYPT_ERROR_ENQ_FAIL, numa);
340 
341  crypto_free_ops (numa, ops, cwm->ops + from_frame->n_vectors - ops);
342 
343  return from_frame->n_vectors;
344 }
345 
346 /* *INDENT-OFF* */
348  .function = dpdk_esp_decrypt_node_fn,
349  .name = "dpdk-esp-decrypt",
350  .vector_size = sizeof (u32),
351  .format_trace = format_esp_decrypt_trace,
352  .type = VLIB_NODE_TYPE_INTERNAL,
353 
355  .error_strings = esp_decrypt_error_strings,
356 
357  .n_next_nodes = ESP_DECRYPT_N_NEXT,
358  .next_nodes = {
359 #define _(s,n) [ESP_DECRYPT_NEXT_##s] = n,
361 #undef _
362  },
363 };
364 /* *INDENT-ON* */
365 
367 
368 /*
369  * Decrypt Post Node
370  */
371 
372 #define foreach_esp_decrypt_post_error \
373  _(PKTS, "ESP post pkts")
374 
375 typedef enum {
376 #define _(sym,str) ESP_DECRYPT_POST_ERROR_##sym,
378 #undef _
381 
383 #define _(sym,string) string,
385 #undef _
386 };
387 
389 
390 static u8 * format_esp_decrypt_post_trace (u8 * s, va_list * args)
391 {
392  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
393  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
394  esp_decrypt_trace_t * t = va_arg (*args, esp_decrypt_trace_t *);
395  u32 indent = format_get_indent (s);
396 
397  s = format (s, "cipher %U auth %U\n",
400 
401  ip4_header_t *ih4 = (ip4_header_t *) t->packet_data;
402  if ((ih4->ip_version_and_header_length & 0xF0) == 0x60)
403  s = format (s, "%U%U", format_white_space, indent, format_ip6_header, ih4);
404  else
405  s = format (s, "%U%U", format_white_space, indent, format_ip4_header, ih4);
406 
407  return s;
408 }
409 
410 static uword
412  vlib_node_runtime_t * node,
413  vlib_frame_t * from_frame)
414 {
415  u32 n_left_from, *from, *to_next = 0, next_index;
416  ipsec_sa_t * sa0;
417  u32 sa_index0 = ~0;
418  ipsec_main_t *im = &ipsec_main;
420 
421  from = vlib_frame_vector_args (from_frame);
422  n_left_from = from_frame->n_vectors;
423 
424  next_index = node->cached_next_index;
425 
426  while (n_left_from > 0)
427  {
428  u32 n_left_to_next;
429 
430  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
431 
432  while (n_left_from > 0 && n_left_to_next > 0)
433  {
434  esp_footer_t * f0;
435  u32 bi0, iv_size, next0;
436  vlib_buffer_t * b0 = 0;
437  ip4_header_t *ih4 = 0, *oh4 = 0;
438  ip6_header_t *ih6 = 0, *oh6 = 0;
439  crypto_alg_t *cipher_alg, *auth_alg;
440  esp_header_t *esp0;
441  u8 trunc_size, is_aead;
442 
443  next0 = ESP_DECRYPT_NEXT_DROP;
444 
445  bi0 = from[0];
446  from += 1;
447  n_left_from -= 1;
448  n_left_to_next -= 1;
449 
450  b0 = vlib_get_buffer (vm, bi0);
451  esp0 = vlib_buffer_get_current (b0);
452 
453  sa_index0 = vnet_buffer(b0)->ipsec.sad_index;
454  sa0 = pool_elt_at_index (im->sad, sa_index0);
455 
456  to_next[0] = bi0;
457  to_next += 1;
458 
459  cipher_alg = vec_elt_at_index (dcm->cipher_algs, sa0->crypto_alg);
460  auth_alg = vec_elt_at_index (dcm->auth_algs, sa0->integ_alg);
461  is_aead = cipher_alg->type == RTE_CRYPTO_SYM_XFORM_AEAD;
462  if (is_aead)
463  auth_alg = cipher_alg;
464 
465  trunc_size = auth_alg->trunc_size;
466 
467  iv_size = cipher_alg->iv_len;
468 
469  if (sa0->use_anti_replay)
470  {
471  u32 seq;
472  seq = clib_host_to_net_u32(esp0->seq);
473  if (PREDICT_TRUE(sa0->use_esn))
474  esp_replay_advance_esn(sa0, seq);
475  else
476  esp_replay_advance(sa0, seq);
477  }
478 
479  ih4 = (ip4_header_t *) (b0->data + vnet_buffer(b0)->l3_hdr_offset);
480  vlib_buffer_advance (b0, sizeof (esp_header_t) + iv_size);
481 
482  b0->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
483  f0 = (esp_footer_t *) (vlib_buffer_get_tail (b0) - trunc_size - 2);
484  b0->current_length -= (f0->pad_length + trunc_size + 2);
485 #if 0
486  /* check padding */
487  const u8 *padding = vlib_buffer_get_tail (b0);
488  if (PREDICT_FALSE (memcmp (padding, pad_data, f0->pad_length)))
489  {
490  clib_warning("bad padding");
492  ESP_DECRYPT_ERROR_DECRYPTION_FAILED,
493  1);
494  goto trace;
495  }
496 #endif
497  if (sa0->is_tunnel)
498  {
499  if (f0->next_header == IP_PROTOCOL_IP_IN_IP)
500  next0 = ESP_DECRYPT_NEXT_IP4_INPUT;
501  else if (sa0->is_tunnel_ip6 && f0->next_header == IP_PROTOCOL_IPV6)
502  next0 = ESP_DECRYPT_NEXT_IP6_INPUT;
503  else
504  {
505  clib_warning("next header: 0x%x", f0->next_header);
507  ESP_DECRYPT_ERROR_DECRYPTION_FAILED,
508  1);
509  goto trace;
510  }
511  }
512  else /* transport mode */
513  {
514  if ((ih4->ip_version_and_header_length & 0xF0) == 0x40)
515  {
516  u16 ih4_len = ip4_header_bytes (ih4);
517  vlib_buffer_advance (b0, - ih4_len);
518  oh4 = vlib_buffer_get_current (b0);
519  memmove(oh4, ih4, ih4_len);
520 
521  next0 = ESP_DECRYPT_NEXT_IP4_INPUT;
522  oh4->protocol = f0->next_header;
523  oh4->length = clib_host_to_net_u16 (b0->current_length);
524  oh4->checksum = ip4_header_checksum(oh4);
525  }
526  else if ((ih4->ip_version_and_header_length & 0xF0) == 0x60)
527  {
528  ih6 = (ip6_header_t *) ih4;
529  vlib_buffer_advance (b0, -sizeof(ip6_header_t));
530  oh6 = vlib_buffer_get_current (b0);
531  memmove(oh6, ih6, sizeof(ip6_header_t));
532 
533  next0 = ESP_DECRYPT_NEXT_IP6_INPUT;
534  oh6->protocol = f0->next_header;
535  u16 len = b0->current_length - sizeof (ip6_header_t);
536  oh6->payload_length = clib_host_to_net_u16 (len);
537  }
538  else
539  {
540  clib_warning("next header: 0x%x", f0->next_header);
542  ESP_DECRYPT_ERROR_DECRYPTION_FAILED,
543  1);
544  goto trace;
545  }
546  }
547 
548  vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32)~0;
549 
550  trace:
551  if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
552  {
553  esp_decrypt_trace_t *tr = vlib_add_trace (vm, node, b0, sizeof (*tr));
554  tr->crypto_alg = sa0->crypto_alg;
555  tr->integ_alg = sa0->integ_alg;
556  ih4 = vlib_buffer_get_current (b0);
557  clib_memcpy (tr->packet_data, ih4, sizeof (ip6_header_t));
558  }
559 
560  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
561  to_next, n_left_to_next, bi0, next0);
562  }
563  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
564  }
565 
567  ESP_DECRYPT_POST_ERROR_PKTS,
568  from_frame->n_vectors);
569 
570  return from_frame->n_vectors;
571 }
572 
573 /* *INDENT-OFF* */
575  .function = dpdk_esp_decrypt_post_node_fn,
576  .name = "dpdk-esp-decrypt-post",
577  .vector_size = sizeof (u32),
578  .format_trace = format_esp_decrypt_post_trace,
579  .type = VLIB_NODE_TYPE_INTERNAL,
580 
582  .error_strings = esp_decrypt_post_error_strings,
583 
584  .n_next_nodes = ESP_DECRYPT_N_NEXT,
585  .next_nodes = {
586 #define _(s,n) [ESP_DECRYPT_NEXT_##s] = n,
588 #undef _
589  },
590 };
591 /* *INDENT-ON* */
592 
u32 alg
Definition: ipsec.h:77
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:328
static vlib_cli_command_t trace
(constructor) VLIB_CLI_COMMAND (trace)
Definition: vlib_api_cli.c:862
static u8 * vlib_buffer_get_tail(vlib_buffer_t *b)
Get pointer to the end of buffer&#39;s data.
Definition: buffer.h:281
#define CLIB_UNUSED(x)
Definition: clib.h:79
static char * esp_decrypt_post_error_strings[]
Definition: esp_decrypt.c:382
static u8 * format_esp_decrypt_post_trace(u8 *s, va_list *args)
Definition: esp_decrypt.c:390
format_function_t format_ip4_header
Definition: format.h:86
#define PREDICT_TRUE(x)
Definition: clib.h:106
static void esp_replay_advance(ipsec_sa_t *sa, u32 seq)
Definition: esp.h:167
static int ip4_header_bytes(ip4_header_t *i)
Definition: ip4_packet.h:227
#define NULL
Definition: clib.h:55
static_always_inline i32 crypto_alloc_ops(u8 numa, struct rte_crypto_op **ops, u32 n)
Definition: ipsec.h:258
ipsec_integ_alg_t integ_alg
Definition: ipsec.h:121
static_always_inline void crypto_set_icb(dpdk_gcm_cnt_blk *icb, u32 salt, u32 seq, u32 seq_hi)
Definition: ipsec.h:320
ipsec_crypto_alg_t crypto_alg
Definition: esp_decrypt.c:65
u32 padding
Definition: vhost-user.h:77
vlib_node_registration_t dpdk_esp_decrypt_post_node
(constructor) VLIB_REGISTER_NODE (dpdk_esp_decrypt_post_node)
Definition: esp_decrypt.c:388
u8 is_tunnel
Definition: ipsec.h:128
static u32 format_get_indent(u8 *s)
Definition: format.h:72
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
static_always_inline void crypto_enqueue_ops(vlib_main_t *vm, crypto_worker_main_t *cwm, u8 outbound, u32 node_index, u32 error, u8 numa)
Definition: ipsec.h:286
esp_decrypt_next_t
Definition: esp_decrypt.c:32
static char * esp_decrypt_error_strings[]
Definition: esp_decrypt.c:59
u32 bi[VLIB_FRAME_SIZE]
Definition: ipsec.h:118
u32 seq_hi
Definition: ipsec.h:137
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:208
static_always_inline void crypto_free_ops(u8 numa, struct rte_crypto_op **ops, u32 n)
Definition: ipsec.h:274
i16 current_data
signed offset in data[], pre_data[] that we are currently processing.
Definition: buffer.h:104
#define foreach_esp_decrypt_next
Definition: esp_decrypt.c:28
dpdk_crypto_main_t dpdk_crypto_main
Definition: ipsec.c:24
static void esp_replay_advance_esn(ipsec_sa_t *sa, u32 seq)
Definition: esp.h:188
ipsec_main_t ipsec_main
Definition: ipsec.c:28
#define foreach_esp_decrypt_post_error
Definition: esp_decrypt.c:372
u8 * format_white_space(u8 *s, va_list *va)
Definition: std-formats.c:113
u8 use_esn
Definition: ipsec.h:125
#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
crypto_alg_t * auth_algs
Definition: ipsec.h:150
static const u8 pad_data[]
Definition: ipsec.h:159
u8 * format_ipsec_crypto_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:58
u8 trunc_size
Definition: ipsec.h:80
u32 next
Definition: ipsec.h:59
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:91
#define VLIB_NODE_FUNCTION_MULTIARCH(node, fn)
Definition: node.h:158
#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:461
ipsec_integ_alg_t
Definition: ipsec.h:97
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:108
u8 is_tunnel_ip6
Definition: ipsec.h:129
crypto_alg_t * cipher_algs
Definition: ipsec.h:149
static int esp_replay_check_esn(ipsec_sa_t *sa, u32 seq)
Definition: esp.h:123
u32 salt
Definition: ipsec.h:133
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:209
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:411
#define PREDICT_FALSE(x)
Definition: clib.h:105
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
Definition: buffer_node.h:218
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
Definition: node_funcs.h:364
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1166
esp_decrypt_post_error_t
Definition: esp_decrypt.c:375
u8 aad[16]
Definition: ipsec.h:61
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:143
u16 n_vectors
Definition: node.h:344
static_always_inline uword vlib_get_thread_index(void)
Definition: threads.h:221
#define CLIB_PREFETCH(addr, size, type)
Definition: cache.h:74
vlib_main_t * vm
Definition: buffer.c:294
dpdk_gcm_cnt_blk cb
Definition: ipsec.h:60
#define clib_warning(format, args...)
Definition: error.h:59
#define clib_memcpy(a, b, c)
Definition: string.h:75
#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 * format_esp_header(u8 *s, va_list *args)
Definition: esp_format.c:23
u8 iv_len
Definition: ipsec.h:79
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)
static int esp_replay_check(ipsec_sa_t *sa, u32 seq)
Definition: esp.h:105
unsigned int u32
Definition: types.h:88
esp_decrypt_error_t
Definition: esp_decrypt.c:49
u8 icv[32]
Definition: ipsec.h:62
ipsec_sa_t * sad
Definition: ipsec.h:260
ipsec_crypto_alg_t
Definition: ipsec.h:80
crypto_worker_main_t * workers_main
Definition: ipsec.h:145
u64 total_data_size
Definition: ipsec.h:143
u32 seq
Definition: esp.h:28
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:222
format_function_t format_ip6_header
Definition: format.h:98
u8 boundary
Definition: ipsec.h:81
crypto_resource_t * resource
Definition: ipsec.h:148
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
u8 * format_ipsec_integ_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:90
struct _vlib_node_registration vlib_node_registration_t
Definition: defs.h:47
unsigned short u16
Definition: types.h:57
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
struct rte_crypto_op ** ops
Definition: ipsec.h:68
static u8 * format_esp_decrypt_trace(u8 *s, va_list *args)
Definition: esp_decrypt.c:74
enum rte_crypto_sym_xform_type type
Definition: ipsec.h:76
#define vnet_buffer(b)
Definition: buffer.h:372
static_always_inline u16 get_resource(crypto_worker_main_t *cwm, ipsec_sa_t *sa)
Definition: ipsec.h:233
ipsec_crypto_alg_t crypto_alg
Definition: ipsec.h:117
u8 data[0]
Packet data.
Definition: buffer.h:179
u8 ip_version_and_header_length
Definition: ip4_packet.h:132
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
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:111
#define foreach_esp_decrypt_error
Definition: esp_decrypt.c:40
u8 use_anti_replay
Definition: ipsec.h:126
struct rte_crypto_op * ops[VLIB_FRAME_SIZE]
Definition: ipsec.h:117
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
static_always_inline dpdk_op_priv_t * crypto_op_get_priv(struct rte_crypto_op *op)
Definition: ipsec.h:191
vlib_node_registration_t dpdk_esp_decrypt_node
(constructor) VLIB_REGISTER_NODE (dpdk_esp_decrypt_node)
Definition: esp_decrypt.c:65