Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
Neale Ranns | 999c8ee | 2019-02-01 03:31:24 -0800 | [diff] [blame] | 2 | * ipsec.c : IPSEC module functions |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 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> |
Florin Coras | b040f98 | 2020-10-20 14:59:43 -0700 | [diff] [blame] | 22 | #include <vnet/udp/udp_local.h> |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 23 | |
| 24 | #include <vnet/ipsec/ipsec.h> |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 25 | #include <vnet/ipsec/esp.h> |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 26 | #include <vnet/ipsec/ah.h> |
Sergio Gonzalez Monroy | a10f62b | 2016-11-25 13:36:12 +0000 | [diff] [blame] | 27 | |
Dave Wallace | 71612d6 | 2017-10-24 01:32:41 -0400 | [diff] [blame] | 28 | ipsec_main_t ipsec_main; |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 29 | esp_async_post_next_t esp_encrypt_async_next; |
| 30 | esp_async_post_next_t esp_decrypt_async_next; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 31 | |
| 32 | static clib_error_t * |
Klement Sekera | 4fd5a9d | 2019-01-30 11:11:23 +0100 | [diff] [blame] | 33 | ipsec_check_ah_support (ipsec_sa_t * sa) |
| 34 | { |
Neale Ranns | ece2ae0 | 2019-06-21 12:44:11 +0000 | [diff] [blame] | 35 | ipsec_main_t *im = &ipsec_main; |
| 36 | |
Klement Sekera | 4fd5a9d | 2019-01-30 11:11:23 +0100 | [diff] [blame] | 37 | if (sa->integ_alg == IPSEC_INTEG_ALG_NONE) |
| 38 | return clib_error_return (0, "unsupported none integ-alg"); |
Neale Ranns | ece2ae0 | 2019-06-21 12:44:11 +0000 | [diff] [blame] | 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 | |
Klement Sekera | 4fd5a9d | 2019-01-30 11:11:23 +0100 | [diff] [blame] | 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | static clib_error_t * |
| 48 | ipsec_check_esp_support (ipsec_sa_t * sa) |
Sergio Gonzalez Monroy | d04b60b | 2017-01-20 15:35:23 +0000 | [diff] [blame] | 49 | { |
Neale Ranns | ece2ae0 | 2019-06-21 12:44:11 +0000 | [diff] [blame] | 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); |
Sergio Gonzalez Monroy | d04b60b | 2017-01-20 15:35:23 +0000 | [diff] [blame] | 66 | } |
| 67 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 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; |
Matthew Smith | 461caa5 | 2018-12-21 11:53:16 -0600 | [diff] [blame] | 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 | } |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 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 | |
Neale Ranns | abc5660 | 2020-04-01 09:45:23 +0000 | [diff] [blame] | 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 | void |
| 139 | ipsec_unregister_udp_port (u16 port) |
| 140 | { |
| 141 | ipsec_main_t *im = &ipsec_main; |
| 142 | u32 n_regs; |
| 143 | uword *p; |
| 144 | |
| 145 | p = hash_get (im->udp_port_registrations, port); |
| 146 | |
| 147 | ASSERT (p); |
| 148 | |
| 149 | n_regs = p[0]; |
| 150 | |
| 151 | if (0 == --n_regs) |
| 152 | { |
| 153 | udp_unregister_dst_port (vlib_get_main (), port, 1); |
| 154 | hash_unset (im->udp_port_registrations, port); |
| 155 | } |
| 156 | else |
| 157 | { |
| 158 | hash_unset (im->udp_port_registrations, port); |
| 159 | hash_set (im->udp_port_registrations, port, n_regs); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | void |
| 164 | ipsec_register_udp_port (u16 port) |
| 165 | { |
| 166 | ipsec_main_t *im = &ipsec_main; |
| 167 | u32 n_regs; |
| 168 | uword *p; |
| 169 | |
| 170 | p = hash_get (im->udp_port_registrations, port); |
| 171 | |
| 172 | n_regs = (p ? p[0] : 0); |
| 173 | |
| 174 | if (0 == n_regs++) |
| 175 | udp_register_dst_port (vlib_get_main (), port, |
| 176 | ipsec4_tun_input_node.index, 1); |
| 177 | |
| 178 | hash_unset (im->udp_port_registrations, port); |
| 179 | hash_set (im->udp_port_registrations, port, n_regs); |
| 180 | } |
| 181 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 182 | u32 |
| 183 | ipsec_register_ah_backend (vlib_main_t * vm, ipsec_main_t * im, |
| 184 | const char *name, |
| 185 | const char *ah4_encrypt_node_name, |
| 186 | const char *ah4_decrypt_node_name, |
| 187 | const char *ah6_encrypt_node_name, |
| 188 | const char *ah6_decrypt_node_name, |
| 189 | check_support_cb_t ah_check_support_cb, |
| 190 | add_del_sa_sess_cb_t ah_add_del_sa_sess_cb) |
| 191 | { |
| 192 | ipsec_ah_backend_t *b; |
| 193 | pool_get (im->ah_backends, b); |
Kingwel Xie | 561d1ca | 2019-03-05 22:56:17 -0500 | [diff] [blame] | 194 | b->name = format (0, "%s%c", name, 0); |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 195 | |
Pierre Pfister | 057b356 | 2018-12-10 17:01:01 +0100 | [diff] [blame] | 196 | ipsec_add_node (vm, ah4_encrypt_node_name, "ipsec4-output-feature", |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 197 | &b->ah4_encrypt_node_index, &b->ah4_encrypt_next_index); |
Pierre Pfister | 057b356 | 2018-12-10 17:01:01 +0100 | [diff] [blame] | 198 | ipsec_add_node (vm, ah4_decrypt_node_name, "ipsec4-input-feature", |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 199 | &b->ah4_decrypt_node_index, &b->ah4_decrypt_next_index); |
Pierre Pfister | 057b356 | 2018-12-10 17:01:01 +0100 | [diff] [blame] | 200 | ipsec_add_node (vm, ah6_encrypt_node_name, "ipsec6-output-feature", |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 201 | &b->ah6_encrypt_node_index, &b->ah6_encrypt_next_index); |
Pierre Pfister | 057b356 | 2018-12-10 17:01:01 +0100 | [diff] [blame] | 202 | ipsec_add_node (vm, ah6_decrypt_node_name, "ipsec6-input-feature", |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 203 | &b->ah6_decrypt_node_index, &b->ah6_decrypt_next_index); |
| 204 | |
| 205 | b->check_support_cb = ah_check_support_cb; |
| 206 | b->add_del_sa_sess_cb = ah_add_del_sa_sess_cb; |
| 207 | return b - im->ah_backends; |
| 208 | } |
| 209 | |
| 210 | u32 |
Neale Ranns | 4a58e49 | 2020-12-21 13:19:10 +0000 | [diff] [blame] | 211 | ipsec_register_esp_backend ( |
| 212 | vlib_main_t *vm, ipsec_main_t *im, const char *name, |
| 213 | const char *esp4_encrypt_node_name, const char *esp4_encrypt_node_tun_name, |
| 214 | const char *esp4_decrypt_node_name, const char *esp4_decrypt_tun_node_name, |
| 215 | const char *esp6_encrypt_node_name, const char *esp6_encrypt_node_tun_name, |
| 216 | const char *esp6_decrypt_node_name, const char *esp6_decrypt_tun_node_name, |
| 217 | const char *esp_mpls_encrypt_node_tun_name, |
| 218 | check_support_cb_t esp_check_support_cb, |
| 219 | add_del_sa_sess_cb_t esp_add_del_sa_sess_cb, |
| 220 | enable_disable_cb_t enable_disable_cb) |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 221 | { |
| 222 | ipsec_esp_backend_t *b; |
Neale Ranns | e8915fc | 2019-04-23 20:57:55 -0400 | [diff] [blame] | 223 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 224 | pool_get (im->esp_backends, b); |
Kingwel Xie | 561d1ca | 2019-03-05 22:56:17 -0500 | [diff] [blame] | 225 | b->name = format (0, "%s%c", name, 0); |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 226 | |
Pierre Pfister | 057b356 | 2018-12-10 17:01:01 +0100 | [diff] [blame] | 227 | ipsec_add_node (vm, esp4_encrypt_node_name, "ipsec4-output-feature", |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 228 | &b->esp4_encrypt_node_index, &b->esp4_encrypt_next_index); |
Pierre Pfister | 057b356 | 2018-12-10 17:01:01 +0100 | [diff] [blame] | 229 | ipsec_add_node (vm, esp4_decrypt_node_name, "ipsec4-input-feature", |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 230 | &b->esp4_decrypt_node_index, &b->esp4_decrypt_next_index); |
Pierre Pfister | 057b356 | 2018-12-10 17:01:01 +0100 | [diff] [blame] | 231 | ipsec_add_node (vm, esp6_encrypt_node_name, "ipsec6-output-feature", |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 232 | &b->esp6_encrypt_node_index, &b->esp6_encrypt_next_index); |
Pierre Pfister | 057b356 | 2018-12-10 17:01:01 +0100 | [diff] [blame] | 233 | ipsec_add_node (vm, esp6_decrypt_node_name, "ipsec6-input-feature", |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 234 | &b->esp6_decrypt_node_index, &b->esp6_decrypt_next_index); |
Neale Ranns | 7ec120e | 2020-01-21 04:58:02 +0000 | [diff] [blame] | 235 | ipsec_add_node (vm, esp4_decrypt_tun_node_name, "ipsec4-tun-input", |
| 236 | &b->esp4_decrypt_tun_node_index, |
| 237 | &b->esp4_decrypt_tun_next_index); |
| 238 | ipsec_add_node (vm, esp6_decrypt_tun_node_name, "ipsec6-tun-input", |
| 239 | &b->esp6_decrypt_tun_node_index, |
| 240 | &b->esp6_decrypt_tun_next_index); |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 241 | |
Neale Ranns | 4ec36c5 | 2020-03-31 09:21:29 -0400 | [diff] [blame] | 242 | b->esp6_encrypt_tun_node_index = |
| 243 | vlib_get_node_by_name (vm, (u8 *) esp6_encrypt_node_tun_name)->index; |
Neale Ranns | 4a58e49 | 2020-12-21 13:19:10 +0000 | [diff] [blame] | 244 | b->esp_mpls_encrypt_tun_node_index = |
| 245 | vlib_get_node_by_name (vm, (u8 *) esp_mpls_encrypt_node_tun_name)->index; |
Neale Ranns | 4ec36c5 | 2020-03-31 09:21:29 -0400 | [diff] [blame] | 246 | b->esp4_encrypt_tun_node_index = |
| 247 | vlib_get_node_by_name (vm, (u8 *) esp4_encrypt_node_tun_name)->index; |
Neale Ranns | e8915fc | 2019-04-23 20:57:55 -0400 | [diff] [blame] | 248 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 249 | b->check_support_cb = esp_check_support_cb; |
| 250 | b->add_del_sa_sess_cb = esp_add_del_sa_sess_cb; |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 251 | b->enable_disable_cb = enable_disable_cb; |
| 252 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 253 | return b - im->esp_backends; |
| 254 | } |
| 255 | |
Neale Ranns | e8915fc | 2019-04-23 20:57:55 -0400 | [diff] [blame] | 256 | clib_error_t * |
| 257 | ipsec_rsc_in_use (ipsec_main_t * im) |
Neale Ranns | b4cfd55 | 2019-02-13 02:08:06 -0800 | [diff] [blame] | 258 | { |
Neale Ranns | e8915fc | 2019-04-23 20:57:55 -0400 | [diff] [blame] | 259 | /* return an error is crypto resource are in use */ |
| 260 | if (pool_elts (im->sad) > 0) |
| 261 | return clib_error_return (0, |
| 262 | "%d SA entries configured", |
| 263 | pool_elts (im->sad)); |
Neale Ranns | b4cfd55 | 2019-02-13 02:08:06 -0800 | [diff] [blame] | 264 | |
Neale Ranns | e8915fc | 2019-04-23 20:57:55 -0400 | [diff] [blame] | 265 | return (NULL); |
Neale Ranns | b4cfd55 | 2019-02-13 02:08:06 -0800 | [diff] [blame] | 266 | } |
| 267 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 268 | int |
| 269 | ipsec_select_ah_backend (ipsec_main_t * im, u32 backend_idx) |
| 270 | { |
Neale Ranns | e8915fc | 2019-04-23 20:57:55 -0400 | [diff] [blame] | 271 | if (ipsec_rsc_in_use (im)) |
| 272 | return VNET_API_ERROR_RSRC_IN_USE; |
| 273 | |
| 274 | if (pool_is_free_index (im->ah_backends, backend_idx)) |
| 275 | return VNET_API_ERROR_INVALID_VALUE; |
| 276 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 277 | ipsec_ah_backend_t *b = pool_elt_at_index (im->ah_backends, backend_idx); |
| 278 | im->ah_current_backend = backend_idx; |
| 279 | im->ah4_encrypt_node_index = b->ah4_encrypt_node_index; |
| 280 | im->ah4_decrypt_node_index = b->ah4_decrypt_node_index; |
| 281 | im->ah4_encrypt_next_index = b->ah4_encrypt_next_index; |
| 282 | im->ah4_decrypt_next_index = b->ah4_decrypt_next_index; |
| 283 | im->ah6_encrypt_node_index = b->ah6_encrypt_node_index; |
| 284 | im->ah6_decrypt_node_index = b->ah6_decrypt_node_index; |
| 285 | im->ah6_encrypt_next_index = b->ah6_encrypt_next_index; |
| 286 | im->ah6_decrypt_next_index = b->ah6_decrypt_next_index; |
Neale Ranns | b4cfd55 | 2019-02-13 02:08:06 -0800 | [diff] [blame] | 287 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 288 | return 0; |
| 289 | } |
| 290 | |
| 291 | int |
| 292 | ipsec_select_esp_backend (ipsec_main_t * im, u32 backend_idx) |
| 293 | { |
Neale Ranns | e8915fc | 2019-04-23 20:57:55 -0400 | [diff] [blame] | 294 | if (ipsec_rsc_in_use (im)) |
| 295 | return VNET_API_ERROR_RSRC_IN_USE; |
| 296 | |
| 297 | if (pool_is_free_index (im->esp_backends, backend_idx)) |
| 298 | return VNET_API_ERROR_INVALID_VALUE; |
| 299 | |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 300 | /* disable current backend */ |
| 301 | if (im->esp_current_backend != ~0) |
| 302 | { |
| 303 | ipsec_esp_backend_t *cb = pool_elt_at_index (im->esp_backends, |
| 304 | im->esp_current_backend); |
| 305 | if (cb->enable_disable_cb) |
| 306 | { |
| 307 | if ((cb->enable_disable_cb) (0) != 0) |
| 308 | return -1; |
| 309 | } |
| 310 | } |
| 311 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 312 | ipsec_esp_backend_t *b = pool_elt_at_index (im->esp_backends, backend_idx); |
| 313 | im->esp_current_backend = backend_idx; |
| 314 | im->esp4_encrypt_node_index = b->esp4_encrypt_node_index; |
| 315 | im->esp4_decrypt_node_index = b->esp4_decrypt_node_index; |
| 316 | im->esp4_encrypt_next_index = b->esp4_encrypt_next_index; |
| 317 | im->esp4_decrypt_next_index = b->esp4_decrypt_next_index; |
| 318 | im->esp6_encrypt_node_index = b->esp6_encrypt_node_index; |
| 319 | im->esp6_decrypt_node_index = b->esp6_decrypt_node_index; |
| 320 | im->esp6_encrypt_next_index = b->esp6_encrypt_next_index; |
| 321 | im->esp6_decrypt_next_index = b->esp6_decrypt_next_index; |
Neale Ranns | 7ec120e | 2020-01-21 04:58:02 +0000 | [diff] [blame] | 322 | im->esp4_decrypt_tun_node_index = b->esp4_decrypt_tun_node_index; |
| 323 | im->esp4_decrypt_tun_next_index = b->esp4_decrypt_tun_next_index; |
| 324 | im->esp6_decrypt_tun_node_index = b->esp6_decrypt_tun_node_index; |
| 325 | im->esp6_decrypt_tun_next_index = b->esp6_decrypt_tun_next_index; |
Neale Ranns | 4ec36c5 | 2020-03-31 09:21:29 -0400 | [diff] [blame] | 326 | im->esp4_encrypt_tun_node_index = b->esp4_encrypt_tun_node_index; |
| 327 | im->esp6_encrypt_tun_node_index = b->esp6_encrypt_tun_node_index; |
Neale Ranns | 4a58e49 | 2020-12-21 13:19:10 +0000 | [diff] [blame] | 328 | im->esp_mpls_encrypt_tun_node_index = b->esp_mpls_encrypt_tun_node_index; |
Neale Ranns | e8915fc | 2019-04-23 20:57:55 -0400 | [diff] [blame] | 329 | |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 330 | if (b->enable_disable_cb) |
| 331 | { |
| 332 | if ((b->enable_disable_cb) (1) != 0) |
| 333 | return -1; |
| 334 | } |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 335 | return 0; |
| 336 | } |
| 337 | |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 338 | void |
| 339 | ipsec_set_async_mode (u32 is_enabled) |
| 340 | { |
| 341 | ipsec_main_t *im = &ipsec_main; |
| 342 | ipsec_sa_t *sa; |
| 343 | |
| 344 | /* lock all SAs before change im->async_mode */ |
Damjan Marion | b2c31b6 | 2020-12-13 21:47:40 +0100 | [diff] [blame] | 345 | pool_foreach (sa, im->sad) |
| 346 | { |
| 347 | fib_node_lock (&sa->node); |
| 348 | } |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 349 | |
| 350 | im->async_mode = is_enabled; |
| 351 | |
| 352 | /* change SA crypto op data before unlock them */ |
Damjan Marion | b2c31b6 | 2020-12-13 21:47:40 +0100 | [diff] [blame] | 353 | pool_foreach (sa, im->sad) |
| 354 | { |
| 355 | sa->crypto_op_data = is_enabled ? |
| 356 | sa->async_op_data.data : sa->sync_op_data.data; |
| 357 | fib_node_unlock (&sa->node); |
| 358 | } |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | static void |
| 362 | crypto_engine_backend_register_post_node (vlib_main_t * vm) |
| 363 | { |
| 364 | esp_async_post_next_t *eit; |
| 365 | esp_async_post_next_t *dit; |
| 366 | |
| 367 | eit = &esp_encrypt_async_next; |
| 368 | eit->esp4_post_next = |
| 369 | vnet_crypto_register_post_node (vm, "esp4-encrypt-post"); |
| 370 | eit->esp6_post_next = |
| 371 | vnet_crypto_register_post_node (vm, "esp6-encrypt-post"); |
| 372 | eit->esp4_tun_post_next = |
| 373 | vnet_crypto_register_post_node (vm, "esp4-encrypt-tun-post"); |
| 374 | eit->esp6_tun_post_next = |
| 375 | vnet_crypto_register_post_node (vm, "esp6-encrypt-tun-post"); |
Neale Ranns | 4a58e49 | 2020-12-21 13:19:10 +0000 | [diff] [blame] | 376 | eit->esp_mpls_tun_post_next = |
| 377 | vnet_crypto_register_post_node (vm, "esp-mpls-encrypt-tun-post"); |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 378 | |
| 379 | dit = &esp_decrypt_async_next; |
| 380 | dit->esp4_post_next = |
| 381 | vnet_crypto_register_post_node (vm, "esp4-decrypt-post"); |
| 382 | dit->esp6_post_next = |
| 383 | vnet_crypto_register_post_node (vm, "esp6-decrypt-post"); |
| 384 | dit->esp4_tun_post_next = |
| 385 | vnet_crypto_register_post_node (vm, "esp4-decrypt-tun-post"); |
| 386 | dit->esp6_tun_post_next = |
| 387 | vnet_crypto_register_post_node (vm, "esp6-decrypt-tun-post"); |
| 388 | } |
| 389 | |
Sergio Gonzalez Monroy | d04b60b | 2017-01-20 15:35:23 +0000 | [diff] [blame] | 390 | static clib_error_t * |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 391 | ipsec_init (vlib_main_t * vm) |
| 392 | { |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 393 | clib_error_t *error; |
| 394 | ipsec_main_t *im = &ipsec_main; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 395 | ipsec_main_crypto_alg_t *a; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 396 | |
Dave Barach | 0dd9165 | 2019-05-05 13:34:28 -0400 | [diff] [blame] | 397 | /* Backend registration requires the feature arcs to be set up */ |
| 398 | if ((error = vlib_call_init_function (vm, vnet_feature_init))) |
| 399 | return (error); |
| 400 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 401 | im->vnet_main = vnet_get_main (); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 402 | im->vlib_main = vm; |
| 403 | |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 404 | im->spd_index_by_spd_id = hash_create (0, sizeof (uword)); |
| 405 | im->sa_index_by_sa_id = hash_create (0, sizeof (uword)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 406 | im->spd_index_by_sw_if_index = hash_create (0, sizeof (uword)); |
| 407 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 408 | vlib_node_t *node = vlib_get_node_by_name (vm, (u8 *) "error-drop"); |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 409 | ASSERT (node); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 410 | im->error_drop_node_index = node->index; |
| 411 | |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 412 | im->ah_current_backend = ~0; |
| 413 | im->esp_current_backend = ~0; |
| 414 | |
Neale Ranns | d1a5b2d | 2019-05-16 17:09:28 +0000 | [diff] [blame] | 415 | u32 idx = ipsec_register_ah_backend (vm, im, "crypto engine backend", |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 416 | "ah4-encrypt", |
| 417 | "ah4-decrypt", |
| 418 | "ah6-encrypt", |
| 419 | "ah6-decrypt", |
Klement Sekera | 4fd5a9d | 2019-01-30 11:11:23 +0100 | [diff] [blame] | 420 | ipsec_check_ah_support, |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 421 | NULL); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 422 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 423 | im->ah_default_backend = idx; |
| 424 | int rv = ipsec_select_ah_backend (im, idx); |
| 425 | ASSERT (0 == rv); |
| 426 | (void) (rv); // avoid warning |
Sergio Gonzalez Monroy | d04b60b | 2017-01-20 15:35:23 +0000 | [diff] [blame] | 427 | |
Neale Ranns | 4a58e49 | 2020-12-21 13:19:10 +0000 | [diff] [blame] | 428 | idx = ipsec_register_esp_backend ( |
| 429 | vm, im, "crypto engine backend", "esp4-encrypt", "esp4-encrypt-tun", |
| 430 | "esp4-decrypt", "esp4-decrypt-tun", "esp6-encrypt", "esp6-encrypt-tun", |
| 431 | "esp6-decrypt", "esp6-decrypt-tun", "esp-mpls-encrypt-tun", |
| 432 | ipsec_check_esp_support, NULL, crypto_dispatch_enable_disable); |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 433 | im->esp_default_backend = idx; |
“mukeshyadav1984” | 430ac93 | 2017-11-23 02:39:33 -0800 | [diff] [blame] | 434 | |
Klement Sekera | b4d3053 | 2018-11-08 13:00:02 +0100 | [diff] [blame] | 435 | rv = ipsec_select_esp_backend (im, idx); |
| 436 | ASSERT (0 == rv); |
| 437 | (void) (rv); // avoid warning |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 438 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 439 | if ((error = vlib_call_init_function (vm, ipsec_cli_init))) |
| 440 | return error; |
| 441 | |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 442 | vec_validate (im->crypto_algs, IPSEC_CRYPTO_N_ALG - 1); |
| 443 | |
Neale Ranns | 2cdcd0c | 2019-08-27 12:26:14 +0000 | [diff] [blame] | 444 | a = im->crypto_algs + IPSEC_CRYPTO_ALG_NONE; |
| 445 | a->enc_op_id = VNET_CRYPTO_OP_NONE; |
| 446 | a->dec_op_id = VNET_CRYPTO_OP_NONE; |
| 447 | a->alg = VNET_CRYPTO_ALG_NONE; |
| 448 | a->iv_size = 0; |
Christian Hopps | fb7e7ed | 2019-11-03 07:02:15 -0500 | [diff] [blame] | 449 | a->block_align = 1; |
Neale Ranns | 2cdcd0c | 2019-08-27 12:26:14 +0000 | [diff] [blame] | 450 | |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 451 | a = im->crypto_algs + IPSEC_CRYPTO_ALG_DES_CBC; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 452 | a->enc_op_id = VNET_CRYPTO_OP_DES_CBC_ENC; |
| 453 | a->dec_op_id = VNET_CRYPTO_OP_DES_CBC_DEC; |
Damjan Marion | d1bed68 | 2019-04-24 15:20:35 +0200 | [diff] [blame] | 454 | a->alg = VNET_CRYPTO_ALG_DES_CBC; |
Christian Hopps | fb7e7ed | 2019-11-03 07:02:15 -0500 | [diff] [blame] | 455 | a->iv_size = a->block_align = 8; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 456 | |
| 457 | a = im->crypto_algs + IPSEC_CRYPTO_ALG_3DES_CBC; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 458 | a->enc_op_id = VNET_CRYPTO_OP_3DES_CBC_ENC; |
| 459 | a->dec_op_id = VNET_CRYPTO_OP_3DES_CBC_DEC; |
Damjan Marion | d1bed68 | 2019-04-24 15:20:35 +0200 | [diff] [blame] | 460 | a->alg = VNET_CRYPTO_ALG_3DES_CBC; |
Christian Hopps | fb7e7ed | 2019-11-03 07:02:15 -0500 | [diff] [blame] | 461 | a->iv_size = a->block_align = 8; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 462 | |
| 463 | a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CBC_128; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 464 | a->enc_op_id = VNET_CRYPTO_OP_AES_128_CBC_ENC; |
| 465 | a->dec_op_id = VNET_CRYPTO_OP_AES_128_CBC_DEC; |
Damjan Marion | d1bed68 | 2019-04-24 15:20:35 +0200 | [diff] [blame] | 466 | a->alg = VNET_CRYPTO_ALG_AES_128_CBC; |
Christian Hopps | fb7e7ed | 2019-11-03 07:02:15 -0500 | [diff] [blame] | 467 | a->iv_size = a->block_align = 16; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 468 | |
| 469 | a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CBC_192; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 470 | a->enc_op_id = VNET_CRYPTO_OP_AES_192_CBC_ENC; |
| 471 | a->dec_op_id = VNET_CRYPTO_OP_AES_192_CBC_DEC; |
Damjan Marion | d1bed68 | 2019-04-24 15:20:35 +0200 | [diff] [blame] | 472 | a->alg = VNET_CRYPTO_ALG_AES_192_CBC; |
Christian Hopps | fb7e7ed | 2019-11-03 07:02:15 -0500 | [diff] [blame] | 473 | a->iv_size = a->block_align = 16; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 474 | |
| 475 | a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CBC_256; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 476 | a->enc_op_id = VNET_CRYPTO_OP_AES_256_CBC_ENC; |
| 477 | a->dec_op_id = VNET_CRYPTO_OP_AES_256_CBC_DEC; |
Damjan Marion | d1bed68 | 2019-04-24 15:20:35 +0200 | [diff] [blame] | 478 | a->alg = VNET_CRYPTO_ALG_AES_256_CBC; |
Christian Hopps | fb7e7ed | 2019-11-03 07:02:15 -0500 | [diff] [blame] | 479 | a->iv_size = a->block_align = 16; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 480 | |
Benoît Ganne | 490b927 | 2021-01-22 18:03:09 +0100 | [diff] [blame] | 481 | a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CTR_128; |
| 482 | a->enc_op_id = VNET_CRYPTO_OP_AES_128_CTR_ENC; |
| 483 | a->dec_op_id = VNET_CRYPTO_OP_AES_128_CTR_DEC; |
| 484 | a->alg = VNET_CRYPTO_ALG_AES_128_CTR; |
| 485 | a->iv_size = 8; |
| 486 | a->block_align = 1; |
| 487 | |
| 488 | a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CTR_192; |
| 489 | a->enc_op_id = VNET_CRYPTO_OP_AES_192_CTR_ENC; |
| 490 | a->dec_op_id = VNET_CRYPTO_OP_AES_192_CTR_DEC; |
| 491 | a->alg = VNET_CRYPTO_ALG_AES_192_CTR; |
| 492 | a->iv_size = 8; |
| 493 | a->block_align = 1; |
| 494 | |
| 495 | a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_CTR_256; |
| 496 | a->enc_op_id = VNET_CRYPTO_OP_AES_256_CTR_ENC; |
| 497 | a->dec_op_id = VNET_CRYPTO_OP_AES_256_CTR_DEC; |
| 498 | a->alg = VNET_CRYPTO_ALG_AES_256_CTR; |
| 499 | a->iv_size = 8; |
| 500 | a->block_align = 1; |
| 501 | |
Neale Ranns | 47feb11 | 2019-04-11 15:14:07 +0000 | [diff] [blame] | 502 | a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_GCM_128; |
| 503 | a->enc_op_id = VNET_CRYPTO_OP_AES_128_GCM_ENC; |
| 504 | a->dec_op_id = VNET_CRYPTO_OP_AES_128_GCM_DEC; |
Damjan Marion | d1bed68 | 2019-04-24 15:20:35 +0200 | [diff] [blame] | 505 | a->alg = VNET_CRYPTO_ALG_AES_128_GCM; |
Damjan Marion | f1ecb65 | 2020-02-10 19:21:14 +0100 | [diff] [blame] | 506 | a->iv_size = 8; |
Christian Hopps | fb7e7ed | 2019-11-03 07:02:15 -0500 | [diff] [blame] | 507 | a->block_align = 1; |
Neale Ranns | 47feb11 | 2019-04-11 15:14:07 +0000 | [diff] [blame] | 508 | a->icv_size = 16; |
| 509 | |
| 510 | a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_GCM_192; |
| 511 | a->enc_op_id = VNET_CRYPTO_OP_AES_192_GCM_ENC; |
| 512 | a->dec_op_id = VNET_CRYPTO_OP_AES_192_GCM_DEC; |
Damjan Marion | d1bed68 | 2019-04-24 15:20:35 +0200 | [diff] [blame] | 513 | a->alg = VNET_CRYPTO_ALG_AES_192_GCM; |
Damjan Marion | f1ecb65 | 2020-02-10 19:21:14 +0100 | [diff] [blame] | 514 | a->iv_size = 8; |
Christian Hopps | fb7e7ed | 2019-11-03 07:02:15 -0500 | [diff] [blame] | 515 | a->block_align = 1; |
Neale Ranns | 47feb11 | 2019-04-11 15:14:07 +0000 | [diff] [blame] | 516 | a->icv_size = 16; |
| 517 | |
| 518 | a = im->crypto_algs + IPSEC_CRYPTO_ALG_AES_GCM_256; |
| 519 | a->enc_op_id = VNET_CRYPTO_OP_AES_256_GCM_ENC; |
| 520 | a->dec_op_id = VNET_CRYPTO_OP_AES_256_GCM_DEC; |
Damjan Marion | d1bed68 | 2019-04-24 15:20:35 +0200 | [diff] [blame] | 521 | a->alg = VNET_CRYPTO_ALG_AES_256_GCM; |
Damjan Marion | f1ecb65 | 2020-02-10 19:21:14 +0100 | [diff] [blame] | 522 | a->iv_size = 8; |
Christian Hopps | fb7e7ed | 2019-11-03 07:02:15 -0500 | [diff] [blame] | 523 | a->block_align = 1; |
Neale Ranns | 47feb11 | 2019-04-11 15:14:07 +0000 | [diff] [blame] | 524 | a->icv_size = 16; |
| 525 | |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 526 | vec_validate (im->integ_algs, IPSEC_INTEG_N_ALG - 1); |
| 527 | ipsec_main_integ_alg_t *i; |
| 528 | |
Dmitry Vakhrushev | 77cc14a | 2019-08-14 00:12:33 -0400 | [diff] [blame] | 529 | i = &im->integ_algs[IPSEC_INTEG_ALG_MD5_96]; |
| 530 | i->op_id = VNET_CRYPTO_OP_MD5_HMAC; |
| 531 | i->alg = VNET_CRYPTO_ALG_HMAC_MD5; |
| 532 | i->icv_size = 12; |
| 533 | |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 534 | i = &im->integ_algs[IPSEC_INTEG_ALG_SHA1_96]; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 535 | i->op_id = VNET_CRYPTO_OP_SHA1_HMAC; |
Damjan Marion | d1bed68 | 2019-04-24 15:20:35 +0200 | [diff] [blame] | 536 | i->alg = VNET_CRYPTO_ALG_HMAC_SHA1; |
Damjan Marion | 7c22ff7 | 2019-04-04 12:25:44 +0200 | [diff] [blame] | 537 | i->icv_size = 12; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 538 | |
| 539 | i = &im->integ_algs[IPSEC_INTEG_ALG_SHA_256_96]; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 540 | i->op_id = VNET_CRYPTO_OP_SHA1_HMAC; |
Damjan Marion | d1bed68 | 2019-04-24 15:20:35 +0200 | [diff] [blame] | 541 | i->alg = VNET_CRYPTO_ALG_HMAC_SHA256; |
Damjan Marion | 7c22ff7 | 2019-04-04 12:25:44 +0200 | [diff] [blame] | 542 | i->icv_size = 12; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 543 | |
| 544 | i = &im->integ_algs[IPSEC_INTEG_ALG_SHA_256_128]; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 545 | i->op_id = VNET_CRYPTO_OP_SHA256_HMAC; |
Damjan Marion | d1bed68 | 2019-04-24 15:20:35 +0200 | [diff] [blame] | 546 | i->alg = VNET_CRYPTO_ALG_HMAC_SHA256; |
Damjan Marion | 7c22ff7 | 2019-04-04 12:25:44 +0200 | [diff] [blame] | 547 | i->icv_size = 16; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 548 | |
| 549 | i = &im->integ_algs[IPSEC_INTEG_ALG_SHA_384_192]; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 550 | i->op_id = VNET_CRYPTO_OP_SHA384_HMAC; |
Damjan Marion | 4cb8381 | 2019-04-24 17:32:01 +0200 | [diff] [blame] | 551 | i->alg = VNET_CRYPTO_ALG_HMAC_SHA384; |
Damjan Marion | 7c22ff7 | 2019-04-04 12:25:44 +0200 | [diff] [blame] | 552 | i->icv_size = 24; |
Damjan Marion | 91f17dc | 2019-03-18 18:59:25 +0100 | [diff] [blame] | 553 | |
| 554 | i = &im->integ_algs[IPSEC_INTEG_ALG_SHA_512_256]; |
Damjan Marion | 060bfb9 | 2019-03-29 13:47:54 +0100 | [diff] [blame] | 555 | i->op_id = VNET_CRYPTO_OP_SHA512_HMAC; |
Damjan Marion | d1bed68 | 2019-04-24 15:20:35 +0200 | [diff] [blame] | 556 | i->alg = VNET_CRYPTO_ALG_HMAC_SHA512; |
Damjan Marion | 7c22ff7 | 2019-04-04 12:25:44 +0200 | [diff] [blame] | 557 | i->icv_size = 32; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 558 | |
Neale Ranns | 5ae793a | 2019-04-03 13:36:56 +0000 | [diff] [blame] | 559 | vec_validate_aligned (im->ptd, vlib_num_workers (), CLIB_CACHE_LINE_BYTES); |
Damjan Marion | c59b9a2 | 2019-03-19 15:38:40 +0100 | [diff] [blame] | 560 | |
Neale Ranns | f62a8c0 | 2019-04-02 08:13:33 +0000 | [diff] [blame] | 561 | im->ah4_enc_fq_index = |
| 562 | vlib_frame_queue_main_init (ah4_encrypt_node.index, 0); |
| 563 | im->ah4_dec_fq_index = |
| 564 | vlib_frame_queue_main_init (ah4_decrypt_node.index, 0); |
| 565 | im->ah6_enc_fq_index = |
| 566 | vlib_frame_queue_main_init (ah6_encrypt_node.index, 0); |
| 567 | im->ah6_dec_fq_index = |
| 568 | vlib_frame_queue_main_init (ah6_decrypt_node.index, 0); |
| 569 | |
| 570 | im->esp4_enc_fq_index = |
| 571 | vlib_frame_queue_main_init (esp4_encrypt_node.index, 0); |
| 572 | im->esp4_dec_fq_index = |
| 573 | vlib_frame_queue_main_init (esp4_decrypt_node.index, 0); |
| 574 | im->esp6_enc_fq_index = |
| 575 | vlib_frame_queue_main_init (esp6_encrypt_node.index, 0); |
| 576 | im->esp6_dec_fq_index = |
| 577 | vlib_frame_queue_main_init (esp6_decrypt_node.index, 0); |
| 578 | im->esp4_enc_tun_fq_index = |
| 579 | vlib_frame_queue_main_init (esp4_encrypt_tun_node.index, 0); |
| 580 | im->esp6_enc_tun_fq_index = |
| 581 | vlib_frame_queue_main_init (esp6_encrypt_tun_node.index, 0); |
Neale Ranns | 4a58e49 | 2020-12-21 13:19:10 +0000 | [diff] [blame] | 582 | im->esp_mpls_enc_tun_fq_index = |
| 583 | vlib_frame_queue_main_init (esp_mpls_encrypt_tun_node.index, 0); |
Neale Ranns | f62a8c0 | 2019-04-02 08:13:33 +0000 | [diff] [blame] | 584 | im->esp4_dec_tun_fq_index = |
| 585 | vlib_frame_queue_main_init (esp4_decrypt_tun_node.index, 0); |
| 586 | im->esp6_dec_tun_fq_index = |
| 587 | vlib_frame_queue_main_init (esp6_decrypt_tun_node.index, 0); |
| 588 | |
Fan Zhang | f539578 | 2020-04-29 14:00:03 +0100 | [diff] [blame] | 589 | im->async_mode = 0; |
| 590 | crypto_engine_backend_register_post_node (vm); |
| 591 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 592 | return 0; |
| 593 | } |
| 594 | |
| 595 | VLIB_INIT_FUNCTION (ipsec_init); |
Keith Burns (alagalah) | 166a9d4 | 2016-08-06 11:00:56 -0700 | [diff] [blame] | 596 | |
| 597 | /* |
| 598 | * fd.io coding-style-patch-verification: ON |
| 599 | * |
| 600 | * Local Variables: |
| 601 | * eval: (c-set-style "gnu") |
| 602 | * End: |
| 603 | */ |