52 return VNET_API_ERROR_SYSCALL_ERROR_1;
58 return VNET_API_ERROR_SYSCALL_ERROR_1;
70 sw_if_index, spd_id, spd_index);
74 INTF_OUTPUT_FEAT_IPSEC, is_add);
114 return VNET_API_ERROR_INVALID_VALUE;
116 return VNET_API_ERROR_INVALID_VALUE;
123 return VNET_API_ERROR_INVALID_VALUE;
127 ipsec_set_interface_spd(vm, k, spd_id, 0);
141 memset (spd, 0,
sizeof (*spd));
142 spd_index = spd - im->
spds;
160 p1 = pool_elt_at_index(spd->policies, *id1);
161 p2 = pool_elt_at_index(spd->policies, *id2);
163 return p2->priority - p1->priority;
179 clib_warning (
"policy-id %u priority %d is_outbound %u", policy->
id,
182 if (policy->
policy == IPSEC_POLICY_ACTION_PROTECT)
186 return VNET_API_ERROR_SYSCALL_ERROR_1;
193 return VNET_API_ERROR_SYSCALL_ERROR_1;
198 return VNET_API_ERROR_SYSCALL_ERROR_1;
229 if (policy->
policy == IPSEC_POLICY_ACTION_PROTECT)
251 if (policy->
policy == IPSEC_POLICY_ACTION_PROTECT)
279 vp = pool_elt_at_index(spd->policies, i);
280 if (vp->priority != policy->priority)
282 if (vp->is_outbound != policy->is_outbound)
284 if (vp->policy != policy->policy)
286 if (vp->sa_id != policy->sa_id)
288 if (vp->protocol != policy->protocol)
290 if (vp->lport.start != policy->lport.start)
292 if (vp->lport.stop != policy->lport.stop)
294 if (vp->rport.start != policy->rport.start)
296 if (vp->rport.stop != policy->rport.stop)
298 if (vp->is_ipv6 != policy->is_ipv6)
302 if (vp->laddr.start.ip6.as_u64[0] != policy->laddr.start.ip6.as_u64[0])
304 if (vp->laddr.start.ip6.as_u64[1] != policy->laddr.start.ip6.as_u64[1])
306 if (vp->laddr.stop.ip6.as_u64[0] != policy->laddr.stop.ip6.as_u64[0])
308 if (vp->laddr.stop.ip6.as_u64[1] != policy->laddr.stop.ip6.as_u64[1])
310 if (vp->raddr.start.ip6.as_u64[0] != policy->raddr.start.ip6.as_u64[0])
312 if (vp->raddr.start.ip6.as_u64[1] != policy->raddr.start.ip6.as_u64[1])
314 if (vp->raddr.stop.ip6.as_u64[0] != policy->raddr.stop.ip6.as_u64[0])
316 if (vp->laddr.stop.ip6.as_u64[1] != policy->laddr.stop.ip6.as_u64[1])
318 if (policy->is_outbound)
320 vec_foreach_index(j, spd->ipv6_outbound_policies) {
321 if (vec_elt(spd->ipv6_outbound_policies, j) == i) {
322 vec_del1 (spd->ipv6_outbound_policies, j);
329 if (policy->policy == IPSEC_POLICY_ACTION_PROTECT)
331 vec_foreach_index(j, spd->ipv6_inbound_protect_policy_indices) {
332 if (vec_elt(spd->ipv6_inbound_protect_policy_indices, j) == i) {
333 vec_del1 (spd->ipv6_inbound_protect_policy_indices, j);
340 vec_foreach_index(j, spd->ipv6_inbound_policy_discard_and_bypass_indices) {
341 if (vec_elt(spd->ipv6_inbound_policy_discard_and_bypass_indices, j) == i) {
342 vec_del1 (spd->ipv6_inbound_policy_discard_and_bypass_indices, j);
351 if (vp->laddr.start.ip4.as_u32 != policy->laddr.start.ip4.as_u32)
353 if (vp->laddr.stop.ip4.as_u32 != policy->laddr.stop.ip4.as_u32)
355 if (vp->raddr.start.ip4.as_u32 != policy->raddr.start.ip4.as_u32)
357 if (vp->raddr.stop.ip4.as_u32 != policy->raddr.stop.ip4.as_u32)
359 if (policy->is_outbound)
361 vec_foreach_index(j, spd->ipv4_outbound_policies) {
362 if (vec_elt(spd->ipv4_outbound_policies, j) == i) {
363 vec_del1 (spd->ipv4_outbound_policies, j);
370 if (policy->policy == IPSEC_POLICY_ACTION_PROTECT)
372 vec_foreach_index(j, spd->ipv4_inbound_protect_policy_indices) {
373 if (vec_elt(spd->ipv4_inbound_protect_policy_indices, j) == i) {
374 vec_del1 (spd->ipv4_inbound_protect_policy_indices, j);
381 vec_foreach_index(j, spd->ipv4_inbound_policy_discard_and_bypass_indices) {
382 if (vec_elt(spd->ipv4_inbound_policy_discard_and_bypass_indices, j) == i) {
383 vec_del1 (spd->ipv4_inbound_policy_discard_and_bypass_indices, j);
409 pool_foreach(p, spd->policies, ({
410 if (p->policy == IPSEC_POLICY_ACTION_PROTECT)
412 if (p->sa_index == sa_index)
419 if (t->input_sa_index == sa_index)
421 if (t->output_sa_index == sa_index)
441 return VNET_API_ERROR_SYSCALL_ERROR_1;
443 return VNET_API_ERROR_SYSCALL_ERROR_1;
452 return VNET_API_ERROR_SYSCALL_ERROR_1;
461 sa_index = sa - im->
sad;
477 return VNET_API_ERROR_SYSCALL_ERROR_1;
511 seed_data.time = time (
NULL);
512 seed_data.pid = getpid ();
513 seed_data.p = (
void *) &seed_data;
515 RAND_seed ((
const void *) &seed_data,
sizeof (seed_data));
528 memset (im, 0,
sizeof (im[0]));
u32 * ipv6_inbound_protect_policy_indices
#define hash_set(h, key, value)
u32 * ipv4_inbound_protect_policy_indices
sll srl srl sll sra u16x4 i
u32 * config_index_by_sw_if_index
#define hash_unset(h, key)
int vnet_interface_add_del_feature(vnet_main_t *vnm, vlib_main_t *vm, u32 sw_if_index, intf_output_feat_t feature, int is_add)
u32 vnet_config_del_feature(vlib_main_t *vm, vnet_config_main_t *cm, u32 config_string_heap_index, u32 feature_index, void *feature_config, u32 n_feature_config_bytes)
ip_config_main_t rx_config_mains[VNET_N_CAST]
rx/tx interface/feature configuration.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
u32 * ipv4_outbound_policies
ip_lookup_main_t lookup_main
#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).
uword * spd_index_by_sw_if_index
clib_error_t * ipsec_tunnel_if_init(vlib_main_t *vm)
vnet_main_t * vnet_get_main(void)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
u32 ip4_unicast_rx_feature_ipsec
Built-in unicast feature path indice, see ip_feature_init_cast()
#define VLIB_INIT_FUNCTION(x)
#define hash_foreach(key_var, value_var, h, body)
int ipsec_add_del_policy(vlib_main_t *vm, ipsec_policy_t *policy, int is_add)
#define clib_warning(format, args...)
#define vlib_call_init_function(vm, x)
ipsec_policy_t * policies
u32 ip4_lookup_node_index
u32 error_drop_node_index
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
int ipsec_add_del_sa(vlib_main_t *vm, ipsec_sa_t *new_sa, int is_add)
#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.
int ipsec_set_sa_key(vlib_main_t *vm, ipsec_sa_t *sa_update)
u32 esp_encrypt_node_index
clib_error_t * ipsec_cli_init(vlib_main_t *vm)
#define vec_free(V)
Free vector's memory (no header).
static vlib_thread_main_t * vlib_get_thread_main()
#define clib_memcpy(a, b, c)
uword * sa_index_by_sa_id
static void ipsec_rand_seed(void)
int ipsec_add_del_spd(vlib_main_t *vm, u32 spd_id, int is_add)
static clib_error_t * ipsec_init(vlib_main_t *vm)
static u8 ipsec_is_sa_used(u32 sa_index)
#define hash_create(elts, value_bytes)
ip_lookup_main_t lookup_main
u32 vnet_config_add_feature(vlib_main_t *vm, vnet_config_main_t *cm, u32 config_string_heap_index, u32 feature_index, void *feature_config, u32 n_feature_config_bytes)
vlib_node_t * vlib_get_node_by_name(vlib_main_t *vm, u8 *name)
static int ipsec_spd_entry_sort(void *a1, void *a2)
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.
u32 ip6_unicast_rx_feature_ipsec
u32 ipsec_get_sa_index_by_sa_id(u32 sa_id)
u32 * ipv6_outbound_policies
clib_error_t * ikev2_init(vlib_main_t *vm)
ip4_main_t ip4_main
Global ip4 main structure.
#define pool_foreach_index(i, v, body)
Iterate pool by index.
#define CLIB_CACHE_LINE_BYTES
int ipsec_set_interface_spd(vlib_main_t *vm, u32 sw_if_index, u32 spd_id, int is_add)
vnet_config_main_t config_main