crypto: introduce async crypto infra
[vpp.git] / src / vnet / ipsec / ipsec.c
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.h>
23
24 #include <vnet/ipsec/ipsec.h>
25 #include <vnet/ipsec/esp.h>
26 #include <vnet/ipsec/ah.h>
27
28 ipsec_main_t ipsec_main;
29 esp_async_post_next_t esp_encrypt_async_next;
30 esp_async_post_next_t esp_decrypt_async_next;
31
32 static clib_error_t *
33 ipsec_check_ah_support (ipsec_sa_t * sa)
34 {
35   ipsec_main_t *im = &ipsec_main;
36
37   if (sa->integ_alg == IPSEC_INTEG_ALG_NONE)
38     return clib_error_return (0, "unsupported none integ-alg");
39
40   if (!vnet_crypto_is_set_handler (im->integ_algs[sa->integ_alg].alg))
41     return clib_error_return (0, "No crypto engine support for %U",
42                               format_ipsec_integ_alg, sa->integ_alg);
43
44   return 0;
45 }
46
47 static clib_error_t *
48 ipsec_check_esp_support (ipsec_sa_t * sa)
49 {
50   ipsec_main_t *im = &ipsec_main;
51
52   if (IPSEC_INTEG_ALG_NONE != sa->integ_alg)
53     {
54       if (!vnet_crypto_is_set_handler (im->integ_algs[sa->integ_alg].alg))
55         return clib_error_return (0, "No crypto engine support for %U",
56                                   format_ipsec_integ_alg, sa->integ_alg);
57     }
58   if (IPSEC_CRYPTO_ALG_NONE != sa->crypto_alg)
59     {
60       if (!vnet_crypto_is_set_handler (im->crypto_algs[sa->crypto_alg].alg))
61         return clib_error_return (0, "No crypto engine support for %U",
62                                   format_ipsec_crypto_alg, sa->crypto_alg);
63     }
64
65   return (0);
66 }
67
68 clib_error_t *
69 ipsec_add_del_sa_sess_cb (ipsec_main_t * im, u32 sa_index, u8 is_add)
70 {
71   ipsec_ah_backend_t *ah =
72     pool_elt_at_index (im->ah_backends, im->ah_current_backend);
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 =
80     pool_elt_at_index (im->esp_backends, im->esp_current_backend);
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
90 clib_error_t *
91 ipsec_check_support_cb (ipsec_main_t * im, ipsec_sa_t * sa)
92 {
93   clib_error_t *error = 0;
94
95   if (PREDICT_FALSE (sa->protocol == IPSEC_PROTOCOL_AH))
96     {
97       ipsec_ah_backend_t *ah =
98         pool_elt_at_index (im->ah_backends, im->ah_current_backend);
99       ASSERT (ah->check_support_cb);
100       error = ah->check_support_cb (sa);
101     }
102   else
103     {
104       ipsec_esp_backend_t *esp =
105         pool_elt_at_index (im->esp_backends, im->esp_current_backend);
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
128 ipsec_add_feature (const char *arc_name,
129                    const char *node_name, u32 * out_feature_index)
130 {
131   u8 arc;
132
133   arc = vnet_get_feature_arc_index (arc_name);
134   ASSERT (arc != (u8) ~ 0);
135   *out_feature_index = vnet_get_feature_index (arc, node_name);
136 }
137
138 u32
139 ipsec_register_ah_backend (vlib_main_t * vm, ipsec_main_t * im,
140                            const char *name,
141                            const char *ah4_encrypt_node_name,
142                            const char *ah4_decrypt_node_name,
143                            const char *ah6_encrypt_node_name,
144                            const char *ah6_decrypt_node_name,
145                            check_support_cb_t ah_check_support_cb,
146                            add_del_sa_sess_cb_t ah_add_del_sa_sess_cb)
147 {
148   ipsec_ah_backend_t *b;
149   pool_get (im->ah_backends, b);
150   b->name = format (0, "%s%c", name, 0);
151
152   ipsec_add_node (vm, ah4_encrypt_node_name, "ipsec4-output-feature",
153                   &b->ah4_encrypt_node_index, &b->ah4_encrypt_next_index);
154   ipsec_add_node (vm, ah4_decrypt_node_name, "ipsec4-input-feature",
155                   &b->ah4_decrypt_node_index, &b->ah4_decrypt_next_index);
156   ipsec_add_node (vm, ah6_encrypt_node_name, "ipsec6-output-feature",
157                   &b->ah6_encrypt_node_index, &b->ah6_encrypt_next_index);
158   ipsec_add_node (vm, ah6_decrypt_node_name, "ipsec6-input-feature",
159                   &b->ah6_decrypt_node_index, &b->ah6_decrypt_next_index);
160
161   b->check_support_cb = ah_check_support_cb;
162   b->add_del_sa_sess_cb = ah_add_del_sa_sess_cb;
163   return b - im->ah_backends;
164 }
165
166 u32
167 ipsec_register_esp_backend (vlib_main_t * vm, ipsec_main_t * im,
168                             const char *name,
169                             const char *esp4_encrypt_node_name,
170                             const char *esp4_encrypt_node_tun_name,
171                             const char *esp4_decrypt_node_name,
172                             const char *esp4_decrypt_tun_node_name,
173                             const char *esp6_encrypt_node_name,
174                             const char *esp6_encrypt_node_tun_name,
175                             const char *esp6_decrypt_node_name,
176                             const char *esp6_decrypt_tun_node_name,
177                             check_support_cb_t esp_check_support_cb,
178                             add_del_sa_sess_cb_t esp_add_del_sa_sess_cb,
179                             enable_disable_cb_t enable_disable_cb)
180 {
181   ipsec_esp_backend_t *b;
182
183   pool_get (im->esp_backends, b);
184   b->name = format (0, "%s%c", name, 0);
185
186   ipsec_add_node (vm, esp4_encrypt_node_name, "ipsec4-output-feature",
187                   &b->esp4_encrypt_node_index, &b->esp4_encrypt_next_index);
188   ipsec_add_node (vm, esp4_decrypt_node_name, "ipsec4-input-feature",
189                   &b->esp4_decrypt_node_index, &b->esp4_decrypt_next_index);
190   ipsec_add_node (vm, esp6_encrypt_node_name, "ipsec6-output-feature",
191                   &b->esp6_encrypt_node_index, &b->esp6_encrypt_next_index);
192   ipsec_add_node (vm, esp6_decrypt_node_name, "ipsec6-input-feature",
193                   &b->esp6_decrypt_node_index, &b->esp6_decrypt_next_index);
194   ipsec_add_node (vm, esp4_decrypt_tun_node_name, "ipsec4-tun-input",
195                   &b->esp4_decrypt_tun_node_index,
196                   &b->esp4_decrypt_tun_next_index);
197   ipsec_add_node (vm, esp6_decrypt_tun_node_name, "ipsec6-tun-input",
198                   &b->esp6_decrypt_tun_node_index,
199                   &b->esp6_decrypt_tun_next_index);
200
201   ipsec_add_feature ("ip4-output", esp4_encrypt_node_tun_name,
202                      &b->esp44_encrypt_tun_feature_index);
203   ipsec_add_feature ("ip4-output", esp6_encrypt_node_tun_name,
204                      &b->esp46_encrypt_tun_feature_index);
205   ipsec_add_feature ("ip6-output", esp6_encrypt_node_tun_name,
206                      &b->esp66_encrypt_tun_feature_index);
207   ipsec_add_feature ("ip6-output", esp4_encrypt_node_tun_name,
208                      &b->esp64_encrypt_tun_feature_index);
209
210   b->check_support_cb = esp_check_support_cb;
211   b->add_del_sa_sess_cb = esp_add_del_sa_sess_cb;
212   b->enable_disable_cb = enable_disable_cb;
213
214   return b - im->esp_backends;
215 }
216
217 clib_error_t *
218 ipsec_rsc_in_use (ipsec_main_t * im)
219 {
220   /* return an error is crypto resource are in use */
221   if (pool_elts (im->sad) > 0)
222     return clib_error_return (0,
223                               "%d SA entries configured",
224                               pool_elts (im->sad));
225
226   return (NULL);
227 }
228
229 int
230 ipsec_select_ah_backend (ipsec_main_t * im, u32 backend_idx)
231 {
232   if (ipsec_rsc_in_use (im))
233     return VNET_API_ERROR_RSRC_IN_USE;
234
235   if (pool_is_free_index (im->ah_backends, backend_idx))
236     return VNET_API_ERROR_INVALID_VALUE;
237
238   ipsec_ah_backend_t *b = pool_elt_at_index (im->ah_backends, backend_idx);
239   im->ah_current_backend = backend_idx;
240   im->ah4_encrypt_node_index = b->ah4_encrypt_node_index;
241   im->ah4_decrypt_node_index = b->ah4_decrypt_node_index;
242   im->ah4_encrypt_next_index = b->ah4_encrypt_next_index;
243   im->ah4_decrypt_next_index = b->ah4_decrypt_next_index;
244   im->ah6_encrypt_node_index = b->ah6_encrypt_node_index;
245   im->ah6_decrypt_node_index = b->ah6_decrypt_node_index;
246   im->ah6_encrypt_next_index = b->ah6_encrypt_next_index;
247   im->ah6_decrypt_next_index = b->ah6_decrypt_next_index;
248
249   return 0;
250 }
251
252 int
253 ipsec_select_esp_backend (ipsec_main_t * im, u32 backend_idx)
254 {
255   if (ipsec_rsc_in_use (im))
256     return VNET_API_ERROR_RSRC_IN_USE;
257
258   if (pool_is_free_index (im->esp_backends, backend_idx))
259     return VNET_API_ERROR_INVALID_VALUE;
260
261   /* disable current backend */
262   if (im->esp_current_backend != ~0)
263     {
264       ipsec_esp_backend_t *cb = pool_elt_at_index (im->esp_backends,
265                                                    im->esp_current_backend);
266       if (cb->enable_disable_cb)
267         {
268           if ((cb->enable_disable_cb) (0) != 0)
269             return -1;
270         }
271     }
272
273   ipsec_esp_backend_t *b = pool_elt_at_index (im->esp_backends, backend_idx);
274   im->esp_current_backend = backend_idx;
275   im->esp4_encrypt_node_index = b->esp4_encrypt_node_index;
276   im->esp4_decrypt_node_index = b->esp4_decrypt_node_index;
277   im->esp4_encrypt_next_index = b->esp4_encrypt_next_index;
278   im->esp4_decrypt_next_index = b->esp4_decrypt_next_index;
279   im->esp6_encrypt_node_index = b->esp6_encrypt_node_index;
280   im->esp6_decrypt_node_index = b->esp6_decrypt_node_index;
281   im->esp6_encrypt_next_index = b->esp6_encrypt_next_index;
282   im->esp6_decrypt_next_index = b->esp6_decrypt_next_index;
283   im->esp4_decrypt_tun_node_index = b->esp4_decrypt_tun_node_index;
284   im->esp4_decrypt_tun_next_index = b->esp4_decrypt_tun_next_index;
285   im->esp6_decrypt_tun_node_index = b->esp6_decrypt_tun_node_index;
286   im->esp6_decrypt_tun_next_index = b->esp6_decrypt_tun_next_index;
287
288   im->esp44_encrypt_tun_feature_index = b->esp44_encrypt_tun_feature_index;
289   im->esp64_encrypt_tun_feature_index = b->esp64_encrypt_tun_feature_index;
290   im->esp46_encrypt_tun_feature_index = b->esp46_encrypt_tun_feature_index;
291   im->esp66_encrypt_tun_feature_index = b->esp66_encrypt_tun_feature_index;
292
293   if (b->enable_disable_cb)
294     {
295       if ((b->enable_disable_cb) (1) != 0)
296         return -1;
297     }
298   return 0;
299 }
300
301 void
302 ipsec_set_async_mode (u32 is_enabled)
303 {
304   ipsec_main_t *im = &ipsec_main;
305   ipsec_sa_t *sa;
306
307   /* lock all SAs before change im->async_mode */
308   pool_foreach (sa, im->sad, (
309                                {
310                                fib_node_lock (&sa->node);
311                                }));
312
313   im->async_mode = is_enabled;
314
315   /* change SA crypto op data before unlock them */
316   pool_foreach (sa, im->sad, (
317                                {
318                                sa->crypto_op_data = is_enabled ?
319                                sa->async_op_data.data : sa->sync_op_data.data;
320                                fib_node_unlock (&sa->node);
321                                }));
322 }
323
324 static void
325 crypto_engine_backend_register_post_node (vlib_main_t * vm)
326 {
327   esp_async_post_next_t *eit;
328   esp_async_post_next_t *dit;
329
330   eit = &esp_encrypt_async_next;
331   eit->esp4_post_next =
332     vnet_crypto_register_post_node (vm, "esp4-encrypt-post");
333   eit->esp6_post_next =
334     vnet_crypto_register_post_node (vm, "esp6-encrypt-post");
335   eit->esp4_tun_post_next =
336     vnet_crypto_register_post_node (vm, "esp4-encrypt-tun-post");
337   eit->esp6_tun_post_next =
338     vnet_crypto_register_post_node (vm, "esp6-encrypt-tun-post");
339
340   dit = &esp_decrypt_async_next;
341   dit->esp4_post_next =
342     vnet_crypto_register_post_node (vm, "esp4-decrypt-post");
343   dit->esp6_post_next =
344     vnet_crypto_register_post_node (vm, "esp6-decrypt-post");
345   dit->esp4_tun_post_next =
346     vnet_crypto_register_post_node (vm, "esp4-decrypt-tun-post");
347   dit->esp6_tun_post_next =
348     vnet_crypto_register_post_node (vm, "esp6-decrypt-tun-post");
349 }
350
351 static clib_error_t *
352 ipsec_init (vlib_main_t * vm)
353 {
354   clib_error_t *error;
355   ipsec_main_t *im = &ipsec_main;
356   ipsec_main_crypto_alg_t *a;
357
358   /* Backend registration requires the feature arcs to be set up */
359   if ((error = vlib_call_init_function (vm, vnet_feature_init)))
360     return (error);
361
362   im->vnet_main = vnet_get_main ();
363   im->vlib_main = vm;
364
365   im->spd_index_by_spd_id = hash_create (0, sizeof (uword));
366   im->sa_index_by_sa_id = hash_create (0, sizeof (uword));
367   im->spd_index_by_sw_if_index = hash_create (0, sizeof (uword));
368
369   vlib_node_t *node = vlib_get_node_by_name (vm, (u8 *) "error-drop");
370   ASSERT (node);
371   im->error_drop_node_index = node->index;
372
373   im->ah_current_backend = ~0;
374   im->esp_current_backend = ~0;
375
376   u32 idx = ipsec_register_ah_backend (vm, im, "crypto engine backend",
377                                        "ah4-encrypt",
378                                        "ah4-decrypt",
379                                        "ah6-encrypt",
380                                        "ah6-decrypt",
381                                        ipsec_check_ah_support,
382                                        NULL);
383
384   im->ah_default_backend = idx;
385   int rv = ipsec_select_ah_backend (im, idx);
386   ASSERT (0 == rv);
387   (void) (rv);                  // avoid warning
388
389   idx = ipsec_register_esp_backend (vm, im, "crypto engine backend",
390                                     "esp4-encrypt",
391                                     "esp4-encrypt-tun",
392                                     "esp4-decrypt",
393                                     "esp4-decrypt-tun",
394                                     "esp6-encrypt",
395                                     "esp6-encrypt-tun",
396                                     "esp6-decrypt",
397                                     "esp6-decrypt-tun",
398                                     ipsec_check_esp_support,
399                                     NULL, crypto_dispatch_enable_disable);
400   im->esp_default_backend = idx;
401
402   rv = ipsec_select_esp_backend (im, idx);
403   ASSERT (0 == rv);
404   (void) (rv);                  // avoid warning
405
406   if ((error = vlib_call_init_function (vm, ipsec_cli_init)))
407     return error;
408
409   vec_validate (im->crypto_algs, IPSEC_CRYPTO_N_ALG - 1);
410
411   a = im->crypto_algs + IPSEC_CRYPTO_ALG_NONE;
412   a->enc_op_id = VNET_CRYPTO_OP_NONE;
413   a->dec_op_id = VNET_CRYPTO_OP_NONE;
414   a->alg = VNET_CRYPTO_ALG_NONE;
415   a->iv_size = 0;
416   a->block_size = 1;
417
418   a = im->crypto_algs + IPSEC_CRYPTO_ALG_DES_CBC;
419   a->enc_op_id = VNET_CRYPTO_OP_DES_CBC_ENC;
420   a->dec_op_id = VNET_CRYPTO_OP_DES_CBC_DEC;
421   a->alg = VNET_CRYPTO_ALG_DES_CBC;
422   a->iv_size = a->block_size = 8;
423
424   a = im->crypto_algs + IPSEC_CRYPTO_ALG_3DES_CBC;
425   a->enc_op_id = VNET_CRYPTO_OP_3DES_CBC_ENC;
426   a->dec_op_id = VNET_CRYPTO_OP_3DES_CBC_DEC;
427   a->alg = VNET_CRYPTO_ALG_3DES_CBC;
428   a->iv_size = a->block_size = 8;
429
430   a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CBC_128;
431   a->enc_op_id = VNET_CRYPTO_OP_AES_128_CBC_ENC;
432   a->dec_op_id = VNET_CRYPTO_OP_AES_128_CBC_DEC;
433   a->alg = VNET_CRYPTO_ALG_AES_128_CBC;
434   a->iv_size = a->block_size = 16;
435
436   a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CBC_192;
437   a->enc_op_id = VNET_CRYPTO_OP_AES_192_CBC_ENC;
438   a->dec_op_id = VNET_CRYPTO_OP_AES_192_CBC_DEC;
439   a->alg = VNET_CRYPTO_ALG_AES_192_CBC;
440   a->iv_size = a->block_size = 16;
441
442   a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CBC_256;
443   a->enc_op_id = VNET_CRYPTO_OP_AES_256_CBC_ENC;
444   a->dec_op_id = VNET_CRYPTO_OP_AES_256_CBC_DEC;
445   a->alg = VNET_CRYPTO_ALG_AES_256_CBC;
446   a->iv_size = a->block_size = 16;
447
448   a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_GCM_128;
449   a->enc_op_id = VNET_CRYPTO_OP_AES_128_GCM_ENC;
450   a->dec_op_id = VNET_CRYPTO_OP_AES_128_GCM_DEC;
451   a->alg = VNET_CRYPTO_ALG_AES_128_GCM;
452   a->iv_size = 8;
453   a->block_size = 16;
454   a->icv_size = 16;
455
456   a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_GCM_192;
457   a->enc_op_id = VNET_CRYPTO_OP_AES_192_GCM_ENC;
458   a->dec_op_id = VNET_CRYPTO_OP_AES_192_GCM_DEC;
459   a->alg = VNET_CRYPTO_ALG_AES_192_GCM;
460   a->iv_size = 8;
461   a->block_size = 16;
462   a->icv_size = 16;
463
464   a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_GCM_256;
465   a->enc_op_id = VNET_CRYPTO_OP_AES_256_GCM_ENC;
466   a->dec_op_id = VNET_CRYPTO_OP_AES_256_GCM_DEC;
467   a->alg = VNET_CRYPTO_ALG_AES_256_GCM;
468   a->iv_size = 8;
469   a->block_size = 16;
470   a->icv_size = 16;
471
472   vec_validate (im->integ_algs, IPSEC_INTEG_N_ALG - 1);
473   ipsec_main_integ_alg_t *i;
474
475   i = &im->integ_algs[IPSEC_INTEG_ALG_MD5_96];
476   i->op_id = VNET_CRYPTO_OP_MD5_HMAC;
477   i->alg = VNET_CRYPTO_ALG_HMAC_MD5;
478   i->icv_size = 12;
479
480   i = &im->integ_algs[IPSEC_INTEG_ALG_SHA1_96];
481   i->op_id = VNET_CRYPTO_OP_SHA1_HMAC;
482   i->alg = VNET_CRYPTO_ALG_HMAC_SHA1;
483   i->icv_size = 12;
484
485   i = &im->integ_algs[IPSEC_INTEG_ALG_SHA_256_96];
486   i->op_id = VNET_CRYPTO_OP_SHA1_HMAC;
487   i->alg = VNET_CRYPTO_ALG_HMAC_SHA256;
488   i->icv_size = 12;
489
490   i = &im->integ_algs[IPSEC_INTEG_ALG_SHA_256_128];
491   i->op_id = VNET_CRYPTO_OP_SHA256_HMAC;
492   i->alg = VNET_CRYPTO_ALG_HMAC_SHA256;
493   i->icv_size = 16;
494
495   i = &im->integ_algs[IPSEC_INTEG_ALG_SHA_384_192];
496   i->op_id = VNET_CRYPTO_OP_SHA384_HMAC;
497   i->alg = VNET_CRYPTO_ALG_HMAC_SHA384;
498   i->icv_size = 24;
499
500   i = &im->integ_algs[IPSEC_INTEG_ALG_SHA_512_256];
501   i->op_id = VNET_CRYPTO_OP_SHA512_HMAC;
502   i->alg = VNET_CRYPTO_ALG_HMAC_SHA512;
503   i->icv_size = 32;
504
505   vec_validate_aligned (im->ptd, vlib_num_workers (), CLIB_CACHE_LINE_BYTES);
506
507   im->ah4_enc_fq_index =
508     vlib_frame_queue_main_init (ah4_encrypt_node.index, 0);
509   im->ah4_dec_fq_index =
510     vlib_frame_queue_main_init (ah4_decrypt_node.index, 0);
511   im->ah6_enc_fq_index =
512     vlib_frame_queue_main_init (ah6_encrypt_node.index, 0);
513   im->ah6_dec_fq_index =
514     vlib_frame_queue_main_init (ah6_decrypt_node.index, 0);
515
516   im->esp4_enc_fq_index =
517     vlib_frame_queue_main_init (esp4_encrypt_node.index, 0);
518   im->esp4_dec_fq_index =
519     vlib_frame_queue_main_init (esp4_decrypt_node.index, 0);
520   im->esp6_enc_fq_index =
521     vlib_frame_queue_main_init (esp6_encrypt_node.index, 0);
522   im->esp6_dec_fq_index =
523     vlib_frame_queue_main_init (esp6_decrypt_node.index, 0);
524   im->esp4_enc_tun_fq_index =
525     vlib_frame_queue_main_init (esp4_encrypt_tun_node.index, 0);
526   im->esp6_enc_tun_fq_index =
527     vlib_frame_queue_main_init (esp6_encrypt_tun_node.index, 0);
528   im->esp4_dec_tun_fq_index =
529     vlib_frame_queue_main_init (esp4_decrypt_tun_node.index, 0);
530   im->esp6_dec_tun_fq_index =
531     vlib_frame_queue_main_init (esp6_decrypt_tun_node.index, 0);
532
533   im->async_mode = 0;
534   crypto_engine_backend_register_post_node (vm);
535
536   return 0;
537 }
538
539 VLIB_INIT_FUNCTION (ipsec_init);
540
541 /*
542  * fd.io coding-style-patch-verification: ON
543  *
544  * Local Variables:
545  * eval: (c-set-style "gnu")
546  * End:
547  */