summaryrefslogtreecommitdiffstats
path: root/src/plugins/dpdk/ipsec/esp_encrypt.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2019-03-26 13:16:42 +0100
committerDamjan Marion <dmarion@me.com>2019-03-27 12:40:18 +0000
commitd709cbcb1ef80633af657c5427608831e5bbd919 (patch)
treecb389257174014b546e32cb3a6ab15df781703d8 /src/plugins/dpdk/ipsec/esp_encrypt.c
parentfbf278adc2fa5ffd1671fb9f91eb03d6d0dc5a9e (diff)
ipsec: compress ipsec_sa_t so data used by dataplane code fits in cacheline
Change-Id: I81ecdf9fdcfcb017117b47dc031f93208e004d7c Signed-off-by: Damjan Marion <damarion@cisco.com> Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/plugins/dpdk/ipsec/esp_encrypt.c')
-rw-r--r--src/plugins/dpdk/ipsec/esp_encrypt.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/plugins/dpdk/ipsec/esp_encrypt.c b/src/plugins/dpdk/ipsec/esp_encrypt.c
index d29ca55ea2e..25815d98748 100644
--- a/src/plugins/dpdk/ipsec/esp_encrypt.c
+++ b/src/plugins/dpdk/ipsec/esp_encrypt.c
@@ -297,13 +297,13 @@ dpdk_esp_encrypt_inline (vlib_main_t * vm,
trunc_size = auth_alg->trunc_size;
/* if UDP encapsulation is used adjust the address of the IP header */
- if (sa0->udp_encap && !is_ip6)
+ if (ipsec_sa_is_set_UDP_ENCAP (sa0) && !is_ip6)
udp_encap_adv = sizeof (udp_header_t);
- if (sa0->is_tunnel)
+ if (ipsec_sa_is_set_IS_TUNNEL (sa0))
{
rewrite_len = 0;
- if (!is_ip6 && !sa0->is_tunnel_ip6) /* ip4inip4 */
+ if (!is_ip6 && !ipsec_sa_is_set_IS_TUNNEL_V6 (sa0)) /* ip4inip4 */
{
/* in tunnel mode send it back to FIB */
priv->next = DPDK_CRYPTO_INPUT_NEXT_IP4_LOOKUP;
@@ -333,7 +333,7 @@ dpdk_esp_encrypt_inline (vlib_main_t * vm,
oh0->ip4.dst_address.as_u32 =
sa0->tunnel_dst_addr.ip4.as_u32;
- if (sa0->udp_encap)
+ if (ipsec_sa_is_set_UDP_ENCAP (sa0))
{
oh0->ip4.protocol = IP_PROTOCOL_UDP;
esp0 = &ouh0->esp;
@@ -343,8 +343,9 @@ dpdk_esp_encrypt_inline (vlib_main_t * vm,
esp0->spi = clib_host_to_net_u32 (sa0->spi);
esp0->seq = clib_host_to_net_u32 (sa0->seq);
}
- else if (is_ip6 && sa0->is_tunnel_ip6) /* ip6inip6 */
+ else if (is_ip6 && ipsec_sa_is_set_IS_TUNNEL_V6 (sa0))
{
+ /* ip6inip6 */
/* in tunnel mode send it back to FIB */
priv->next = DPDK_CRYPTO_INPUT_NEXT_IP6_LOOKUP;
@@ -418,7 +419,7 @@ dpdk_esp_encrypt_inline (vlib_main_t * vm,
memmove (dst, src, rewrite_len + ip_size);
oh0->ip4.protocol = IP_PROTOCOL_IPSEC_ESP;
esp0 = (esp_header_t *) (((u8 *) oh0) + ip_size);
- if (sa0->udp_encap)
+ if (ipsec_sa_is_set_UDP_ENCAP (sa0))
{
oh0->ip4.protocol = IP_PROTOCOL_UDP;
esp0 = (esp_header_t *)
@@ -434,7 +435,7 @@ dpdk_esp_encrypt_inline (vlib_main_t * vm,
esp0->seq = clib_host_to_net_u32 (sa0->seq);
}
- if (sa0->udp_encap && ouh0)
+ if (ipsec_sa_is_set_UDP_ENCAP (sa0) && ouh0)
{
ouh0->udp.src_port = clib_host_to_net_u16 (UDP_DST_PORT_ipsec);
ouh0->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_ipsec);
@@ -467,7 +468,7 @@ dpdk_esp_encrypt_inline (vlib_main_t * vm,
oh0->ip4.length =
clib_host_to_net_u16 (b0->current_length - rewrite_len);
oh0->ip4.checksum = ip4_header_checksum (&oh0->ip4);
- if (sa0->udp_encap && ouh0)
+ if (ipsec_sa_is_set_UDP_ENCAP (sa0) && ouh0)
{
ouh0->udp.length =
clib_host_to_net_u16 (clib_net_to_host_u16
@@ -512,7 +513,7 @@ dpdk_esp_encrypt_inline (vlib_main_t * vm,
aad[1] = clib_host_to_net_u32 (sa0->seq);
/* aad[3] should always be 0 */
- if (PREDICT_FALSE (sa0->use_esn))
+ if (PREDICT_FALSE (ipsec_sa_is_set_USE_EXTENDED_SEQ_NUM (sa0)))
aad[2] = clib_host_to_net_u32 (sa0->seq_hi);
else
aad[2] = 0;
@@ -521,7 +522,7 @@ dpdk_esp_encrypt_inline (vlib_main_t * vm,
{
auth_len =
vlib_buffer_get_tail (b0) - ((u8 *) esp0) - trunc_size;
- if (sa0->use_esn)
+ if (ipsec_sa_is_set_USE_EXTENDED_SEQ_NUM (sa0))
{
u32 *_digest = (u32 *) digest;
_digest[0] = clib_host_to_net_u32 (sa0->seq_hi);
@@ -540,7 +541,7 @@ dpdk_esp_encrypt_inline (vlib_main_t * vm,
tr->crypto_alg = sa0->crypto_alg;
tr->integ_alg = sa0->integ_alg;
u8 *p = vlib_buffer_get_current (b0);
- if (!sa0->is_tunnel)
+ if (!ipsec_sa_is_set_IS_TUNNEL (sa0))
p += vnet_buffer (b0)->ip.save_rewrite_length;
clib_memcpy_fast (tr->packet_data, p, sizeof (tr->packet_data));
}