FD.io VPP  v18.04-17-g3a0d853
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) 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 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 <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_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 to crypto device") \
46  _(DISCARD, "Not enough crypto operations, discarding frame") \
47  _(SESSION, "Failed to get crypto session") \
48  _(NOSUP, "Cipher/Auth not supported")
49 
50 
51 typedef enum
52 {
53 #define _(sym,str) ESP_ENCRYPT_ERROR_##sym,
55 #undef _
58 
59 static char *esp_encrypt_error_strings[] = {
60 #define _(sym,string) string,
62 #undef _
63 };
64 
66 
67 typedef struct
68 {
69  ipsec_crypto_alg_t crypto_alg;
70  ipsec_integ_alg_t integ_alg;
71  u8 packet_data[64];
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 *);
82  u32 indent = format_get_indent (s), offset;
83 
84  s = format (s, "cipher %U auth %U\n",
87 
88  if ((ih4->ip_version_and_header_length & 0xF0) == 0x60)
89  {
90  s = format (s, "%U%U", format_white_space, indent,
91  format_ip6_header, ih4);
92  offset = sizeof (ip6_header_t);
93  }
94  else
95  {
96  s = format (s, "%U%U", format_white_space, indent,
97  format_ip4_header, ih4);
98  offset = ip4_header_bytes (ih4);
99  }
100 
101  s = format (s, "\n%U%U", format_white_space, indent,
103 
104  return s;
105 }
106 
107 static uword
109  vlib_node_runtime_t * node,
110  vlib_frame_t * from_frame)
111 {
112  u32 n_left_from, *from, *to_next, next_index;
113  ipsec_main_t *im = &ipsec_main;
114  u32 thread_idx = vlib_get_thread_index ();
116  crypto_resource_t *res = 0;
117  ipsec_sa_t *sa0 = 0;
118  crypto_alg_t *cipher_alg = 0, *auth_alg = 0;
119  struct rte_cryptodev_sym_session *session = 0;
120  u32 ret, last_sa_index = ~0;
121  u8 numa = rte_socket_id ();
122  u8 is_aead = 0;
123  crypto_worker_main_t *cwm =
124  vec_elt_at_index (dcm->workers_main, thread_idx);
125  struct rte_crypto_op **ops = cwm->ops;
126 
127  from = vlib_frame_vector_args (from_frame);
128  n_left_from = from_frame->n_vectors;
129 
130  ret = crypto_alloc_ops (numa, ops, n_left_from);
131  if (ret)
132  {
134  ESP_ENCRYPT_ERROR_DISCARD, 1);
135  /* Discard whole frame */
136  return n_left_from;
137  }
138 
139  next_index = ESP_ENCRYPT_NEXT_DROP;
140 
141  while (n_left_from > 0)
142  {
143  u32 n_left_to_next;
144 
145  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
146 
147  while (n_left_from > 0 && n_left_to_next > 0)
148  {
149  clib_error_t *error;
150  u32 bi0;
151  vlib_buffer_t *b0 = 0;
152  u32 sa_index0;
153  ip4_and_esp_header_t *ih0, *oh0 = 0;
154  ip6_and_esp_header_t *ih6_0, *oh6_0 = 0;
155  esp_header_t *esp0;
156  esp_footer_t *f0;
157  u8 is_ipv6, next_hdr_type;
158  u32 iv_size;
159  u16 orig_sz;
160  u8 trunc_size;
161  u16 rewrite_len;
162  struct rte_mbuf *mb0 = 0;
163  struct rte_crypto_op *op;
164  u16 res_idx;
165 
166  bi0 = from[0];
167  from += 1;
168  n_left_from -= 1;
169 
170  b0 = vlib_get_buffer (vm, bi0);
171  ih0 = vlib_buffer_get_current (b0);
172  mb0 = rte_mbuf_from_vlib_buffer (b0);
173 
174  /* ih0/ih6_0 */
175  CLIB_PREFETCH (ih0, sizeof (ih6_0[0]), LOAD);
176  /* f0 */
177  CLIB_PREFETCH (vlib_buffer_get_tail (b0), 20, STORE);
178  /* mb0 */
179  CLIB_PREFETCH (mb0, CLIB_CACHE_LINE_BYTES, STORE);
180 
181  op = ops[0];
182  ops += 1;
183  ASSERT (op->status == RTE_CRYPTO_OP_STATUS_NOT_PROCESSED);
184 
185  dpdk_op_priv_t *priv = crypto_op_get_priv (op);
186 
187  u16 op_len =
188  sizeof (op[0]) + sizeof (op[0].sym[0]) + sizeof (priv[0]);
189  CLIB_PREFETCH (op, op_len, STORE);
190 
191  sa_index0 = vnet_buffer (b0)->ipsec.sad_index;
192 
193  if (sa_index0 != last_sa_index)
194  {
195  sa0 = pool_elt_at_index (im->sad, sa_index0);
196 
197  cipher_alg =
199  auth_alg = vec_elt_at_index (dcm->auth_algs, sa0->integ_alg);
200 
201  is_aead = (cipher_alg->type == RTE_CRYPTO_SYM_XFORM_AEAD);
202 
203  if (is_aead)
204  auth_alg = cipher_alg;
205 
206  res_idx = get_resource (cwm, sa0);
207 
208  if (PREDICT_FALSE (res_idx == (u16) ~ 0))
209  {
210  clib_warning ("unsupported SA by thread index %u",
211  thread_idx);
213  dpdk_esp_encrypt_node.index,
214  ESP_ENCRYPT_ERROR_NOSUP, 1);
215  to_next[0] = bi0;
216  to_next += 1;
217  n_left_to_next -= 1;
218  goto trace;
219  }
220  res = vec_elt_at_index (dcm->resource, res_idx);
221 
222  error = crypto_get_session (&session, sa_index0, res, cwm, 1);
223  if (PREDICT_FALSE (error || !session))
224  {
225  clib_warning ("failed to get crypto session");
227  dpdk_esp_encrypt_node.index,
228  ESP_ENCRYPT_ERROR_SESSION, 1);
229  to_next[0] = bi0;
230  to_next += 1;
231  n_left_to_next -= 1;
232  goto trace;
233  }
234 
235  last_sa_index = sa_index0;
236  }
237 
238  if (PREDICT_FALSE (esp_seq_advance (sa0)))
239  {
240  clib_warning ("sequence number counter has cycled SPI %u",
241  sa0->spi);
243  ESP_ENCRYPT_ERROR_SEQ_CYCLED, 1);
244  //TODO: rekey SA
245  to_next[0] = bi0;
246  to_next += 1;
247  n_left_to_next -= 1;
248  goto trace;
249  }
250 
251  orig_sz = b0->current_length;
252 
253  /* TODO multi-seg support - total_length_not_including_first_buffer */
254  sa0->total_data_size += b0->current_length;
255 
256  res->ops[res->n_ops] = op;
257  res->bi[res->n_ops] = bi0;
258  res->n_ops += 1;
259 
260  dpdk_gcm_cnt_blk *icb = &priv->cb;
261 
262  crypto_set_icb (icb, sa0->salt, sa0->seq, sa0->seq_hi);
263 
264  is_ipv6 = (ih0->ip4.ip_version_and_header_length & 0xF0) == 0x60;
265 
266  iv_size = cipher_alg->iv_len;
267  trunc_size = auth_alg->trunc_size;
268 
269  if (sa0->is_tunnel)
270  {
271  rewrite_len = 0;
272  if (!is_ipv6 && !sa0->is_tunnel_ip6) /* ip4inip4 */
273  {
274  /* in tunnel mode send it back to FIB */
275  priv->next = DPDK_CRYPTO_INPUT_NEXT_IP4_LOOKUP;
276  u8 adv =
277  sizeof (ip4_header_t) + sizeof (esp_header_t) + iv_size;
278  vlib_buffer_advance (b0, -adv);
279  oh0 = vlib_buffer_get_current (b0);
280  next_hdr_type = IP_PROTOCOL_IP_IN_IP;
281  /*
282  * oh0->ip4.ip_version_and_header_length = 0x45;
283  * oh0->ip4.tos = ih0->ip4.tos;
284  * oh0->ip4.fragment_id = 0;
285  * oh0->ip4.flags_and_fragment_offset = 0;
286  */
287  oh0->ip4.checksum_data_64[0] =
288  clib_host_to_net_u64 (0x45ULL << 56);
289  /*
290  * oh0->ip4.ttl = 254;
291  * oh0->ip4.protocol = IP_PROTOCOL_IPSEC_ESP;
292  */
293  oh0->ip4.checksum_data_32[2] =
294  clib_host_to_net_u32 (0xfe320000);
295 
296  oh0->ip4.src_address.as_u32 =
297  sa0->tunnel_src_addr.ip4.as_u32;
298  oh0->ip4.dst_address.as_u32 =
299  sa0->tunnel_dst_addr.ip4.as_u32;
300  esp0 = &oh0->esp;
301  oh0->esp.spi = clib_host_to_net_u32 (sa0->spi);
302  oh0->esp.seq = clib_host_to_net_u32 (sa0->seq);
303  }
304  else if (is_ipv6 && sa0->is_tunnel_ip6) /* ip6inip6 */
305  {
306  /* in tunnel mode send it back to FIB */
307  priv->next = DPDK_CRYPTO_INPUT_NEXT_IP6_LOOKUP;
308 
309  u8 adv =
310  sizeof (ip6_header_t) + sizeof (esp_header_t) + iv_size;
311  vlib_buffer_advance (b0, -adv);
312  ih6_0 = (ip6_and_esp_header_t *) ih0;
313  oh6_0 = vlib_buffer_get_current (b0);
314 
315  next_hdr_type = IP_PROTOCOL_IPV6;
316 
317  oh6_0->ip6.ip_version_traffic_class_and_flow_label =
318  ih6_0->ip6.ip_version_traffic_class_and_flow_label;
319 
320  oh6_0->ip6.protocol = IP_PROTOCOL_IPSEC_ESP;
321  oh6_0->ip6.hop_limit = 254;
322  oh6_0->ip6.src_address.as_u64[0] =
323  sa0->tunnel_src_addr.ip6.as_u64[0];
324  oh6_0->ip6.src_address.as_u64[1] =
325  sa0->tunnel_src_addr.ip6.as_u64[1];
326  oh6_0->ip6.dst_address.as_u64[0] =
327  sa0->tunnel_dst_addr.ip6.as_u64[0];
328  oh6_0->ip6.dst_address.as_u64[1] =
329  sa0->tunnel_dst_addr.ip6.as_u64[1];
330  esp0 = &oh6_0->esp;
331  oh6_0->esp.spi = clib_host_to_net_u32 (sa0->spi);
332  oh6_0->esp.seq = clib_host_to_net_u32 (sa0->seq);
333  }
334  else /* unsupported ip4inip6, ip6inip4 */
335  {
337  dpdk_esp_encrypt_node.index,
338  ESP_ENCRYPT_ERROR_NOSUP, 1);
339  to_next[0] = bi0;
340  to_next += 1;
341  n_left_to_next -= 1;
342  goto trace;
343  }
344  vnet_buffer (b0)->sw_if_index[VLIB_TX] = (u32) ~ 0;
345  }
346  else /* transport mode */
347  {
348  priv->next = DPDK_CRYPTO_INPUT_NEXT_INTERFACE_OUTPUT;
349  rewrite_len = vnet_buffer (b0)->ip.save_rewrite_length;
350  u16 adv = sizeof (esp_header_t) + iv_size;
351  vlib_buffer_advance (b0, -adv - rewrite_len);
352  u8 *src = ((u8 *) ih0) - rewrite_len;
353  u8 *dst = vlib_buffer_get_current (b0);
354  oh0 = vlib_buffer_get_current (b0) + rewrite_len;
355 
356  if (is_ipv6)
357  {
358  orig_sz -= sizeof (ip6_header_t);
359  ih6_0 = (ip6_and_esp_header_t *) ih0;
360  next_hdr_type = ih6_0->ip6.protocol;
361  memmove (dst, src, rewrite_len + sizeof (ip6_header_t));
362  oh6_0 = (ip6_and_esp_header_t *) oh0;
363  oh6_0->ip6.protocol = IP_PROTOCOL_IPSEC_ESP;
364  esp0 = &oh6_0->esp;
365  }
366  else /* ipv4 */
367  {
368  u16 ip_size = ip4_header_bytes (&ih0->ip4);
369  orig_sz -= ip_size;
370  next_hdr_type = ih0->ip4.protocol;
371  memmove (dst, src, rewrite_len + ip_size);
372  oh0->ip4.protocol = IP_PROTOCOL_IPSEC_ESP;
373  esp0 = (esp_header_t *) (((u8 *) oh0) + ip_size);
374  }
375  esp0->spi = clib_host_to_net_u32 (sa0->spi);
376  esp0->seq = clib_host_to_net_u32 (sa0->seq);
377  }
378 
379  ASSERT (is_pow2 (cipher_alg->boundary));
380  u16 mask = cipher_alg->boundary - 1;
381  u16 pad_payload_len = ((orig_sz + 2) + mask) & ~mask;
382  u8 pad_bytes = pad_payload_len - 2 - orig_sz;
383 
384  u8 *padding =
385  vlib_buffer_put_uninit (b0, pad_bytes + 2 + trunc_size);
386 
387  /* The extra pad bytes would be overwritten by the digest */
388  if (pad_bytes)
389  clib_memcpy (padding, pad_data, 16);
390 
391  f0 = (esp_footer_t *) (padding + pad_bytes);
392  f0->pad_length = pad_bytes;
393  f0->next_header = next_hdr_type;
394 
395  if (is_ipv6)
396  {
397  u16 len = b0->current_length - sizeof (ip6_header_t);
398  oh6_0->ip6.payload_length =
399  clib_host_to_net_u16 (len - rewrite_len);
400  }
401  else
402  {
403  oh0->ip4.length =
404  clib_host_to_net_u16 (b0->current_length - rewrite_len);
405  oh0->ip4.checksum = ip4_header_checksum (&oh0->ip4);
406  }
407 
408  vnet_buffer (b0)->sw_if_index[VLIB_RX] =
409  vnet_buffer (b0)->sw_if_index[VLIB_RX];
410  b0->flags |= VLIB_BUFFER_TOTAL_LENGTH_VALID;
411 
412  /* mbuf packet starts at ESP header */
413  mb0->data_len = vlib_buffer_get_tail (b0) - ((u8 *) esp0);
414  mb0->pkt_len = vlib_buffer_get_tail (b0) - ((u8 *) esp0);
415  mb0->data_off = ((void *) esp0) - mb0->buf_addr;
416 
417  u32 cipher_off, cipher_len, auth_len = 0;
418  u32 *aad = NULL;
419 
420  u8 *digest = vlib_buffer_get_tail (b0) - trunc_size;
421  u64 digest_paddr =
422  mb0->buf_physaddr + digest - ((u8 *) mb0->buf_addr);
423 
424  if (!is_aead && cipher_alg->alg == RTE_CRYPTO_CIPHER_AES_CBC)
425  {
426  cipher_off = sizeof (esp_header_t);
427  cipher_len = iv_size + pad_payload_len;
428  }
429  else /* CTR/GCM */
430  {
431  u32 *esp_iv = (u32 *) (esp0 + 1);
432  esp_iv[0] = sa0->seq;
433  esp_iv[1] = sa0->seq_hi;
434 
435  cipher_off = sizeof (esp_header_t) + iv_size;
436  cipher_len = pad_payload_len;
437  }
438 
439  if (is_aead)
440  {
441  aad = (u32 *) priv->aad;
442  aad[0] = clib_host_to_net_u32 (sa0->spi);
443  aad[1] = clib_host_to_net_u32 (sa0->seq);
444 
445  /* aad[3] should always be 0 */
446  if (PREDICT_FALSE (sa0->use_esn))
447  aad[2] = clib_host_to_net_u32 (sa0->seq_hi);
448  else
449  aad[2] = 0;
450  }
451  else
452  {
453  auth_len =
454  vlib_buffer_get_tail (b0) - ((u8 *) esp0) - trunc_size;
455  if (sa0->use_esn)
456  {
457  u32 *_digest = (u32 *) digest;
458  _digest[0] = clib_host_to_net_u32 (sa0->seq_hi);
459  auth_len += 4;
460  }
461  }
462 
463  crypto_op_setup (is_aead, mb0, op, session, cipher_off, cipher_len,
464  0, auth_len, (u8 *) aad, digest, digest_paddr);
465 
466  trace:
467  if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
468  {
469  esp_encrypt_trace_t *tr =
470  vlib_add_trace (vm, node, b0, sizeof (*tr));
471  tr->crypto_alg = sa0->crypto_alg;
472  tr->integ_alg = sa0->integ_alg;
473  u8 *p = vlib_buffer_get_current (b0);
474  if (!sa0->is_tunnel)
475  p += vnet_buffer (b0)->ip.save_rewrite_length;
476  clib_memcpy (tr->packet_data, p, sizeof (tr->packet_data));
477  }
478  }
479  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
480  }
482  ESP_ENCRYPT_ERROR_RX_PKTS,
483  from_frame->n_vectors);
484 
485  crypto_enqueue_ops (vm, cwm, 1, dpdk_esp_encrypt_node.index,
486  ESP_ENCRYPT_ERROR_ENQ_FAIL, numa);
487 
488  crypto_free_ops (numa, ops, cwm->ops + from_frame->n_vectors - ops);
489 
490  return from_frame->n_vectors;
491 }
492 
493 /* *INDENT-OFF* */
495  .function = dpdk_esp_encrypt_node_fn,
496  .name = "dpdk-esp-encrypt",
497  .flags = VLIB_NODE_FLAG_IS_OUTPUT,
498  .vector_size = sizeof (u32),
499  .format_trace = format_esp_encrypt_trace,
500  .n_errors = ARRAY_LEN (esp_encrypt_error_strings),
501  .error_strings = esp_encrypt_error_strings,
502  .n_next_nodes = 1,
503  .next_nodes =
504  {
505  [ESP_ENCRYPT_NEXT_DROP] = "error-drop",
506  }
507 };
508 /* *INDENT-ON* */
509 
511 /*
512  * fd.io coding-style-patch-verification: ON
513  *
514  * Local Variables:
515  * eval: (c-set-style "gnu")
516  * End:
517  */
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
ip46_address_t tunnel_src_addr
Definition: ipsec.h:130
format_function_t format_ip4_header
Definition: format.h:86
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 u8 * format_esp_encrypt_trace(u8 *s, va_list *args)
Definition: esp_encrypt.c:76
static_always_inline void crypto_set_icb(dpdk_gcm_cnt_blk *icb, u32 salt, u32 seq, u32 seq_hi)
Definition: ipsec.h:320
u32 padding
Definition: vhost-user.h:77
u8 is_tunnel
Definition: ipsec.h:128
ipsec_integ_alg_t integ_alg
Definition: esp_encrypt.c:69
static u32 format_get_indent(u8 *s)
Definition: format.h:72
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
ipsec_crypto_alg_t crypto_alg
Definition: esp_encrypt.c:68
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
u32 spi
Definition: ipsec.h:114
u32 bi[VLIB_FRAME_SIZE]
Definition: ipsec.h:118
u32 seq_hi
Definition: ipsec.h:137
static int esp_seq_advance(ipsec_sa_t *sa)
Definition: esp.h:225
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
dpdk_crypto_main_t dpdk_crypto_main
Definition: ipsec.c:24
ipsec_main_t ipsec_main
Definition: ipsec.c:28
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.
vlib_node_registration_t dpdk_esp_encrypt_node
(constructor) VLIB_REGISTER_NODE (dpdk_esp_encrypt_node)
Definition: esp_encrypt.c:65
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
u32 next
Definition: ipsec.h:59
esp_encrypt_error_t
Definition: esp_encrypt.c:48
#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
static void * vlib_buffer_put_uninit(vlib_buffer_t *b, u8 size)
Append uninitialized data to buffer.
Definition: buffer.h:292
crypto_alg_t * cipher_algs
Definition: ipsec.h:149
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
#define PREDICT_FALSE(x)
Definition: clib.h:105
#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
ip46_address_t tunnel_dst_addr
Definition: ipsec.h:131
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 foreach_esp_encrypt_error
Definition: esp_encrypt.c:42
#define clib_warning(format, args...)
Definition: error.h:59
#define clib_memcpy(a, b, c)
Definition: string.h:75
static char * esp_encrypt_error_strings[]
Definition: esp_encrypt.c:59
#define ARRAY_LEN(x)
Definition: clib.h:59
esp_encrypt_next_t
Definition: esp_encrypt.c:34
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
#define ASSERT(truth)
unsigned int u32
Definition: types.h:88
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
u32 spi
Definition: esp.h:27
u8 boundary
Definition: ipsec.h:81
crypto_resource_t * resource
Definition: ipsec.h:148
static uword is_pow2(uword x)
Definition: clib.h:280
u32 seq
Definition: ipsec.h:136
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
template key/value backing page structure
Definition: bihash_doc.h:44
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
struct clib_bihash_value offset
template key/value backing page structure
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
#define VLIB_NODE_FLAG_IS_OUTPUT
Definition: node.h:253
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:108
#define foreach_esp_encrypt_next
Definition: esp_encrypt.c:28
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
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
Definition: defs.h:46
static_always_inline dpdk_op_priv_t * crypto_op_get_priv(struct rte_crypto_op *op)
Definition: ipsec.h:191