55 return VNET_API_ERROR_SYSCALL_ERROR_1;
61 return VNET_API_ERROR_SYSCALL_ERROR_1;
73 sw_if_index, spd_id, spd_index);
77 sw_if_index, is_add, 0, 0);
79 sw_if_index, is_add, 0, 0);
85 sw_if_index, is_add, &config,
sizeof (config));
87 sw_if_index, is_add, &config,
sizeof (config));
102 return VNET_API_ERROR_INVALID_VALUE;
104 return VNET_API_ERROR_INVALID_VALUE;
111 return VNET_API_ERROR_INVALID_VALUE;
115 ipsec_set_interface_spd(vm, k, spd_id, 0);
130 spd_index = spd - im->
spds;
162 clib_warning (
"policy-id %u priority %d is_outbound %u", policy->
id,
165 if (policy->
policy == IPSEC_POLICY_ACTION_PROTECT)
169 return VNET_API_ERROR_SYSCALL_ERROR_1;
176 return VNET_API_ERROR_SYSCALL_ERROR_1;
181 return VNET_API_ERROR_SYSCALL_ERROR_1;
212 if (policy->
policy == IPSEC_POLICY_ACTION_PROTECT)
232 if (policy->
policy == IPSEC_POLICY_ACTION_PROTECT)
259 vp = pool_elt_at_index(spd->policies, i);
260 if (vp->priority != policy->priority)
262 if (vp->is_outbound != policy->is_outbound)
264 if (vp->policy != policy->policy)
266 if (vp->sa_id != policy->sa_id)
268 if (vp->protocol != policy->protocol)
270 if (vp->lport.start != policy->lport.start)
272 if (vp->lport.stop != policy->lport.stop)
274 if (vp->rport.start != policy->rport.start)
276 if (vp->rport.stop != policy->rport.stop)
278 if (vp->is_ipv6 != policy->is_ipv6)
282 if (vp->laddr.start.ip6.as_u64[0] != policy->laddr.start.ip6.as_u64[0])
284 if (vp->laddr.start.ip6.as_u64[1] != policy->laddr.start.ip6.as_u64[1])
286 if (vp->laddr.stop.ip6.as_u64[0] != policy->laddr.stop.ip6.as_u64[0])
288 if (vp->laddr.stop.ip6.as_u64[1] != policy->laddr.stop.ip6.as_u64[1])
290 if (vp->raddr.start.ip6.as_u64[0] != policy->raddr.start.ip6.as_u64[0])
292 if (vp->raddr.start.ip6.as_u64[1] != policy->raddr.start.ip6.as_u64[1])
294 if (vp->raddr.stop.ip6.as_u64[0] != policy->raddr.stop.ip6.as_u64[0])
296 if (vp->laddr.stop.ip6.as_u64[1] != policy->laddr.stop.ip6.as_u64[1])
298 if (policy->is_outbound)
300 vec_foreach_index(j, spd->ipv6_outbound_policies) {
301 if (vec_elt(spd->ipv6_outbound_policies, j) == i) {
302 vec_del1 (spd->ipv6_outbound_policies, j);
309 if (policy->policy == IPSEC_POLICY_ACTION_PROTECT)
311 vec_foreach_index(j, spd->ipv6_inbound_protect_policy_indices) {
312 if (vec_elt(spd->ipv6_inbound_protect_policy_indices, j) == i) {
313 vec_del1 (spd->ipv6_inbound_protect_policy_indices, j);
320 vec_foreach_index(j, spd->ipv6_inbound_policy_discard_and_bypass_indices) {
321 if (vec_elt(spd->ipv6_inbound_policy_discard_and_bypass_indices, j) == i) {
322 vec_del1 (spd->ipv6_inbound_policy_discard_and_bypass_indices, j);
331 if (vp->laddr.start.ip4.as_u32 != policy->laddr.start.ip4.as_u32)
333 if (vp->laddr.stop.ip4.as_u32 != policy->laddr.stop.ip4.as_u32)
335 if (vp->raddr.start.ip4.as_u32 != policy->raddr.start.ip4.as_u32)
337 if (vp->raddr.stop.ip4.as_u32 != policy->raddr.stop.ip4.as_u32)
339 if (policy->is_outbound)
341 vec_foreach_index(j, spd->ipv4_outbound_policies) {
342 if (vec_elt(spd->ipv4_outbound_policies, j) == i) {
343 vec_del1 (spd->ipv4_outbound_policies, j);
350 if (policy->policy == IPSEC_POLICY_ACTION_PROTECT)
352 vec_foreach_index(j, spd->ipv4_inbound_protect_policy_indices) {
353 if (vec_elt(spd->ipv4_inbound_protect_policy_indices, j) == i) {
354 vec_del1 (spd->ipv4_inbound_protect_policy_indices, j);
361 vec_foreach_index(j, spd->ipv4_inbound_policy_discard_and_bypass_indices) {
362 if (vec_elt(spd->ipv4_inbound_policy_discard_and_bypass_indices, j) == i) {
363 vec_del1 (spd->ipv4_inbound_policy_discard_and_bypass_indices, j);
389 pool_foreach(p, spd->policies, ({
390 if (p->policy == IPSEC_POLICY_ACTION_PROTECT)
392 if (p->sa_index == sa_index)
399 if (t->input_sa_index == sa_index)
401 if (t->output_sa_index == sa_index)
411 u32 sa_index,
int is_add)
444 return VNET_API_ERROR_SYSCALL_ERROR_1;
446 return VNET_API_ERROR_SYSCALL_ERROR_1;
455 return VNET_API_ERROR_SYSCALL_ERROR_1;
460 return VNET_API_ERROR_SYSCALL_ERROR_1;
467 sa_index = sa - im->
sad;
471 return VNET_API_ERROR_SYSCALL_ERROR_1;
487 return VNET_API_ERROR_SYSCALL_ERROR_1;
512 return VNET_API_ERROR_SYSCALL_ERROR_1;
528 seed_data.time = time (
NULL);
529 seed_data.pid = getpid ();
530 seed_data.p = (
void *) &seed_data;
532 RAND_seed ((
const void *) &seed_data,
sizeof (seed_data));
538 if (sa->
integ_alg == IPSEC_INTEG_ALG_NONE)
546 if (sa->
crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_128)
548 if (sa->
crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_192)
550 if (sa->
crypto_alg == IPSEC_CRYPTO_ALG_AES_GCM_256)
603 const char *prev_node_name,
u32 * out_node_index,
604 u32 * out_next_index)
611 *out_node_index = node->
index;
618 const char *ah4_encrypt_node_name,
619 const char *ah4_decrypt_node_name,
620 const char *ah6_encrypt_node_name,
621 const char *ah6_decrypt_node_name,
629 ipsec_add_node (vm, ah4_encrypt_node_name,
"ipsec4-output-feature",
631 ipsec_add_node (vm, ah4_decrypt_node_name,
"ipsec4-input-feature",
633 ipsec_add_node (vm, ah6_encrypt_node_name,
"ipsec6-output-feature",
635 ipsec_add_node (vm, ah6_decrypt_node_name,
"ipsec6-input-feature",
646 const char *esp4_encrypt_node_name,
647 const char *esp4_decrypt_node_name,
648 const char *esp6_encrypt_node_name,
649 const char *esp6_decrypt_node_name,
657 ipsec_add_node (vm, esp4_encrypt_node_name,
"ipsec4-output-feature",
659 ipsec_add_node (vm, esp4_decrypt_node_name,
"ipsec4-input-feature",
661 ipsec_add_node (vm, esp6_encrypt_node_name,
"ipsec6-output-feature",
663 ipsec_add_node (vm, esp6_decrypt_node_name,
"ipsec6-input-feature",
u32 * ipv6_inbound_protect_policy_indices
u32 ipsec_register_ah_backend(vlib_main_t *vm, ipsec_main_t *im, const char *name, const char *ah4_encrypt_node_name, const char *ah4_decrypt_node_name, const char *ah6_encrypt_node_name, const char *ah6_decrypt_node_name, check_support_cb_t ah_check_support_cb, add_del_sa_sess_cb_t ah_add_del_sa_sess_cb)
#define hash_set(h, key, value)
u32 esp4_encrypt_next_index
u32 * ipv4_inbound_protect_policy_indices
int ipsec_add_del_policy(vlib_main_t *vm, ipsec_policy_t *policy, int is_add)
u32 esp6_decrypt_node_index
#define hash_unset(h, key)
u32 ah4_decrypt_next_index
vnet_main_t * vnet_get_main(void)
static void ipsec_add_node(vlib_main_t *vm, const char *node_name, const char *prev_node_name, u32 *out_node_index, u32 *out_next_index)
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)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
u32 esp4_decrypt_node_index
ipsec_integ_alg_t integ_alg
u32 ah6_decrypt_next_index
u32 esp6_decrypt_next_index
u32 ah4_encrypt_next_index
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
u32 ah4_encrypt_node_index
u32 esp6_encrypt_node_index
u32 * ipv4_outbound_policies
int ipsec_select_ah_backend(ipsec_main_t *im, u32 backend_idx)
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).
u32 ah6_decrypt_node_index
static uword vlib_node_add_next(vlib_main_t *vm, uword node, uword next_node)
int ipsec_add_del_spd(vlib_main_t *vm, u32 spd_id, int is_add)
uword * spd_index_by_sw_if_index
#define clib_memcpy(d, s, n)
clib_error_t * ipsec_tunnel_if_init(vlib_main_t *vm)
u32 esp6_encrypt_next_index
static clib_error_t * ipsec_check_ah_support(ipsec_sa_t *sa)
u32 ah6_encrypt_node_index
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
u32 esp6_encrypt_node_index
u32 esp4_decrypt_next_index
u32 ah6_encrypt_next_index
int ipsec_select_esp_backend(ipsec_main_t *im, u32 backend_idx)
#define hash_foreach(key_var, value_var, h, body)
#define clib_error_return(e, args...)
check_support_cb_t check_support_cb
ipsec_spd_t * spd_to_sort
clib_error_t *(* add_del_sa_sess_cb_t)(u32 sa_index, u8 is_add)
#define vlib_call_init_function(vm, x)
u32 esp6_decrypt_node_index
ipsec_policy_t * policies
u32 ah4_decrypt_node_index
u32 error_drop_node_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
u32 esp4_encrypt_node_index
clib_error_t * ipsec_check_support_cb(ipsec_main_t *im, ipsec_sa_t *sa)
u32 ah4_decrypt_next_index
#define pool_put(P, E)
Free an object E in pool P.
u32 esp4_encrypt_node_index
uword * spd_index_by_spd_id
#define pool_free(p)
Free a pool.
u32 ah4_decrypt_node_index
clib_error_t * ipsec_add_del_sa_sess_cb(ipsec_main_t *im, u32 sa_index, u8 is_add)
u32 ah6_encrypt_next_index
ipsec_ah_backend_t * ah_backends
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 esp4_encrypt_next_index
#define clib_warning(format, args...)
u32 ah4_encrypt_next_index
uword * sa_index_by_sa_id
clib_error_t * ipsec_call_add_del_callbacks(ipsec_main_t *im, ipsec_sa_t *sa, u32 sa_index, int is_add)
int ipsec_set_sa_key(vlib_main_t *vm, ipsec_sa_t *sa_update)
u32 esp6_decrypt_next_index
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
static clib_error_t * ipsec_init(vlib_main_t *vm)
u32 esp6_encrypt_next_index
static clib_error_t * ipsec_check_esp_support(ipsec_sa_t *sa)
clib_error_t *(* check_support_cb_t)(ipsec_sa_t *sa)
#define hash_create(elts, value_bytes)
u8 ipsec_is_sa_used(u32 sa_index)
u32 ipsec_register_esp_backend(vlib_main_t *vm, ipsec_main_t *im, const char *name, const char *esp4_encrypt_node_name, const char *esp4_decrypt_node_name, const char *esp6_encrypt_node_name, const char *esp6_decrypt_node_name, check_support_cb_t esp_check_support_cb, add_del_sa_sess_cb_t esp_add_del_sa_sess_cb)
u32 ah4_encrypt_node_index
u32 esp4_decrypt_node_index
ipsec_protocol_t protocol
add_del_sa_sess_cb_t add_del_sa_sess_cb
u32 ah6_decrypt_node_index
u32 ah6_encrypt_node_index
u32 ah6_decrypt_next_index
check_support_cb_t check_support_cb
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
u32 esp4_decrypt_next_index
clib_error_t * ikev2_init(vlib_main_t *vm)
ipsec_crypto_alg_t crypto_alg
static vlib_thread_main_t * vlib_get_thread_main()
static int ipsec_spd_entry_sort(void *a1, void *a2)
add_del_sa_sess_cb_t add_del_sa_sess_cb
#define pool_foreach_index(i, v, body)
Iterate pool by index.
ipsec_esp_backend_t * esp_backends
#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)
static uword pool_elts(void *v)
Number of active elements in a pool.