2 * ipsec.c : IPSEC module functions
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:
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
24 #include <vnet/ipsec/ipsec.h>
25 #include <vnet/ipsec/esp.h>
26 #include <vnet/ipsec/ah.h>
27 #include <vnet/ipsec/ipsec_tun.h>
28 #include <vnet/ipsec/ipsec_itf.h>
30 /* Flow cache is sized for 1 million flows with a load factor of .25.
32 #define IPSEC4_OUT_SPD_DEFAULT_HASH_NUM_BUCKETS (1 << 22)
34 ipsec_main_t ipsec_main;
35 esp_async_post_next_t esp_encrypt_async_next;
36 esp_async_post_next_t esp_decrypt_async_next;
39 ipsec_check_ah_support (ipsec_sa_t * sa)
41 ipsec_main_t *im = &ipsec_main;
43 if (sa->integ_alg == IPSEC_INTEG_ALG_NONE)
44 return clib_error_return (0, "unsupported none integ-alg");
46 if (!vnet_crypto_is_set_handler (im->integ_algs[sa->integ_alg].alg))
47 return clib_error_return (0, "No crypto engine support for %U",
48 format_ipsec_integ_alg, sa->integ_alg);
54 ipsec_check_esp_support (ipsec_sa_t * sa)
56 ipsec_main_t *im = &ipsec_main;
58 if (IPSEC_INTEG_ALG_NONE != sa->integ_alg)
60 if (!vnet_crypto_is_set_handler (im->integ_algs[sa->integ_alg].alg))
61 return clib_error_return (0, "No crypto engine support for %U",
62 format_ipsec_integ_alg, sa->integ_alg);
64 if (IPSEC_CRYPTO_ALG_NONE != sa->crypto_alg)
66 if (!vnet_crypto_is_set_handler (im->crypto_algs[sa->crypto_alg].alg))
67 return clib_error_return (0, "No crypto engine support for %U",
68 format_ipsec_crypto_alg, sa->crypto_alg);
75 ipsec_add_del_sa_sess_cb (ipsec_main_t * im, u32 sa_index, u8 is_add)
77 ipsec_ah_backend_t *ah =
78 pool_elt_at_index (im->ah_backends, im->ah_current_backend);
79 if (ah->add_del_sa_sess_cb)
81 clib_error_t *err = ah->add_del_sa_sess_cb (sa_index, is_add);
85 ipsec_esp_backend_t *esp =
86 pool_elt_at_index (im->esp_backends, im->esp_current_backend);
87 if (esp->add_del_sa_sess_cb)
89 clib_error_t *err = esp->add_del_sa_sess_cb (sa_index, is_add);
97 ipsec_check_support_cb (ipsec_main_t * im, ipsec_sa_t * sa)
99 clib_error_t *error = 0;
101 if (PREDICT_FALSE (sa->protocol == IPSEC_PROTOCOL_AH))
103 ipsec_ah_backend_t *ah =
104 pool_elt_at_index (im->ah_backends, im->ah_current_backend);
105 ASSERT (ah->check_support_cb);
106 error = ah->check_support_cb (sa);
110 ipsec_esp_backend_t *esp =
111 pool_elt_at_index (im->esp_backends, im->esp_current_backend);
112 ASSERT (esp->check_support_cb);
113 error = esp->check_support_cb (sa);
120 ipsec_add_node (vlib_main_t * vm, const char *node_name,
121 const char *prev_node_name, u32 * out_node_index,
122 u32 * out_next_index)
124 vlib_node_t *prev_node, *node;
125 prev_node = vlib_get_node_by_name (vm, (u8 *) prev_node_name);
127 node = vlib_get_node_by_name (vm, (u8 *) node_name);
129 *out_node_index = node->index;
130 *out_next_index = vlib_node_add_next (vm, prev_node->index, node->index);
134 ipsec_unregister_udp_port (u16 port)
136 ipsec_main_t *im = &ipsec_main;
140 p = hash_get (im->udp_port_registrations, port);
148 udp_unregister_dst_port (vlib_get_main (), port, 1);
149 hash_unset (im->udp_port_registrations, port);
153 hash_unset (im->udp_port_registrations, port);
154 hash_set (im->udp_port_registrations, port, n_regs);
159 ipsec_register_udp_port (u16 port)
161 ipsec_main_t *im = &ipsec_main;
165 p = hash_get (im->udp_port_registrations, port);
167 n_regs = (p ? p[0] : 0);
170 udp_register_dst_port (vlib_get_main (), port,
171 ipsec4_tun_input_node.index, 1);
173 hash_unset (im->udp_port_registrations, port);
174 hash_set (im->udp_port_registrations, port, n_regs);
178 ipsec_register_ah_backend (vlib_main_t * vm, ipsec_main_t * im,
180 const char *ah4_encrypt_node_name,
181 const char *ah4_decrypt_node_name,
182 const char *ah6_encrypt_node_name,
183 const char *ah6_decrypt_node_name,
184 check_support_cb_t ah_check_support_cb,
185 add_del_sa_sess_cb_t ah_add_del_sa_sess_cb)
187 ipsec_ah_backend_t *b;
188 pool_get (im->ah_backends, b);
189 b->name = format (0, "%s%c", name, 0);
191 ipsec_add_node (vm, ah4_encrypt_node_name, "ipsec4-output-feature",
192 &b->ah4_encrypt_node_index, &b->ah4_encrypt_next_index);
193 ipsec_add_node (vm, ah4_decrypt_node_name, "ipsec4-input-feature",
194 &b->ah4_decrypt_node_index, &b->ah4_decrypt_next_index);
195 ipsec_add_node (vm, ah6_encrypt_node_name, "ipsec6-output-feature",
196 &b->ah6_encrypt_node_index, &b->ah6_encrypt_next_index);
197 ipsec_add_node (vm, ah6_decrypt_node_name, "ipsec6-input-feature",
198 &b->ah6_decrypt_node_index, &b->ah6_decrypt_next_index);
200 b->check_support_cb = ah_check_support_cb;
201 b->add_del_sa_sess_cb = ah_add_del_sa_sess_cb;
202 return b - im->ah_backends;
206 ipsec_register_esp_backend (
207 vlib_main_t *vm, ipsec_main_t *im, const char *name,
208 const char *esp4_encrypt_node_name, const char *esp4_encrypt_node_tun_name,
209 const char *esp4_decrypt_node_name, const char *esp4_decrypt_tun_node_name,
210 const char *esp6_encrypt_node_name, const char *esp6_encrypt_node_tun_name,
211 const char *esp6_decrypt_node_name, const char *esp6_decrypt_tun_node_name,
212 const char *esp_mpls_encrypt_node_tun_name,
213 check_support_cb_t esp_check_support_cb,
214 add_del_sa_sess_cb_t esp_add_del_sa_sess_cb,
215 enable_disable_cb_t enable_disable_cb)
217 ipsec_esp_backend_t *b;
219 pool_get (im->esp_backends, b);
220 b->name = format (0, "%s%c", name, 0);
222 ipsec_add_node (vm, esp4_encrypt_node_name, "ipsec4-output-feature",
223 &b->esp4_encrypt_node_index, &b->esp4_encrypt_next_index);
224 ipsec_add_node (vm, esp4_decrypt_node_name, "ipsec4-input-feature",
225 &b->esp4_decrypt_node_index, &b->esp4_decrypt_next_index);
226 ipsec_add_node (vm, esp6_encrypt_node_name, "ipsec6-output-feature",
227 &b->esp6_encrypt_node_index, &b->esp6_encrypt_next_index);
228 ipsec_add_node (vm, esp6_decrypt_node_name, "ipsec6-input-feature",
229 &b->esp6_decrypt_node_index, &b->esp6_decrypt_next_index);
230 ipsec_add_node (vm, esp4_decrypt_tun_node_name, "ipsec4-tun-input",
231 &b->esp4_decrypt_tun_node_index,
232 &b->esp4_decrypt_tun_next_index);
233 ipsec_add_node (vm, esp6_decrypt_tun_node_name, "ipsec6-tun-input",
234 &b->esp6_decrypt_tun_node_index,
235 &b->esp6_decrypt_tun_next_index);
237 b->esp6_encrypt_tun_node_index =
238 vlib_get_node_by_name (vm, (u8 *) esp6_encrypt_node_tun_name)->index;
239 b->esp_mpls_encrypt_tun_node_index =
240 vlib_get_node_by_name (vm, (u8 *) esp_mpls_encrypt_node_tun_name)->index;
241 b->esp4_encrypt_tun_node_index =
242 vlib_get_node_by_name (vm, (u8 *) esp4_encrypt_node_tun_name)->index;
244 b->check_support_cb = esp_check_support_cb;
245 b->add_del_sa_sess_cb = esp_add_del_sa_sess_cb;
246 b->enable_disable_cb = enable_disable_cb;
248 return b - im->esp_backends;
252 ipsec_rsc_in_use (ipsec_main_t * im)
254 /* return an error is crypto resource are in use */
255 if (pool_elts (ipsec_sa_pool) > 0)
256 return clib_error_return (0, "%d SA entries configured",
257 pool_elts (ipsec_sa_pool));
258 if (ipsec_itf_count () > 0)
259 return clib_error_return (0, "%d IPSec interface configured",
266 ipsec_select_ah_backend (ipsec_main_t * im, u32 backend_idx)
268 if (ipsec_rsc_in_use (im))
269 return VNET_API_ERROR_RSRC_IN_USE;
271 if (pool_is_free_index (im->ah_backends, backend_idx))
272 return VNET_API_ERROR_INVALID_VALUE;
274 ipsec_ah_backend_t *b = pool_elt_at_index (im->ah_backends, backend_idx);
275 im->ah_current_backend = backend_idx;
276 im->ah4_encrypt_node_index = b->ah4_encrypt_node_index;
277 im->ah4_decrypt_node_index = b->ah4_decrypt_node_index;
278 im->ah4_encrypt_next_index = b->ah4_encrypt_next_index;
279 im->ah4_decrypt_next_index = b->ah4_decrypt_next_index;
280 im->ah6_encrypt_node_index = b->ah6_encrypt_node_index;
281 im->ah6_decrypt_node_index = b->ah6_decrypt_node_index;
282 im->ah6_encrypt_next_index = b->ah6_encrypt_next_index;
283 im->ah6_decrypt_next_index = b->ah6_decrypt_next_index;
289 ipsec_select_esp_backend (ipsec_main_t * im, u32 backend_idx)
291 if (ipsec_rsc_in_use (im))
292 return VNET_API_ERROR_RSRC_IN_USE;
294 if (pool_is_free_index (im->esp_backends, backend_idx))
295 return VNET_API_ERROR_INVALID_VALUE;
297 /* disable current backend */
298 if (im->esp_current_backend != ~0)
300 ipsec_esp_backend_t *cb = pool_elt_at_index (im->esp_backends,
301 im->esp_current_backend);
302 if (cb->enable_disable_cb)
304 if ((cb->enable_disable_cb) (0) != 0)
309 ipsec_esp_backend_t *b = pool_elt_at_index (im->esp_backends, backend_idx);
310 im->esp_current_backend = backend_idx;
311 im->esp4_encrypt_node_index = b->esp4_encrypt_node_index;
312 im->esp4_decrypt_node_index = b->esp4_decrypt_node_index;
313 im->esp4_encrypt_next_index = b->esp4_encrypt_next_index;
314 im->esp4_decrypt_next_index = b->esp4_decrypt_next_index;
315 im->esp6_encrypt_node_index = b->esp6_encrypt_node_index;
316 im->esp6_decrypt_node_index = b->esp6_decrypt_node_index;
317 im->esp6_encrypt_next_index = b->esp6_encrypt_next_index;
318 im->esp6_decrypt_next_index = b->esp6_decrypt_next_index;
319 im->esp4_decrypt_tun_node_index = b->esp4_decrypt_tun_node_index;
320 im->esp4_decrypt_tun_next_index = b->esp4_decrypt_tun_next_index;
321 im->esp6_decrypt_tun_node_index = b->esp6_decrypt_tun_node_index;
322 im->esp6_decrypt_tun_next_index = b->esp6_decrypt_tun_next_index;
323 im->esp4_encrypt_tun_node_index = b->esp4_encrypt_tun_node_index;
324 im->esp6_encrypt_tun_node_index = b->esp6_encrypt_tun_node_index;
325 im->esp_mpls_encrypt_tun_node_index = b->esp_mpls_encrypt_tun_node_index;
327 if (b->enable_disable_cb)
329 if ((b->enable_disable_cb) (1) != 0)
336 ipsec_set_async_mode (u32 is_enabled)
338 ipsec_main_t *im = &ipsec_main;
341 vnet_crypto_request_async_mode (is_enabled);
343 im->async_mode = is_enabled;
345 /* change SA crypto op data */
346 pool_foreach (sa, ipsec_sa_pool)
349 (is_enabled ? sa->async_op_data.data : sa->sync_op_data.data);
354 crypto_engine_backend_register_post_node (vlib_main_t * vm)
356 esp_async_post_next_t *eit;
357 esp_async_post_next_t *dit;
359 eit = &esp_encrypt_async_next;
360 eit->esp4_post_next =
361 vnet_crypto_register_post_node (vm, "esp4-encrypt-post");
362 eit->esp6_post_next =
363 vnet_crypto_register_post_node (vm, "esp6-encrypt-post");
364 eit->esp4_tun_post_next =
365 vnet_crypto_register_post_node (vm, "esp4-encrypt-tun-post");
366 eit->esp6_tun_post_next =
367 vnet_crypto_register_post_node (vm, "esp6-encrypt-tun-post");
368 eit->esp_mpls_tun_post_next =
369 vnet_crypto_register_post_node (vm, "esp-mpls-encrypt-tun-post");
371 dit = &esp_decrypt_async_next;
372 dit->esp4_post_next =
373 vnet_crypto_register_post_node (vm, "esp4-decrypt-post");
374 dit->esp6_post_next =
375 vnet_crypto_register_post_node (vm, "esp6-decrypt-post");
376 dit->esp4_tun_post_next =
377 vnet_crypto_register_post_node (vm, "esp4-decrypt-tun-post");
378 dit->esp6_tun_post_next =
379 vnet_crypto_register_post_node (vm, "esp6-decrypt-tun-post");
382 static clib_error_t *
383 ipsec_init (vlib_main_t * vm)
386 ipsec_main_t *im = &ipsec_main;
387 ipsec_main_crypto_alg_t *a;
389 /* Backend registration requires the feature arcs to be set up */
390 if ((error = vlib_call_init_function (vm, vnet_feature_init)))
393 im->vnet_main = vnet_get_main ();
396 im->spd_index_by_spd_id = hash_create (0, sizeof (uword));
397 im->sa_index_by_sa_id = hash_create (0, sizeof (uword));
398 im->spd_index_by_sw_if_index = hash_create (0, sizeof (uword));
400 vlib_node_t *node = vlib_get_node_by_name (vm, (u8 *) "error-drop");
402 im->error_drop_node_index = node->index;
404 im->ah_current_backend = ~0;
405 im->esp_current_backend = ~0;
407 u32 idx = ipsec_register_ah_backend (vm, im, "crypto engine backend",
412 ipsec_check_ah_support,
415 im->ah_default_backend = idx;
416 int rv = ipsec_select_ah_backend (im, idx);
418 (void) (rv); // avoid warning
420 idx = ipsec_register_esp_backend (
421 vm, im, "crypto engine backend", "esp4-encrypt", "esp4-encrypt-tun",
422 "esp4-decrypt", "esp4-decrypt-tun", "esp6-encrypt", "esp6-encrypt-tun",
423 "esp6-decrypt", "esp6-decrypt-tun", "esp-mpls-encrypt-tun",
424 ipsec_check_esp_support, NULL, crypto_dispatch_enable_disable);
425 im->esp_default_backend = idx;
427 rv = ipsec_select_esp_backend (im, idx);
429 (void) (rv); // avoid warning
431 if ((error = vlib_call_init_function (vm, ipsec_cli_init)))
434 vec_validate (im->crypto_algs, IPSEC_CRYPTO_N_ALG - 1);
436 a = im->crypto_algs + IPSEC_CRYPTO_ALG_NONE;
437 a->enc_op_id = VNET_CRYPTO_OP_NONE;
438 a->dec_op_id = VNET_CRYPTO_OP_NONE;
439 a->alg = VNET_CRYPTO_ALG_NONE;
443 a = im->crypto_algs + IPSEC_CRYPTO_ALG_DES_CBC;
444 a->enc_op_id = VNET_CRYPTO_OP_DES_CBC_ENC;
445 a->dec_op_id = VNET_CRYPTO_OP_DES_CBC_DEC;
446 a->alg = VNET_CRYPTO_ALG_DES_CBC;
447 a->iv_size = a->block_align = 8;
449 a = im->crypto_algs + IPSEC_CRYPTO_ALG_3DES_CBC;
450 a->enc_op_id = VNET_CRYPTO_OP_3DES_CBC_ENC;
451 a->dec_op_id = VNET_CRYPTO_OP_3DES_CBC_DEC;
452 a->alg = VNET_CRYPTO_ALG_3DES_CBC;
453 a->iv_size = a->block_align = 8;
455 a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CBC_128;
456 a->enc_op_id = VNET_CRYPTO_OP_AES_128_CBC_ENC;
457 a->dec_op_id = VNET_CRYPTO_OP_AES_128_CBC_DEC;
458 a->alg = VNET_CRYPTO_ALG_AES_128_CBC;
459 a->iv_size = a->block_align = 16;
461 a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CBC_192;
462 a->enc_op_id = VNET_CRYPTO_OP_AES_192_CBC_ENC;
463 a->dec_op_id = VNET_CRYPTO_OP_AES_192_CBC_DEC;
464 a->alg = VNET_CRYPTO_ALG_AES_192_CBC;
465 a->iv_size = a->block_align = 16;
467 a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CBC_256;
468 a->enc_op_id = VNET_CRYPTO_OP_AES_256_CBC_ENC;
469 a->dec_op_id = VNET_CRYPTO_OP_AES_256_CBC_DEC;
470 a->alg = VNET_CRYPTO_ALG_AES_256_CBC;
471 a->iv_size = a->block_align = 16;
473 a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CTR_128;
474 a->enc_op_id = VNET_CRYPTO_OP_AES_128_CTR_ENC;
475 a->dec_op_id = VNET_CRYPTO_OP_AES_128_CTR_DEC;
476 a->alg = VNET_CRYPTO_ALG_AES_128_CTR;
480 a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CTR_192;
481 a->enc_op_id = VNET_CRYPTO_OP_AES_192_CTR_ENC;
482 a->dec_op_id = VNET_CRYPTO_OP_AES_192_CTR_DEC;
483 a->alg = VNET_CRYPTO_ALG_AES_192_CTR;
487 a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CTR_256;
488 a->enc_op_id = VNET_CRYPTO_OP_AES_256_CTR_ENC;
489 a->dec_op_id = VNET_CRYPTO_OP_AES_256_CTR_DEC;
490 a->alg = VNET_CRYPTO_ALG_AES_256_CTR;
494 a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_GCM_128;
495 a->enc_op_id = VNET_CRYPTO_OP_AES_128_GCM_ENC;
496 a->dec_op_id = VNET_CRYPTO_OP_AES_128_GCM_DEC;
497 a->alg = VNET_CRYPTO_ALG_AES_128_GCM;
502 a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_GCM_192;
503 a->enc_op_id = VNET_CRYPTO_OP_AES_192_GCM_ENC;
504 a->dec_op_id = VNET_CRYPTO_OP_AES_192_GCM_DEC;
505 a->alg = VNET_CRYPTO_ALG_AES_192_GCM;
510 a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_GCM_256;
511 a->enc_op_id = VNET_CRYPTO_OP_AES_256_GCM_ENC;
512 a->dec_op_id = VNET_CRYPTO_OP_AES_256_GCM_DEC;
513 a->alg = VNET_CRYPTO_ALG_AES_256_GCM;
518 vec_validate (im->integ_algs, IPSEC_INTEG_N_ALG - 1);
519 ipsec_main_integ_alg_t *i;
521 i = &im->integ_algs[IPSEC_INTEG_ALG_MD5_96];
522 i->op_id = VNET_CRYPTO_OP_MD5_HMAC;
523 i->alg = VNET_CRYPTO_ALG_HMAC_MD5;
526 i = &im->integ_algs[IPSEC_INTEG_ALG_SHA1_96];
527 i->op_id = VNET_CRYPTO_OP_SHA1_HMAC;
528 i->alg = VNET_CRYPTO_ALG_HMAC_SHA1;
531 i = &im->integ_algs[IPSEC_INTEG_ALG_SHA_256_96];
532 i->op_id = VNET_CRYPTO_OP_SHA1_HMAC;
533 i->alg = VNET_CRYPTO_ALG_HMAC_SHA256;
536 i = &im->integ_algs[IPSEC_INTEG_ALG_SHA_256_128];
537 i->op_id = VNET_CRYPTO_OP_SHA256_HMAC;
538 i->alg = VNET_CRYPTO_ALG_HMAC_SHA256;
541 i = &im->integ_algs[IPSEC_INTEG_ALG_SHA_384_192];
542 i->op_id = VNET_CRYPTO_OP_SHA384_HMAC;
543 i->alg = VNET_CRYPTO_ALG_HMAC_SHA384;
546 i = &im->integ_algs[IPSEC_INTEG_ALG_SHA_512_256];
547 i->op_id = VNET_CRYPTO_OP_SHA512_HMAC;
548 i->alg = VNET_CRYPTO_ALG_HMAC_SHA512;
551 vec_validate_aligned (im->ptd, vlib_num_workers (), CLIB_CACHE_LINE_BYTES);
554 crypto_engine_backend_register_post_node (vm);
556 im->ipsec4_out_spd_hash_tbl = NULL;
557 im->flow_cache_flag = 0;
558 im->ipsec4_out_spd_flow_cache_entries = 0;
560 im->ipsec4_out_spd_hash_num_buckets =
561 IPSEC4_OUT_SPD_DEFAULT_HASH_NUM_BUCKETS;
566 VLIB_INIT_FUNCTION (ipsec_init);
568 static clib_error_t *
569 ipsec_config (vlib_main_t *vm, unformat_input_t *input)
571 ipsec_main_t *im = &ipsec_main;
572 unformat_input_t sub_input;
573 u32 ipsec4_out_spd_hash_num_buckets;
575 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
577 if (unformat (input, "ipv4-outbound-spd-flow-cache on"))
578 im->flow_cache_flag = 1;
579 else if (unformat (input, "ipv4-outbound-spd-flow-cache off"))
580 im->flow_cache_flag = 0;
581 else if (unformat (input, "ipv4-outbound-spd-hash-buckets %d",
582 &ipsec4_out_spd_hash_num_buckets))
584 /* Size of hash is power of 2 >= number of buckets */
585 im->ipsec4_out_spd_hash_num_buckets =
586 1ULL << max_log2 (ipsec4_out_spd_hash_num_buckets);
588 else if (unformat (input, "ip4 %U", unformat_vlib_cli_sub_input,
591 uword table_size = ~0;
594 while (unformat_check_input (&sub_input) != UNFORMAT_END_OF_INPUT)
596 if (unformat (&sub_input, "num-buckets %u", &n_buckets))
599 return clib_error_return (0, "unknown input `%U'",
600 format_unformat_error, &sub_input);
603 ipsec_tun_table_init (AF_IP4, table_size, n_buckets);
605 else if (unformat (input, "ip6 %U", unformat_vlib_cli_sub_input,
608 uword table_size = ~0;
611 while (unformat_check_input (&sub_input) != UNFORMAT_END_OF_INPUT)
613 if (unformat (&sub_input, "num-buckets %u", &n_buckets))
616 return clib_error_return (0, "unknown input `%U'",
617 format_unformat_error, &sub_input);
620 ipsec_tun_table_init (AF_IP6, table_size, n_buckets);
623 return clib_error_return (0, "unknown input `%U'",
624 format_unformat_error, input);
626 if (im->flow_cache_flag)
628 vec_add2 (im->ipsec4_out_spd_hash_tbl, im->ipsec4_out_spd_hash_tbl,
629 im->ipsec4_out_spd_hash_num_buckets);
635 VLIB_CONFIG_FUNCTION (ipsec_config, "ipsec");
638 * fd.io coding-style-patch-verification: ON
641 * eval: (c-set-style "gnu")