blob: 9359a3b772ed07cd4d792c0c35feb74e376bb68a [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001/*
2 * ipsec_if.c : IPSec interface support
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
22#include <vnet/ipsec/ipsec.h>
Sergio Gonzalez Monroya10f62b2016-11-25 13:36:12 +000023#include <vnet/ipsec/esp.h>
Ed Warnickecb9cada2015-12-08 15:45:58 -070024
Matthew Smith2838a232016-06-21 16:05:09 -050025void vl_api_rpc_call_main_thread (void *fp, u8 * data, u32 data_length);
26
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -070027static u8 *
28format_ipsec_name (u8 * s, va_list * args)
Ed Warnickecb9cada2015-12-08 15:45:58 -070029{
30 u32 dev_instance = va_arg (*args, u32);
31 return format (s, "ipsec%d", dev_instance);
32}
33
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -070034static uword
35dummy_interface_tx (vlib_main_t * vm,
36 vlib_node_runtime_t * node, vlib_frame_t * frame)
Ed Warnickecb9cada2015-12-08 15:45:58 -070037{
38 clib_warning ("you shouldn't be here, leaking buffers...");
39 return frame->n_vectors;
40}
41
Sergio Gonzalez Monroyd04b60b2017-01-20 15:35:23 +000042static clib_error_t *
43ipsec_admin_up_down_function (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
44{
45 ipsec_main_t *im = &ipsec_main;
46 clib_error_t *err = 0;
47 ipsec_tunnel_if_t *t;
48 vnet_hw_interface_t *hi;
49 ipsec_sa_t *sa;
50
51 hi = vnet_get_hw_interface (vnm, hw_if_index);
52 if (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)
53 {
54 t = pool_elt_at_index (im->tunnel_interfaces, hi->hw_instance);
55 ASSERT (im->cb.check_support_cb);
56 sa = pool_elt_at_index (im->sad, t->input_sa_index);
57 err = im->cb.check_support_cb (sa);
58 if (err)
59 return err;
60
61 sa = pool_elt_at_index (im->sad, t->output_sa_index);
62 err = im->cb.check_support_cb (sa);
63 if (err)
64 return err;
65
Radu Nicolau3f903392017-01-30 14:33:39 +000066 vnet_hw_interface_set_flags (vnm, hw_if_index,
Sergio Gonzalez Monroyd04b60b2017-01-20 15:35:23 +000067 VNET_HW_INTERFACE_FLAG_LINK_UP);
68 }
69 else
Radu Nicolau3f903392017-01-30 14:33:39 +000070 vnet_hw_interface_set_flags (vnm, hw_if_index, 0 /* down */ );
Sergio Gonzalez Monroyd04b60b2017-01-20 15:35:23 +000071
72 return /* no error */ 0;
73}
74
Neale Rannsb80c5362016-10-08 13:03:40 +010075/* *INDENT-OFF* */
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -070076VNET_DEVICE_CLASS (ipsec_device_class, static) =
77{
Neale Rannsb80c5362016-10-08 13:03:40 +010078 .name = "IPSec",
79 .format_device_name = format_ipsec_name,
80 .format_tx_trace = format_ipsec_if_output_trace,
81 .tx_function = dummy_interface_tx,
Sergio Gonzalez Monroyd04b60b2017-01-20 15:35:23 +000082 .admin_up_down_function = ipsec_admin_up_down_function,
Neale Rannsb80c5362016-10-08 13:03:40 +010083};
84/* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -070085
Neale Rannsb80c5362016-10-08 13:03:40 +010086/* *INDENT-OFF* */
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -070087VNET_HW_INTERFACE_CLASS (ipsec_hw_class) =
88{
Neale Rannsb80c5362016-10-08 13:03:40 +010089 .name = "IPSec",
90 .build_rewrite = default_build_rewrite,
Matthew Smith922549a2017-05-24 16:18:27 -050091 .flags = VNET_HW_INTERFACE_CLASS_FLAG_P2P,
Neale Rannsb80c5362016-10-08 13:03:40 +010092};
93/* *INDENT-ON* */
Matthew Smith2838a232016-06-21 16:05:09 -050094
95static int
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -070096ipsec_add_del_tunnel_if_rpc_callback (ipsec_add_del_tunnel_args_t * a)
Matthew Smith2838a232016-06-21 16:05:09 -050097{
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -070098 vnet_main_t *vnm = vnet_get_main ();
Damjan Marion586afd72017-04-05 19:18:20 +020099 ASSERT (vlib_get_thread_index () == 0);
Matthew Smith2838a232016-06-21 16:05:09 -0500100
Matthew Smithe04d09d2017-05-14 21:47:18 -0500101 return ipsec_add_del_tunnel_if_internal (vnm, a, NULL);
Matthew Smith2838a232016-06-21 16:05:09 -0500102}
103
104int
105ipsec_add_del_tunnel_if (ipsec_add_del_tunnel_args_t * args)
106{
107 vl_api_rpc_call_main_thread (ipsec_add_del_tunnel_if_rpc_callback,
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700108 (u8 *) args, sizeof (*args));
Matthew Smith2838a232016-06-21 16:05:09 -0500109 return 0;
110}
111
112int
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700113ipsec_add_del_tunnel_if_internal (vnet_main_t * vnm,
Matthew Smithe04d09d2017-05-14 21:47:18 -0500114 ipsec_add_del_tunnel_args_t * args,
115 u32 * sw_if_index)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700116{
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700117 ipsec_tunnel_if_t *t;
118 ipsec_main_t *im = &ipsec_main;
Matthew Smithe04d09d2017-05-14 21:47:18 -0500119 vnet_hw_interface_t *hi = NULL;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700120 u32 hw_if_index = ~0;
121 uword *p;
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700122 ipsec_sa_t *sa;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700123
124 u64 key = (u64) args->remote_ip.as_u32 << 32 | (u64) args->remote_spi;
125 p = hash_get (im->ipsec_if_pool_index_by_key, key);
126
127 if (args->is_add)
128 {
129 /* check if same src/dst pair exists */
130 if (p)
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700131 return VNET_API_ERROR_INVALID_VALUE;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700132
133 pool_get_aligned (im->tunnel_interfaces, t, CLIB_CACHE_LINE_BYTES);
134 memset (t, 0, sizeof (*t));
135
136 pool_get (im->sad, sa);
137 memset (sa, 0, sizeof (*sa));
138 t->input_sa_index = sa - im->sad;
139 sa->spi = args->remote_spi;
140 sa->tunnel_src_addr.ip4.as_u32 = args->remote_ip.as_u32;
141 sa->tunnel_dst_addr.ip4.as_u32 = args->local_ip.as_u32;
142 sa->is_tunnel = 1;
143 sa->use_esn = args->esn;
144 sa->use_anti_replay = args->anti_replay;
Matthew Smith2838a232016-06-21 16:05:09 -0500145 sa->integ_alg = args->integ_alg;
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700146 if (args->remote_integ_key_len <= sizeof (args->remote_integ_key))
147 {
148 sa->integ_key_len = args->remote_integ_key_len;
149 clib_memcpy (sa->integ_key, args->remote_integ_key,
150 args->remote_integ_key_len);
151 }
Matthew Smith2838a232016-06-21 16:05:09 -0500152 sa->crypto_alg = args->crypto_alg;
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700153 if (args->remote_crypto_key_len <= sizeof (args->remote_crypto_key))
154 {
155 sa->crypto_key_len = args->remote_crypto_key_len;
156 clib_memcpy (sa->crypto_key, args->remote_crypto_key,
157 args->remote_crypto_key_len);
158 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700159
Sergio Gonzalez Monroyd04b60b2017-01-20 15:35:23 +0000160 if (im->cb.add_del_sa_sess_cb &&
161 im->cb.add_del_sa_sess_cb (t->input_sa_index, args->is_add) < 0)
162 return VNET_API_ERROR_SYSCALL_ERROR_1;
Sergio Gonzalez Monroya10f62b2016-11-25 13:36:12 +0000163
Ed Warnickecb9cada2015-12-08 15:45:58 -0700164 pool_get (im->sad, sa);
165 memset (sa, 0, sizeof (*sa));
166 t->output_sa_index = sa - im->sad;
167 sa->spi = args->local_spi;
168 sa->tunnel_src_addr.ip4.as_u32 = args->local_ip.as_u32;
169 sa->tunnel_dst_addr.ip4.as_u32 = args->remote_ip.as_u32;
170 sa->is_tunnel = 1;
171 sa->seq = 1;
172 sa->use_esn = args->esn;
173 sa->use_anti_replay = args->anti_replay;
Matthew Smith2838a232016-06-21 16:05:09 -0500174 sa->integ_alg = args->integ_alg;
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700175 if (args->local_integ_key_len <= sizeof (args->local_integ_key))
176 {
177 sa->integ_key_len = args->local_integ_key_len;
178 clib_memcpy (sa->integ_key, args->local_integ_key,
179 args->local_integ_key_len);
180 }
Matthew Smith2838a232016-06-21 16:05:09 -0500181 sa->crypto_alg = args->crypto_alg;
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700182 if (args->local_crypto_key_len <= sizeof (args->local_crypto_key))
183 {
184 sa->crypto_key_len = args->local_crypto_key_len;
185 clib_memcpy (sa->crypto_key, args->local_crypto_key,
186 args->local_crypto_key_len);
187 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700188
Sergio Gonzalez Monroyd04b60b2017-01-20 15:35:23 +0000189 if (im->cb.add_del_sa_sess_cb &&
190 im->cb.add_del_sa_sess_cb (t->output_sa_index, args->is_add) < 0)
191 return VNET_API_ERROR_SYSCALL_ERROR_1;
Sergio Gonzalez Monroya10f62b2016-11-25 13:36:12 +0000192
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700193 hash_set (im->ipsec_if_pool_index_by_key, key,
194 t - im->tunnel_interfaces);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700195
196 if (vec_len (im->free_tunnel_if_indices) > 0)
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700197 {
198 hw_if_index =
199 im->free_tunnel_if_indices[vec_len (im->free_tunnel_if_indices) -
200 1];
201 _vec_len (im->free_tunnel_if_indices) -= 1;
202 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700203 else
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700204 {
205 hw_if_index =
206 vnet_register_interface (vnm, ipsec_device_class.index,
207 t - im->tunnel_interfaces,
208 ipsec_hw_class.index,
209 t - im->tunnel_interfaces);
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700210 }
Matthew Smithe04d09d2017-05-14 21:47:18 -0500211
212 hi = vnet_get_hw_interface (vnm, hw_if_index);
213 hi->output_node_index = ipsec_if_output_node.index;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700214 t->hw_if_index = hw_if_index;
215
216 /*1st interface, register protocol */
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700217 if (pool_elts (im->tunnel_interfaces) == 1)
218 ip4_register_protocol (IP_PROTOCOL_IPSEC_ESP,
219 ipsec_if_input_node.index);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700220
Ed Warnickecb9cada2015-12-08 15:45:58 -0700221 }
222 else
223 {
Matthew Smith01034be2017-05-16 11:51:18 -0500224 vnet_interface_main_t *vim = &vnm->interface_main;
225
Ed Warnickecb9cada2015-12-08 15:45:58 -0700226 /* check if exists */
227 if (!p)
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700228 return VNET_API_ERROR_INVALID_VALUE;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700229
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700230 t = pool_elt_at_index (im->tunnel_interfaces, p[0]);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700231 hi = vnet_get_hw_interface (vnm, t->hw_if_index);
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700232 vnet_sw_interface_set_flags (vnm, hi->sw_if_index, 0); /* admin down */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700233 vec_add1 (im->free_tunnel_if_indices, t->hw_if_index);
234
Matthew Smith01034be2017-05-16 11:51:18 -0500235 vnet_interface_counter_lock (vim);
236 vlib_zero_combined_counter (vim->combined_sw_if_counters +
237 VNET_INTERFACE_COUNTER_TX, hi->sw_if_index);
238 vlib_zero_combined_counter (vim->combined_sw_if_counters +
239 VNET_INTERFACE_COUNTER_RX, hi->sw_if_index);
240 vnet_interface_counter_unlock (vim);
241
Ed Warnickecb9cada2015-12-08 15:45:58 -0700242 /* delete input and output SA */
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700243 sa = pool_elt_at_index (im->sad, t->input_sa_index);
Sergio Gonzalez Monroya10f62b2016-11-25 13:36:12 +0000244
Sergio Gonzalez Monroyd04b60b2017-01-20 15:35:23 +0000245 if (im->cb.add_del_sa_sess_cb &&
246 im->cb.add_del_sa_sess_cb (t->input_sa_index, args->is_add) < 0)
Sergio Gonzalez Monroya10f62b2016-11-25 13:36:12 +0000247 return VNET_API_ERROR_SYSCALL_ERROR_1;
248
Ed Warnickecb9cada2015-12-08 15:45:58 -0700249 pool_put (im->sad, sa);
Sergio Gonzalez Monroya10f62b2016-11-25 13:36:12 +0000250
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700251 sa = pool_elt_at_index (im->sad, t->output_sa_index);
Sergio Gonzalez Monroya10f62b2016-11-25 13:36:12 +0000252
Sergio Gonzalez Monroyd04b60b2017-01-20 15:35:23 +0000253 if (im->cb.add_del_sa_sess_cb &&
254 im->cb.add_del_sa_sess_cb (t->output_sa_index, args->is_add) < 0)
Sergio Gonzalez Monroya10f62b2016-11-25 13:36:12 +0000255 return VNET_API_ERROR_SYSCALL_ERROR_1;
256
Ed Warnickecb9cada2015-12-08 15:45:58 -0700257 pool_put (im->sad, sa);
258
259 hash_unset (im->ipsec_if_pool_index_by_key, key);
260 pool_put (im->tunnel_interfaces, t);
261 }
Matthew Smithe04d09d2017-05-14 21:47:18 -0500262
263 if (sw_if_index)
264 *sw_if_index = hi->sw_if_index;
265
Ed Warnickecb9cada2015-12-08 15:45:58 -0700266 return 0;
267}
268
269int
Matus Fabian694265d2016-08-10 01:55:36 -0700270ipsec_add_del_ipsec_gre_tunnel (vnet_main_t * vnm,
271 ipsec_add_del_ipsec_gre_tunnel_args_t * args)
272{
273 ipsec_tunnel_if_t *t = 0;
274 ipsec_main_t *im = &ipsec_main;
275 uword *p;
276 ipsec_sa_t *sa;
277 u64 key;
278 u32 isa, osa;
279
280 p = hash_get (im->sa_index_by_sa_id, args->local_sa_id);
281 if (!p)
282 return VNET_API_ERROR_INVALID_VALUE;
283 isa = p[0];
284
285 p = hash_get (im->sa_index_by_sa_id, args->remote_sa_id);
286 if (!p)
287 return VNET_API_ERROR_INVALID_VALUE;
288 osa = p[0];
289 sa = pool_elt_at_index (im->sad, p[0]);
290
291 if (sa->is_tunnel)
292 key = (u64) sa->tunnel_dst_addr.ip4.as_u32 << 32 | (u64) sa->spi;
293 else
294 key = (u64) args->remote_ip.as_u32 << 32 | (u64) sa->spi;
295
296 p = hash_get (im->ipsec_if_pool_index_by_key, key);
297
298 if (args->is_add)
299 {
300 /* check if same src/dst pair exists */
301 if (p)
302 return VNET_API_ERROR_INVALID_VALUE;
303
304 pool_get_aligned (im->tunnel_interfaces, t, CLIB_CACHE_LINE_BYTES);
305 memset (t, 0, sizeof (*t));
306
307 t->input_sa_index = isa;
308 t->output_sa_index = osa;
309 t->hw_if_index = ~0;
310 hash_set (im->ipsec_if_pool_index_by_key, key,
311 t - im->tunnel_interfaces);
312
313 /*1st interface, register protocol */
314 if (pool_elts (im->tunnel_interfaces) == 1)
315 ip4_register_protocol (IP_PROTOCOL_IPSEC_ESP,
316 ipsec_if_input_node.index);
317 }
318 else
319 {
320 /* check if exists */
321 if (!p)
322 return VNET_API_ERROR_INVALID_VALUE;
323
324 t = pool_elt_at_index (im->tunnel_interfaces, p[0]);
325 hash_unset (im->ipsec_if_pool_index_by_key, key);
326 pool_put (im->tunnel_interfaces, t);
327 }
328 return 0;
329}
330
331int
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700332ipsec_set_interface_key (vnet_main_t * vnm, u32 hw_if_index,
333 ipsec_if_set_key_type_t type, u8 alg, u8 * key)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700334{
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700335 ipsec_main_t *im = &ipsec_main;
336 vnet_hw_interface_t *hi;
337 ipsec_tunnel_if_t *t;
338 ipsec_sa_t *sa;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700339
340 hi = vnet_get_hw_interface (vnm, hw_if_index);
341 t = pool_elt_at_index (im->tunnel_interfaces, hi->dev_instance);
342
343 if (type == IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO)
344 {
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700345 sa = pool_elt_at_index (im->sad, t->output_sa_index);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700346 sa->crypto_alg = alg;
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700347 sa->crypto_key_len = vec_len (key);
348 clib_memcpy (sa->crypto_key, key, vec_len (key));
Sergio Gonzalez Monroya10f62b2016-11-25 13:36:12 +0000349
Sergio Gonzalez Monroyd04b60b2017-01-20 15:35:23 +0000350 if (im->cb.add_del_sa_sess_cb &&
351 im->cb.add_del_sa_sess_cb (t->output_sa_index, 0) < 0)
Sergio Gonzalez Monroya10f62b2016-11-25 13:36:12 +0000352 return VNET_API_ERROR_SYSCALL_ERROR_1;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700353 }
354 else if (type == IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG)
355 {
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700356 sa = pool_elt_at_index (im->sad, t->output_sa_index);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700357 sa->integ_alg = alg;
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700358 sa->integ_key_len = vec_len (key);
359 clib_memcpy (sa->integ_key, key, vec_len (key));
Sergio Gonzalez Monroya10f62b2016-11-25 13:36:12 +0000360
Sergio Gonzalez Monroyd04b60b2017-01-20 15:35:23 +0000361 if (im->cb.add_del_sa_sess_cb &&
362 im->cb.add_del_sa_sess_cb (t->output_sa_index, 0) < 0)
Sergio Gonzalez Monroya10f62b2016-11-25 13:36:12 +0000363 return VNET_API_ERROR_SYSCALL_ERROR_1;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700364 }
365 else if (type == IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO)
366 {
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700367 sa = pool_elt_at_index (im->sad, t->input_sa_index);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700368 sa->crypto_alg = alg;
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700369 sa->crypto_key_len = vec_len (key);
370 clib_memcpy (sa->crypto_key, key, vec_len (key));
Sergio Gonzalez Monroya10f62b2016-11-25 13:36:12 +0000371
Sergio Gonzalez Monroyd04b60b2017-01-20 15:35:23 +0000372 if (im->cb.add_del_sa_sess_cb &&
373 im->cb.add_del_sa_sess_cb (t->input_sa_index, 0) < 0)
Sergio Gonzalez Monroya10f62b2016-11-25 13:36:12 +0000374 return VNET_API_ERROR_SYSCALL_ERROR_1;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700375 }
376 else if (type == IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG)
377 {
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700378 sa = pool_elt_at_index (im->sad, t->input_sa_index);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700379 sa->integ_alg = alg;
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700380 sa->integ_key_len = vec_len (key);
381 clib_memcpy (sa->integ_key, key, vec_len (key));
Sergio Gonzalez Monroya10f62b2016-11-25 13:36:12 +0000382
Sergio Gonzalez Monroyd04b60b2017-01-20 15:35:23 +0000383 if (im->cb.add_del_sa_sess_cb &&
384 im->cb.add_del_sa_sess_cb (t->input_sa_index, 0) < 0)
Sergio Gonzalez Monroya10f62b2016-11-25 13:36:12 +0000385 return VNET_API_ERROR_SYSCALL_ERROR_1;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700386 }
387 else
388 return VNET_API_ERROR_INVALID_VALUE;
389
390 return 0;
391}
392
393
394clib_error_t *
395ipsec_tunnel_if_init (vlib_main_t * vm)
396{
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700397 ipsec_main_t *im = &ipsec_main;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700398
399 im->ipsec_if_pool_index_by_key = hash_create (0, sizeof (uword));
400
401 return 0;
402}
403
404VLIB_INIT_FUNCTION (ipsec_tunnel_if_init);
405
Keith Burns (alagalah)166a9d42016-08-06 11:00:56 -0700406
407/*
408 * fd.io coding-style-patch-verification: ON
409 *
410 * Local Variables:
411 * eval: (c-set-style "gnu")
412 * End:
413 */