summaryrefslogtreecommitdiffstats
path: root/src/vnet/ipsec/ipsec_if.c
diff options
context:
space:
mode:
authorSergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>2017-08-26 15:22:05 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2017-10-05 09:54:34 +0000
commitdb93cd971320301eb21403caabada7a3ec6a4cce (patch)
tree01c57f4f476a97805411a74d665eedb72331f91e /src/vnet/ipsec/ipsec_if.c
parent7939f904600018aeed9d8cc9d19ca37c7e96f3d1 (diff)
dpdk/ipsec: rework plus improved cli commands
This patch reworks the DPDK ipsec implementation including the cryptodev management as well as replacing new cli commands for better usability. For the data path: - The dpdk-esp-encrypt-post node is not necessary anymore. - IPv4 packets in the decrypt path are sent to ip4-input-no-checksum instead of ip4-input. The DPDK cryptodev cli commands are replaced by the following new commands: - show dpdk crypto devices - show dpdk crypto placement [verbose] - set dpdk crypto placement (<device> <thread> | auto) - clear dpdk crypto placement <device> [<thread>] - show dpdk crypto pools Change-Id: I47324517ede82d3e6e0e9f9c71c1a3433714b27b Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
Diffstat (limited to 'src/vnet/ipsec/ipsec_if.c')
-rw-r--r--src/vnet/ipsec/ipsec_if.c78
1 files changed, 43 insertions, 35 deletions
diff --git a/src/vnet/ipsec/ipsec_if.c b/src/vnet/ipsec/ipsec_if.c
index 9359a3b772e..974553489ea 100644
--- a/src/vnet/ipsec/ipsec_if.c
+++ b/src/vnet/ipsec/ipsec_if.c
@@ -49,25 +49,63 @@ ipsec_admin_up_down_function (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
ipsec_sa_t *sa;
hi = vnet_get_hw_interface (vnm, hw_if_index);
+ t = pool_elt_at_index (im->tunnel_interfaces, hi->hw_instance);
+
if (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)
{
- t = pool_elt_at_index (im->tunnel_interfaces, hi->hw_instance);
ASSERT (im->cb.check_support_cb);
+
sa = pool_elt_at_index (im->sad, t->input_sa_index);
+
err = im->cb.check_support_cb (sa);
if (err)
return err;
+ if (im->cb.add_del_sa_sess_cb)
+ {
+ err = im->cb.add_del_sa_sess_cb (t->input_sa_index, 1);
+ if (err)
+ return err;
+ }
+
sa = pool_elt_at_index (im->sad, t->output_sa_index);
+
err = im->cb.check_support_cb (sa);
if (err)
return err;
+ if (im->cb.add_del_sa_sess_cb)
+ {
+ err = im->cb.add_del_sa_sess_cb (t->output_sa_index, 1);
+ if (err)
+ return err;
+ }
+
vnet_hw_interface_set_flags (vnm, hw_if_index,
VNET_HW_INTERFACE_FLAG_LINK_UP);
}
else
- vnet_hw_interface_set_flags (vnm, hw_if_index, 0 /* down */ );
+ {
+ vnet_hw_interface_set_flags (vnm, hw_if_index, 0 /* down */ );
+
+ sa = pool_elt_at_index (im->sad, t->input_sa_index);
+
+ if (im->cb.add_del_sa_sess_cb)
+ {
+ err = im->cb.add_del_sa_sess_cb (t->input_sa_index, 0);
+ if (err)
+ return err;
+ }
+
+ sa = pool_elt_at_index (im->sad, t->output_sa_index);
+
+ if (im->cb.add_del_sa_sess_cb)
+ {
+ err = im->cb.add_del_sa_sess_cb (t->output_sa_index, 0);
+ if (err)
+ return err;
+ }
+ }
return /* no error */ 0;
}
@@ -157,10 +195,6 @@ ipsec_add_del_tunnel_if_internal (vnet_main_t * vnm,
args->remote_crypto_key_len);
}
- if (im->cb.add_del_sa_sess_cb &&
- im->cb.add_del_sa_sess_cb (t->input_sa_index, args->is_add) < 0)
- return VNET_API_ERROR_SYSCALL_ERROR_1;
-
pool_get (im->sad, sa);
memset (sa, 0, sizeof (*sa));
t->output_sa_index = sa - im->sad;
@@ -168,7 +202,6 @@ ipsec_add_del_tunnel_if_internal (vnet_main_t * vnm,
sa->tunnel_src_addr.ip4.as_u32 = args->local_ip.as_u32;
sa->tunnel_dst_addr.ip4.as_u32 = args->remote_ip.as_u32;
sa->is_tunnel = 1;
- sa->seq = 1;
sa->use_esn = args->esn;
sa->use_anti_replay = args->anti_replay;
sa->integ_alg = args->integ_alg;
@@ -186,10 +219,6 @@ ipsec_add_del_tunnel_if_internal (vnet_main_t * vnm,
args->local_crypto_key_len);
}
- if (im->cb.add_del_sa_sess_cb &&
- im->cb.add_del_sa_sess_cb (t->output_sa_index, args->is_add) < 0)
- return VNET_API_ERROR_SYSCALL_ERROR_1;
-
hash_set (im->ipsec_if_pool_index_by_key, key,
t - im->tunnel_interfaces);
@@ -242,18 +271,10 @@ ipsec_add_del_tunnel_if_internal (vnet_main_t * vnm,
/* delete input and output SA */
sa = pool_elt_at_index (im->sad, t->input_sa_index);
- if (im->cb.add_del_sa_sess_cb &&
- im->cb.add_del_sa_sess_cb (t->input_sa_index, args->is_add) < 0)
- return VNET_API_ERROR_SYSCALL_ERROR_1;
-
pool_put (im->sad, sa);
sa = pool_elt_at_index (im->sad, t->output_sa_index);
- if (im->cb.add_del_sa_sess_cb &&
- im->cb.add_del_sa_sess_cb (t->output_sa_index, args->is_add) < 0)
- return VNET_API_ERROR_SYSCALL_ERROR_1;
-
pool_put (im->sad, sa);
hash_unset (im->ipsec_if_pool_index_by_key, key);
@@ -340,16 +361,15 @@ ipsec_set_interface_key (vnet_main_t * vnm, u32 hw_if_index,
hi = vnet_get_hw_interface (vnm, hw_if_index);
t = pool_elt_at_index (im->tunnel_interfaces, hi->dev_instance);
+ if (hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP)
+ return VNET_API_ERROR_SYSCALL_ERROR_1;
+
if (type == IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO)
{
sa = pool_elt_at_index (im->sad, t->output_sa_index);
sa->crypto_alg = alg;
sa->crypto_key_len = vec_len (key);
clib_memcpy (sa->crypto_key, key, vec_len (key));
-
- if (im->cb.add_del_sa_sess_cb &&
- im->cb.add_del_sa_sess_cb (t->output_sa_index, 0) < 0)
- return VNET_API_ERROR_SYSCALL_ERROR_1;
}
else if (type == IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG)
{
@@ -357,10 +377,6 @@ ipsec_set_interface_key (vnet_main_t * vnm, u32 hw_if_index,
sa->integ_alg = alg;
sa->integ_key_len = vec_len (key);
clib_memcpy (sa->integ_key, key, vec_len (key));
-
- if (im->cb.add_del_sa_sess_cb &&
- im->cb.add_del_sa_sess_cb (t->output_sa_index, 0) < 0)
- return VNET_API_ERROR_SYSCALL_ERROR_1;
}
else if (type == IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO)
{
@@ -368,10 +384,6 @@ ipsec_set_interface_key (vnet_main_t * vnm, u32 hw_if_index,
sa->crypto_alg = alg;
sa->crypto_key_len = vec_len (key);
clib_memcpy (sa->crypto_key, key, vec_len (key));
-
- if (im->cb.add_del_sa_sess_cb &&
- im->cb.add_del_sa_sess_cb (t->input_sa_index, 0) < 0)
- return VNET_API_ERROR_SYSCALL_ERROR_1;
}
else if (type == IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG)
{
@@ -379,10 +391,6 @@ ipsec_set_interface_key (vnet_main_t * vnm, u32 hw_if_index,
sa->integ_alg = alg;
sa->integ_key_len = vec_len (key);
clib_memcpy (sa->integ_key, key, vec_len (key));
-
- if (im->cb.add_del_sa_sess_cb &&
- im->cb.add_del_sa_sess_cb (t->input_sa_index, 0) < 0)
- return VNET_API_ERROR_SYSCALL_ERROR_1;
}
else
return VNET_API_ERROR_INVALID_VALUE;