53 return VNET_API_ERROR_SYSCALL_ERROR_1;
59 return VNET_API_ERROR_SYSCALL_ERROR_1;
71 sw_if_index, spd_id, spd_index);
81 is_add, &config,
sizeof (config));
83 is_add, &config,
sizeof (config));
98 return VNET_API_ERROR_INVALID_VALUE;
100 return VNET_API_ERROR_INVALID_VALUE;
107 return VNET_API_ERROR_INVALID_VALUE;
111 ipsec_set_interface_spd(vm, k, spd_id, 0);
125 memset (spd, 0,
sizeof (*spd));
126 spd_index = spd - im->
spds;
144 p1 = pool_elt_at_index(spd->policies, *id1);
145 p2 = pool_elt_at_index(spd->policies, *id2);
147 return p2->priority - p1->priority;
163 clib_warning (
"policy-id %u priority %d is_outbound %u", policy->
id,
166 if (policy->
policy == IPSEC_POLICY_ACTION_PROTECT)
170 return VNET_API_ERROR_SYSCALL_ERROR_1;
177 return VNET_API_ERROR_SYSCALL_ERROR_1;
182 return VNET_API_ERROR_SYSCALL_ERROR_1;
213 if (policy->
policy == IPSEC_POLICY_ACTION_PROTECT)
235 if (policy->
policy == IPSEC_POLICY_ACTION_PROTECT)
263 vp = pool_elt_at_index(spd->policies, i);
264 if (vp->priority != policy->priority)
266 if (vp->is_outbound != policy->is_outbound)
268 if (vp->policy != policy->policy)
270 if (vp->sa_id != policy->sa_id)
272 if (vp->protocol != policy->protocol)
274 if (vp->lport.start != policy->lport.start)
276 if (vp->lport.stop != policy->lport.stop)
278 if (vp->rport.start != policy->rport.start)
280 if (vp->rport.stop != policy->rport.stop)
282 if (vp->is_ipv6 != policy->is_ipv6)
286 if (vp->laddr.start.ip6.as_u64[0] != policy->laddr.start.ip6.as_u64[0])
288 if (vp->laddr.start.ip6.as_u64[1] != policy->laddr.start.ip6.as_u64[1])
290 if (vp->laddr.stop.ip6.as_u64[0] != policy->laddr.stop.ip6.as_u64[0])
292 if (vp->laddr.stop.ip6.as_u64[1] != policy->laddr.stop.ip6.as_u64[1])
294 if (vp->raddr.start.ip6.as_u64[0] != policy->raddr.start.ip6.as_u64[0])
296 if (vp->raddr.start.ip6.as_u64[1] != policy->raddr.start.ip6.as_u64[1])
298 if (vp->raddr.stop.ip6.as_u64[0] != policy->raddr.stop.ip6.as_u64[0])
300 if (vp->laddr.stop.ip6.as_u64[1] != policy->laddr.stop.ip6.as_u64[1])
302 if (policy->is_outbound)
304 vec_foreach_index(j, spd->ipv6_outbound_policies) {
305 if (vec_elt(spd->ipv6_outbound_policies, j) == i) {
306 vec_del1 (spd->ipv6_outbound_policies, j);
313 if (policy->policy == IPSEC_POLICY_ACTION_PROTECT)
315 vec_foreach_index(j, spd->ipv6_inbound_protect_policy_indices) {
316 if (vec_elt(spd->ipv6_inbound_protect_policy_indices, j) == i) {
317 vec_del1 (spd->ipv6_inbound_protect_policy_indices, j);
324 vec_foreach_index(j, spd->ipv6_inbound_policy_discard_and_bypass_indices) {
325 if (vec_elt(spd->ipv6_inbound_policy_discard_and_bypass_indices, j) == i) {
326 vec_del1 (spd->ipv6_inbound_policy_discard_and_bypass_indices, j);
335 if (vp->laddr.start.ip4.as_u32 != policy->laddr.start.ip4.as_u32)
337 if (vp->laddr.stop.ip4.as_u32 != policy->laddr.stop.ip4.as_u32)
339 if (vp->raddr.start.ip4.as_u32 != policy->raddr.start.ip4.as_u32)
341 if (vp->raddr.stop.ip4.as_u32 != policy->raddr.stop.ip4.as_u32)
343 if (policy->is_outbound)
345 vec_foreach_index(j, spd->ipv4_outbound_policies) {
346 if (vec_elt(spd->ipv4_outbound_policies, j) == i) {
347 vec_del1 (spd->ipv4_outbound_policies, j);
354 if (policy->policy == IPSEC_POLICY_ACTION_PROTECT)
356 vec_foreach_index(j, spd->ipv4_inbound_protect_policy_indices) {
357 if (vec_elt(spd->ipv4_inbound_protect_policy_indices, j) == i) {
358 vec_del1 (spd->ipv4_inbound_protect_policy_indices, j);
365 vec_foreach_index(j, spd->ipv4_inbound_policy_discard_and_bypass_indices) {
366 if (vec_elt(spd->ipv4_inbound_policy_discard_and_bypass_indices, j) == i) {
367 vec_del1 (spd->ipv4_inbound_policy_discard_and_bypass_indices, j);
393 pool_foreach(p, spd->policies, ({
394 if (p->policy == IPSEC_POLICY_ACTION_PROTECT)
396 if (p->sa_index == sa_index)
403 if (t->input_sa_index == sa_index)
405 if (t->output_sa_index == sa_index)
426 return VNET_API_ERROR_SYSCALL_ERROR_1;
428 return VNET_API_ERROR_SYSCALL_ERROR_1;
437 return VNET_API_ERROR_SYSCALL_ERROR_1;
444 return VNET_API_ERROR_SYSCALL_ERROR_1;
452 sa_index = sa - im->
sad;
458 return VNET_API_ERROR_SYSCALL_ERROR_1;
475 return VNET_API_ERROR_SYSCALL_ERROR_1;
502 return VNET_API_ERROR_SYSCALL_ERROR_1;
519 seed_data.time = time (
NULL);
520 seed_data.pid = getpid ();
521 seed_data.p = (
void *) &seed_data;
523 RAND_seed ((
const void *) &seed_data,
sizeof (seed_data));
529 if (sa->
crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
531 if (sa->
integ_alg == IPSEC_INTEG_ALG_NONE)
547 memset (im, 0,
sizeof (im[0]));
u32 * ipv6_inbound_protect_policy_indices
#define hash_set(h, key, value)
u32 ah_decrypt_next_index
u32 * ipv4_inbound_protect_policy_indices
u32 ah_decrypt_node_index
int ipsec_add_del_policy(vlib_main_t *vm, ipsec_policy_t *policy, int is_add)
#define hash_unset(h, key)
vnet_main_t * vnet_get_main(void)
static void ipsec_rand_seed(void)
int ipsec_set_interface_spd(vlib_main_t *vm, u32 sw_if_index, u32 spd_id, int is_add)
u32 ah_encrypt_node_index
ipsec_integ_alg_t integ_alg
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
u32 * ipv4_outbound_policies
u32 ipsec_get_sa_index_by_sa_id(u32 sa_id)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
int ipsec_add_del_spd(vlib_main_t *vm, u32 spd_id, int is_add)
uword * spd_index_by_sw_if_index
clib_error_t * ipsec_tunnel_if_init(vlib_main_t *vm)
u32 esp_encrypt_next_index
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
#define hash_foreach(key_var, value_var, h, body)
#define clib_error_return(e, args...)
ipsec_main_callbacks_t cb
u32 ah_encrypt_next_index
#define vlib_call_init_function(vm, x)
ipsec_policy_t * policies
u32 error_drop_node_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
clib_error_t *(* check_support_cb)(ipsec_sa_t *sa)
#define pool_put(P, E)
Free an object E in pool P.
uword * spd_index_by_spd_id
#define pool_free(p)
Free a pool.
u32 esp_encrypt_node_index
int ipsec_add_del_sa(vlib_main_t *vm, ipsec_sa_t *new_sa, int is_add)
clib_error_t * ipsec_cli_init(vlib_main_t *vm)
#define vec_free(V)
Free vector's memory (no header).
u32 esp_decrypt_next_index
#define clib_warning(format, args...)
#define clib_memcpy(a, b, c)
uword * sa_index_by_sa_id
int ipsec_set_sa_key(vlib_main_t *vm, ipsec_sa_t *sa_update)
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
static clib_error_t * ipsec_init(vlib_main_t *vm)
#define hash_create(elts, value_bytes)
u8 ipsec_is_sa_used(u32 sa_index)
u32 * ipv4_inbound_policy_discard_and_bypass_indices
u32 * ipv6_inbound_policy_discard_and_bypass_indices
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
static void ipsec_proto_init()
u32 * ipv6_outbound_policies
static clib_error_t * ipsec_check_support(ipsec_sa_t *sa)
clib_error_t * ikev2_init(vlib_main_t *vm)
ipsec_crypto_alg_t crypto_alg
static vlib_thread_main_t * vlib_get_thread_main()
clib_error_t *(* add_del_sa_sess_cb)(u32 sa_index, u8 is_add)
static int ipsec_spd_entry_sort(void *a1, void *a2)
#define pool_foreach_index(i, v, body)
Iterate pool by index.
#define CLIB_CACHE_LINE_BYTES
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
u32 esp_decrypt_node_index