FD.io VPP  v21.06
Vector Packet Processing
ipsec.c
Go to the documentation of this file.
1 /*
2  * ipsec.c : IPSEC module functions
3  *
4  * Copyright (c) 2015 Cisco 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 #include <vnet/interface.h>
22 #include <vnet/udp/udp_local.h>
23 
24 #include <vnet/ipsec/ipsec.h>
25 #include <vnet/ipsec/esp.h>
26 #include <vnet/ipsec/ah.h>
27 
31 
32 static clib_error_t *
34 {
36 
37  if (sa->integ_alg == IPSEC_INTEG_ALG_NONE)
38  return clib_error_return (0, "unsupported none integ-alg");
39 
41  return clib_error_return (0, "No crypto engine support for %U",
43 
44  return 0;
45 }
46 
47 static clib_error_t *
49 {
51 
52  if (IPSEC_INTEG_ALG_NONE != sa->integ_alg)
53  {
55  return clib_error_return (0, "No crypto engine support for %U",
57  }
58  if (IPSEC_CRYPTO_ALG_NONE != sa->crypto_alg)
59  {
61  return clib_error_return (0, "No crypto engine support for %U",
63  }
64 
65  return (0);
66 }
67 
70 {
71  ipsec_ah_backend_t *ah =
73  if (ah->add_del_sa_sess_cb)
74  {
75  clib_error_t *err = ah->add_del_sa_sess_cb (sa_index, is_add);
76  if (err)
77  return err;
78  }
79  ipsec_esp_backend_t *esp =
81  if (esp->add_del_sa_sess_cb)
82  {
83  clib_error_t *err = esp->add_del_sa_sess_cb (sa_index, is_add);
84  if (err)
85  return err;
86  }
87  return 0;
88 }
89 
92 {
93  clib_error_t *error = 0;
94 
96  {
97  ipsec_ah_backend_t *ah =
100  error = ah->check_support_cb (sa);
101  }
102  else
103  {
104  ipsec_esp_backend_t *esp =
106  ASSERT (esp->check_support_cb);
107  error = esp->check_support_cb (sa);
108  }
109  return error;
110 }
111 
112 
113 static void
114 ipsec_add_node (vlib_main_t * vm, const char *node_name,
115  const char *prev_node_name, u32 * out_node_index,
116  u32 * out_next_index)
117 {
118  vlib_node_t *prev_node, *node;
119  prev_node = vlib_get_node_by_name (vm, (u8 *) prev_node_name);
120  ASSERT (prev_node);
121  node = vlib_get_node_by_name (vm, (u8 *) node_name);
122  ASSERT (node);
123  *out_node_index = node->index;
124  *out_next_index = vlib_node_add_next (vm, prev_node->index, node->index);
125 }
126 
127 void
129 {
131  u32 n_regs;
132  uword *p;
133 
134  p = hash_get (im->udp_port_registrations, port);
135 
136  ASSERT (p);
137 
138  n_regs = p[0];
139 
140  if (0 == --n_regs)
141  {
144  }
145  else
146  {
148  hash_set (im->udp_port_registrations, port, n_regs);
149  }
150 }
151 
152 void
154 {
156  u32 n_regs;
157  uword *p;
158 
159  p = hash_get (im->udp_port_registrations, port);
160 
161  n_regs = (p ? p[0] : 0);
162 
163  if (0 == n_regs++)
165  ipsec4_tun_input_node.index, 1);
166 
168  hash_set (im->udp_port_registrations, port, n_regs);
169 }
170 
171 u32
173  const char *name,
174  const char *ah4_encrypt_node_name,
175  const char *ah4_decrypt_node_name,
176  const char *ah6_encrypt_node_name,
177  const char *ah6_decrypt_node_name,
178  check_support_cb_t ah_check_support_cb,
179  add_del_sa_sess_cb_t ah_add_del_sa_sess_cb)
180 {
182  pool_get (im->ah_backends, b);
183  b->name = format (0, "%s%c", name, 0);
184 
185  ipsec_add_node (vm, ah4_encrypt_node_name, "ipsec4-output-feature",
187  ipsec_add_node (vm, ah4_decrypt_node_name, "ipsec4-input-feature",
189  ipsec_add_node (vm, ah6_encrypt_node_name, "ipsec6-output-feature",
191  ipsec_add_node (vm, ah6_decrypt_node_name, "ipsec6-input-feature",
193 
194  b->check_support_cb = ah_check_support_cb;
195  b->add_del_sa_sess_cb = ah_add_del_sa_sess_cb;
196  return b - im->ah_backends;
197 }
198 
199 u32
201  vlib_main_t *vm, ipsec_main_t *im, const char *name,
202  const char *esp4_encrypt_node_name, const char *esp4_encrypt_node_tun_name,
203  const char *esp4_decrypt_node_name, const char *esp4_decrypt_tun_node_name,
204  const char *esp6_encrypt_node_name, const char *esp6_encrypt_node_tun_name,
205  const char *esp6_decrypt_node_name, const char *esp6_decrypt_tun_node_name,
206  const char *esp_mpls_encrypt_node_tun_name,
207  check_support_cb_t esp_check_support_cb,
208  add_del_sa_sess_cb_t esp_add_del_sa_sess_cb,
209  enable_disable_cb_t enable_disable_cb)
210 {
212 
213  pool_get (im->esp_backends, b);
214  b->name = format (0, "%s%c", name, 0);
215 
216  ipsec_add_node (vm, esp4_encrypt_node_name, "ipsec4-output-feature",
218  ipsec_add_node (vm, esp4_decrypt_node_name, "ipsec4-input-feature",
220  ipsec_add_node (vm, esp6_encrypt_node_name, "ipsec6-output-feature",
222  ipsec_add_node (vm, esp6_decrypt_node_name, "ipsec6-input-feature",
224  ipsec_add_node (vm, esp4_decrypt_tun_node_name, "ipsec4-tun-input",
227  ipsec_add_node (vm, esp6_decrypt_tun_node_name, "ipsec6-tun-input",
230 
232  vlib_get_node_by_name (vm, (u8 *) esp6_encrypt_node_tun_name)->index;
234  vlib_get_node_by_name (vm, (u8 *) esp_mpls_encrypt_node_tun_name)->index;
236  vlib_get_node_by_name (vm, (u8 *) esp4_encrypt_node_tun_name)->index;
237 
238  b->check_support_cb = esp_check_support_cb;
239  b->add_del_sa_sess_cb = esp_add_del_sa_sess_cb;
240  b->enable_disable_cb = enable_disable_cb;
241 
242  return b - im->esp_backends;
243 }
244 
245 clib_error_t *
247 {
248  /* return an error is crypto resource are in use */
249  if (pool_elts (ipsec_sa_pool) > 0)
250  return clib_error_return (0, "%d SA entries configured",
252 
253  return (NULL);
254 }
255 
256 int
258 {
259  if (ipsec_rsc_in_use (im))
260  return VNET_API_ERROR_RSRC_IN_USE;
261 
262  if (pool_is_free_index (im->ah_backends, backend_idx))
263  return VNET_API_ERROR_INVALID_VALUE;
264 
265  ipsec_ah_backend_t *b = pool_elt_at_index (im->ah_backends, backend_idx);
266  im->ah_current_backend = backend_idx;
275 
276  return 0;
277 }
278 
279 int
281 {
282  if (ipsec_rsc_in_use (im))
283  return VNET_API_ERROR_RSRC_IN_USE;
284 
285  if (pool_is_free_index (im->esp_backends, backend_idx))
286  return VNET_API_ERROR_INVALID_VALUE;
287 
288  /* disable current backend */
289  if (im->esp_current_backend != ~0)
290  {
292  im->esp_current_backend);
293  if (cb->enable_disable_cb)
294  {
295  if ((cb->enable_disable_cb) (0) != 0)
296  return -1;
297  }
298  }
299 
300  ipsec_esp_backend_t *b = pool_elt_at_index (im->esp_backends, backend_idx);
301  im->esp_current_backend = backend_idx;
317 
318  if (b->enable_disable_cb)
319  {
320  if ((b->enable_disable_cb) (1) != 0)
321  return -1;
322  }
323  return 0;
324 }
325 
326 void
328 {
330  ipsec_sa_t *sa;
331 
332  vnet_crypto_request_async_mode (is_enabled);
333 
334  im->async_mode = is_enabled;
335 
336  /* change SA crypto op data */
338  {
339  sa->crypto_op_data =
340  (is_enabled ? sa->async_op_data.data : sa->sync_op_data.data);
341  }
342 }
343 
344 static void
346 {
349 
350  eit = &esp_encrypt_async_next;
351  eit->esp4_post_next =
352  vnet_crypto_register_post_node (vm, "esp4-encrypt-post");
353  eit->esp6_post_next =
354  vnet_crypto_register_post_node (vm, "esp6-encrypt-post");
355  eit->esp4_tun_post_next =
356  vnet_crypto_register_post_node (vm, "esp4-encrypt-tun-post");
357  eit->esp6_tun_post_next =
358  vnet_crypto_register_post_node (vm, "esp6-encrypt-tun-post");
360  vnet_crypto_register_post_node (vm, "esp-mpls-encrypt-tun-post");
361 
362  dit = &esp_decrypt_async_next;
363  dit->esp4_post_next =
364  vnet_crypto_register_post_node (vm, "esp4-decrypt-post");
365  dit->esp6_post_next =
366  vnet_crypto_register_post_node (vm, "esp6-decrypt-post");
367  dit->esp4_tun_post_next =
368  vnet_crypto_register_post_node (vm, "esp4-decrypt-tun-post");
369  dit->esp6_tun_post_next =
370  vnet_crypto_register_post_node (vm, "esp6-decrypt-tun-post");
371 }
372 
373 static clib_error_t *
375 {
379 
380  /* Backend registration requires the feature arcs to be set up */
381  if ((error = vlib_call_init_function (vm, vnet_feature_init)))
382  return (error);
383 
384  im->vnet_main = vnet_get_main ();
385  im->vlib_main = vm;
386 
387  im->spd_index_by_spd_id = hash_create (0, sizeof (uword));
388  im->sa_index_by_sa_id = hash_create (0, sizeof (uword));
389  im->spd_index_by_sw_if_index = hash_create (0, sizeof (uword));
390 
391  vlib_node_t *node = vlib_get_node_by_name (vm, (u8 *) "error-drop");
392  ASSERT (node);
393  im->error_drop_node_index = node->index;
394 
395  im->ah_current_backend = ~0;
396  im->esp_current_backend = ~0;
397 
398  u32 idx = ipsec_register_ah_backend (vm, im, "crypto engine backend",
399  "ah4-encrypt",
400  "ah4-decrypt",
401  "ah6-encrypt",
402  "ah6-decrypt",
404  NULL);
405 
406  im->ah_default_backend = idx;
407  int rv = ipsec_select_ah_backend (im, idx);
408  ASSERT (0 == rv);
409  (void) (rv); // avoid warning
410 
412  vm, im, "crypto engine backend", "esp4-encrypt", "esp4-encrypt-tun",
413  "esp4-decrypt", "esp4-decrypt-tun", "esp6-encrypt", "esp6-encrypt-tun",
414  "esp6-decrypt", "esp6-decrypt-tun", "esp-mpls-encrypt-tun",
416  im->esp_default_backend = idx;
417 
418  rv = ipsec_select_esp_backend (im, idx);
419  ASSERT (0 == rv);
420  (void) (rv); // avoid warning
421 
422  if ((error = vlib_call_init_function (vm, ipsec_cli_init)))
423  return error;
424 
426 
427  a = im->crypto_algs + IPSEC_CRYPTO_ALG_NONE;
431  a->iv_size = 0;
432  a->block_align = 1;
433 
434  a = im->crypto_algs + IPSEC_CRYPTO_ALG_DES_CBC;
435  a->enc_op_id = VNET_CRYPTO_OP_DES_CBC_ENC;
436  a->dec_op_id = VNET_CRYPTO_OP_DES_CBC_DEC;
437  a->alg = VNET_CRYPTO_ALG_DES_CBC;
438  a->iv_size = a->block_align = 8;
439 
440  a = im->crypto_algs + IPSEC_CRYPTO_ALG_3DES_CBC;
441  a->enc_op_id = VNET_CRYPTO_OP_3DES_CBC_ENC;
442  a->dec_op_id = VNET_CRYPTO_OP_3DES_CBC_DEC;
443  a->alg = VNET_CRYPTO_ALG_3DES_CBC;
444  a->iv_size = a->block_align = 8;
445 
446  a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CBC_128;
447  a->enc_op_id = VNET_CRYPTO_OP_AES_128_CBC_ENC;
448  a->dec_op_id = VNET_CRYPTO_OP_AES_128_CBC_DEC;
449  a->alg = VNET_CRYPTO_ALG_AES_128_CBC;
450  a->iv_size = a->block_align = 16;
451 
452  a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CBC_192;
453  a->enc_op_id = VNET_CRYPTO_OP_AES_192_CBC_ENC;
454  a->dec_op_id = VNET_CRYPTO_OP_AES_192_CBC_DEC;
455  a->alg = VNET_CRYPTO_ALG_AES_192_CBC;
456  a->iv_size = a->block_align = 16;
457 
458  a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CBC_256;
459  a->enc_op_id = VNET_CRYPTO_OP_AES_256_CBC_ENC;
460  a->dec_op_id = VNET_CRYPTO_OP_AES_256_CBC_DEC;
461  a->alg = VNET_CRYPTO_ALG_AES_256_CBC;
462  a->iv_size = a->block_align = 16;
463 
464  a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CTR_128;
465  a->enc_op_id = VNET_CRYPTO_OP_AES_128_CTR_ENC;
466  a->dec_op_id = VNET_CRYPTO_OP_AES_128_CTR_DEC;
467  a->alg = VNET_CRYPTO_ALG_AES_128_CTR;
468  a->iv_size = 8;
469  a->block_align = 1;
470 
471  a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CTR_192;
472  a->enc_op_id = VNET_CRYPTO_OP_AES_192_CTR_ENC;
473  a->dec_op_id = VNET_CRYPTO_OP_AES_192_CTR_DEC;
474  a->alg = VNET_CRYPTO_ALG_AES_192_CTR;
475  a->iv_size = 8;
476  a->block_align = 1;
477 
478  a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CTR_256;
479  a->enc_op_id = VNET_CRYPTO_OP_AES_256_CTR_ENC;
480  a->dec_op_id = VNET_CRYPTO_OP_AES_256_CTR_DEC;
481  a->alg = VNET_CRYPTO_ALG_AES_256_CTR;
482  a->iv_size = 8;
483  a->block_align = 1;
484 
485  a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_GCM_128;
486  a->enc_op_id = VNET_CRYPTO_OP_AES_128_GCM_ENC;
487  a->dec_op_id = VNET_CRYPTO_OP_AES_128_GCM_DEC;
488  a->alg = VNET_CRYPTO_ALG_AES_128_GCM;
489  a->iv_size = 8;
490  a->block_align = 1;
491  a->icv_size = 16;
492 
493  a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_GCM_192;
494  a->enc_op_id = VNET_CRYPTO_OP_AES_192_GCM_ENC;
495  a->dec_op_id = VNET_CRYPTO_OP_AES_192_GCM_DEC;
496  a->alg = VNET_CRYPTO_ALG_AES_192_GCM;
497  a->iv_size = 8;
498  a->block_align = 1;
499  a->icv_size = 16;
500 
501  a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_GCM_256;
502  a->enc_op_id = VNET_CRYPTO_OP_AES_256_GCM_ENC;
503  a->dec_op_id = VNET_CRYPTO_OP_AES_256_GCM_DEC;
504  a->alg = VNET_CRYPTO_ALG_AES_256_GCM;
505  a->iv_size = 8;
506  a->block_align = 1;
507  a->icv_size = 16;
508 
511 
512  i = &im->integ_algs[IPSEC_INTEG_ALG_MD5_96];
513  i->op_id = VNET_CRYPTO_OP_MD5_HMAC;
514  i->alg = VNET_CRYPTO_ALG_HMAC_MD5;
515  i->icv_size = 12;
516 
517  i = &im->integ_algs[IPSEC_INTEG_ALG_SHA1_96];
518  i->op_id = VNET_CRYPTO_OP_SHA1_HMAC;
519  i->alg = VNET_CRYPTO_ALG_HMAC_SHA1;
520  i->icv_size = 12;
521 
522  i = &im->integ_algs[IPSEC_INTEG_ALG_SHA_256_96];
523  i->op_id = VNET_CRYPTO_OP_SHA1_HMAC;
524  i->alg = VNET_CRYPTO_ALG_HMAC_SHA256;
525  i->icv_size = 12;
526 
527  i = &im->integ_algs[IPSEC_INTEG_ALG_SHA_256_128];
528  i->op_id = VNET_CRYPTO_OP_SHA256_HMAC;
529  i->alg = VNET_CRYPTO_ALG_HMAC_SHA256;
530  i->icv_size = 16;
531 
532  i = &im->integ_algs[IPSEC_INTEG_ALG_SHA_384_192];
533  i->op_id = VNET_CRYPTO_OP_SHA384_HMAC;
534  i->alg = VNET_CRYPTO_ALG_HMAC_SHA384;
535  i->icv_size = 24;
536 
537  i = &im->integ_algs[IPSEC_INTEG_ALG_SHA_512_256];
538  i->op_id = VNET_CRYPTO_OP_SHA512_HMAC;
539  i->alg = VNET_CRYPTO_ALG_HMAC_SHA512;
540  i->icv_size = 32;
541 
543 
544  im->async_mode = 0;
546 
547  return 0;
548 }
549 
551 
552 /*
553  * fd.io coding-style-patch-verification: ON
554  *
555  * Local Variables:
556  * eval: (c-set-style "gnu")
557  * End:
558  */
void udp_unregister_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u8 is_ip4)
Definition: udp_local.c:506
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Definition: vec.h:524
u32 esp_mpls_encrypt_tun_node_index
Definition: ipsec.h:77
u32 esp4_decrypt_tun_node_index
Definition: ipsec.h:140
u8 * format_ipsec_integ_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:111
#define hash_set(h, key, value)
Definition: hash.h:255
u32 esp_default_backend
Definition: ipsec.h:182
u32 esp4_encrypt_next_index
Definition: ipsec.h:65
ipsec_main_crypto_alg_t * crypto_algs
Definition: ipsec.h:185
static void crypto_engine_backend_register_post_node(vlib_main_t *vm)
Definition: ipsec.c:345
void ipsec_register_udp_port(u16 port)
Definition: ipsec.c:153
ipsec_per_thread_data_t * ptd
Definition: ipsec.h:191
u32 esp6_decrypt_node_index
Definition: ipsec.h:145
#define hash_unset(h, key)
Definition: hash.h:261
enable_disable_cb_t enable_disable_cb
Definition: ipsec.h:62
u32 ah4_decrypt_next_index
Definition: ipsec.h:156
a
Definition: bitmap.h:544
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
u32 esp6_encrypt_tun_node_index
Definition: ipsec.h:76
u32 index
Definition: node.h:270
u32 esp4_decrypt_node_index
Definition: ipsec.h:64
static clib_error_t * ipsec_init(vlib_main_t *vm)
Definition: ipsec.c:374
esp_async_post_next_t esp_decrypt_async_next
Definition: ipsec.c:30
u32 esp6_post_next
Definition: esp.h:243
ipsec_integ_alg_t integ_alg
Definition: ipsec_sa.h:218
u32 ah6_decrypt_next_index
Definition: ipsec.h:51
u32 esp6_decrypt_tun_node_index
Definition: ipsec.h:146
void vnet_crypto_request_async_mode(int is_enable)
Definition: crypto.c:571
u32 esp6_decrypt_next_index
Definition: ipsec.h:70
u32 ah4_encrypt_next_index
Definition: ipsec.h:155
Definition: esp.h:239
u32 ah4_encrypt_node_index
Definition: ipsec.h:44
u32 esp6_encrypt_node_index
Definition: ipsec.h:67
void udp_register_dst_port(vlib_main_t *vm, udp_dst_port_t dst_port, u32 node_index, u8 is_ip4)
Definition: udp_local.c:468
ipsec_sa_t * ipsec_sa_pool
Pool of IPSec SAs.
Definition: ipsec_sa.c:32
u32 ah_current_backend
Definition: ipsec.h:176
string name[64]
Definition: fib.api:25
u32 esp6_decrypt_tun_next_index
Definition: ipsec.h:75
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:535
u32 esp_current_backend
Definition: ipsec.h:178
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
Definition: pool.h:255
u32 ah6_decrypt_node_index
Definition: ipsec.h:49
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
Definition: node_funcs.h:1177
static void ipsec_add_node(vlib_main_t *vm, const char *node_name, const char *prev_node_name, u32 *out_node_index, u32 *out_next_index)
Definition: ipsec.c:114
unsigned char u8
Definition: types.h:56
vlib_buffer_t ** b
uword * spd_index_by_sw_if_index
Definition: ipsec.h:126
unsigned int u32
Definition: types.h:88
int vnet_crypto_is_set_handler(vnet_crypto_alg_t alg)
Definition: crypto.c:189
u32 esp4_decrypt_tun_next_index
Definition: ipsec.h:154
vnet_crypto_alg_t alg
Definition: ipsec.h:93
u32 esp6_encrypt_next_index
Definition: ipsec.h:69
clib_error_t * ipsec_rsc_in_use(ipsec_main_t *im)
Definition: ipsec.c:246
esp_async_post_next_t esp_encrypt_async_next
Definition: ipsec.c:29
union ipsec_sa_t::@446 async_op_data
u32 ah6_encrypt_node_index
Definition: ipsec.h:48
uword * udp_port_registrations
Definition: ipsec.h:116
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
u32 ah_default_backend
Definition: ipsec.h:180
u32 esp4_tun_post_next
Definition: esp.h:244
u32 esp6_encrypt_node_index
Definition: ipsec.h:144
u32 esp4_decrypt_next_index
Definition: ipsec.h:153
u32 ah6_encrypt_next_index
Definition: ipsec.h:50
description fragment has unexpected format
Definition: map.api:433
u32 esp_mpls_encrypt_tun_node_index
Definition: ipsec.h:148
#define clib_error_return(e, args...)
Definition: error.h:99
check_support_cb_t check_support_cb
Definition: ipsec.h:60
vnet_main_t * vnet_get_main(void)
u8 * format_ipsec_crypto_alg(u8 *s, va_list *args)
Definition: ipsec_format.c:79
int __clib_unused rv
Definition: application.c:491
#define vlib_call_init_function(vm, x)
Definition: init.h:259
u32 esp6_decrypt_node_index
Definition: ipsec.h:68
static clib_error_t * vnet_feature_init(vlib_main_t *vm)
Definition: feature.c:50
u32 ah4_decrypt_node_index
Definition: ipsec.h:143
clib_error_t * crypto_dispatch_enable_disable(int is_enable)
Definition: crypto.c:459
u32 error_drop_node_index
Definition: ipsec.h:137
Definition: cJSON.c:88
#define hash_get(h, key)
Definition: hash.h:249
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
Definition: pool.h:553
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
Definition: node.c:45
clib_error_t *(* check_support_cb_t)(ipsec_sa_t *sa)
Definition: ipsec.h:34
u32 esp4_encrypt_node_index
Definition: ipsec.h:138
vnet_main_t * vnet_main
Definition: ipsec.h:122
vnet_crypto_op_id_t enc_op_id
Definition: ipsec.h:82
unsigned short u16
Definition: types.h:57
u32 ah4_decrypt_next_index
Definition: ipsec.h:47
u32 ipsec_register_ah_backend(vlib_main_t *vm, ipsec_main_t *im, const char *name, const char *ah4_encrypt_node_name, const char *ah4_decrypt_node_name, const char *ah6_encrypt_node_name, const char *ah6_decrypt_node_name, check_support_cb_t ah_check_support_cb, add_del_sa_sess_cb_t ah_add_del_sa_sess_cb)
Definition: ipsec.c:172
u32 esp4_decrypt_tun_next_index
Definition: ipsec.h:72
u32 vnet_crypto_register_post_node(vlib_main_t *vm, char *post_node_name)
async crypto register functions
Definition: crypto.c:541
static clib_error_t * ipsec_check_ah_support(ipsec_sa_t *sa)
Definition: ipsec.c:33
#define PREDICT_FALSE(x)
Definition: clib.h:124
clib_error_t *(* enable_disable_cb_t)(int is_enable)
Definition: ipsec.h:35
u32 esp6_decrypt_tun_node_index
Definition: ipsec.h:74
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
void ipsec_unregister_udp_port(u16 port)
Definition: ipsec.c:128
u32 esp4_encrypt_node_index
Definition: ipsec.h:63
uword * spd_index_by_spd_id
Definition: ipsec.h:125
u32 ah4_decrypt_node_index
Definition: ipsec.h:45
u32 ah6_encrypt_next_index
Definition: ipsec.h:160
u32 esp6_decrypt_tun_next_index
Definition: ipsec.h:159
ipsec_ah_backend_t * ah_backends
Definition: ipsec.h:172
clib_error_t * ipsec_cli_init(vlib_main_t *vm)
Definition: ipsec_cli.c:911
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
u32 esp4_encrypt_next_index
Definition: ipsec.h:152
u64 data
Definition: ipsec_sa.h:192
u32 ah4_encrypt_next_index
Definition: ipsec.h:46
vnet_interface_main_t * im
uword * sa_index_by_sa_id
Definition: ipsec.h:127
u32 esp6_decrypt_next_index
Definition: ipsec.h:158
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
Definition: pool.h:302
u32 esp4_encrypt_tun_node_index
Definition: ipsec.h:141
vlib_main_t * vlib_main
Definition: ipsec.h:121
clib_error_t * ipsec_add_del_sa_sess_cb(ipsec_main_t *im, u32 sa_index, u8 is_add)
Definition: ipsec.c:69
u32 esp4_post_next
Definition: esp.h:242
u32 esp6_tun_post_next
Definition: esp.h:245
u32 esp6_encrypt_next_index
Definition: ipsec.h:157
#define hash_create(elts, value_bytes)
Definition: hash.h:696
vnet_crypto_op_id_t op_id
Definition: ipsec.h:92
#define ASSERT(truth)
u32 ah4_encrypt_node_index
Definition: ipsec.h:142
ipsec_main_integ_alg_t * integ_algs
Definition: ipsec.h:188
u64 crypto_op_data
Definition: ipsec_sa.h:160
u32 esp4_decrypt_node_index
Definition: ipsec.h:139
u32 ipsec_register_esp_backend(vlib_main_t *vm, ipsec_main_t *im, const char *name, const char *esp4_encrypt_node_name, const char *esp4_encrypt_node_tun_name, const char *esp4_decrypt_node_name, const char *esp4_decrypt_tun_node_name, const char *esp6_encrypt_node_name, const char *esp6_encrypt_node_tun_name, const char *esp6_decrypt_node_name, const char *esp6_decrypt_tun_node_name, const char *esp_mpls_encrypt_node_tun_name, check_support_cb_t esp_check_support_cb, add_del_sa_sess_cb_t esp_add_del_sa_sess_cb, enable_disable_cb_t enable_disable_cb)
Definition: ipsec.c:200
ipsec_protocol_t protocol
Definition: ipsec_sa.h:176
add_del_sa_sess_cb_t add_del_sa_sess_cb
Definition: ipsec.h:58
vnet_crypto_op_id_t dec_op_id
Definition: ipsec.h:83
u32 ah6_decrypt_node_index
Definition: ipsec.h:150
static vlib_main_t * vlib_get_main(void)
Definition: global_funcs.h:38
u32 ah6_encrypt_node_index
Definition: ipsec.h:149
u32 ah6_decrypt_next_index
Definition: ipsec.h:161
check_support_cb_t check_support_cb
Definition: ipsec.h:43
clib_error_t * ipsec_check_support_cb(ipsec_main_t *im, ipsec_sa_t *sa)
Definition: ipsec.c:91
int ipsec_select_ah_backend(ipsec_main_t *im, u32 backend_idx)
Definition: ipsec.c:257
u32 esp4_decrypt_tun_node_index
Definition: ipsec.h:71
vlib_main_t vlib_node_runtime_t * node
Definition: nat44_ei.c:3047
ipsec_main_t ipsec_main
Definition: ipsec.c:28
u64 uword
Definition: types.h:112
union ipsec_sa_t::@445 sync_op_data
int ipsec_select_esp_backend(ipsec_main_t *im, u32 backend_idx)
Definition: ipsec.c:280
u32 esp4_encrypt_tun_node_index
Definition: ipsec.h:73
u16 port
Definition: lb_types.api:73
u32 esp4_decrypt_next_index
Definition: ipsec.h:66
ipsec_crypto_alg_t crypto_alg
Definition: ipsec_sa.h:217
static u32 vlib_num_workers()
Definition: threads.h:354
static clib_error_t * ipsec_check_esp_support(ipsec_sa_t *sa)
Definition: ipsec.c:48
vnet_crypto_alg_t alg
Definition: ipsec.h:84
add_del_sa_sess_cb_t add_del_sa_sess_cb
Definition: ipsec.h:41
void ipsec_set_async_mode(u32 is_enabled)
Definition: ipsec.c:327
ipsec_esp_backend_t * esp_backends
Definition: ipsec.h:174
clib_error_t *(* add_del_sa_sess_cb_t)(u32 sa_index, u8 is_add)
Definition: ipsec.h:33
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
u32 esp_mpls_tun_post_next
Definition: esp.h:246
u8 async_mode
Definition: ipsec.h:209
u32 esp6_encrypt_tun_node_index
Definition: ipsec.h:147
vlib_node_registration_t ipsec4_tun_input_node
(constructor) VLIB_REGISTER_NODE (ipsec4_tun_input_node)
Definition: ipsec_tun_in.c:388
static uword pool_elts(void *v)
Number of active elements in a pool.
Definition: pool.h:127