aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/dpdk/ipsec/esp_decrypt.c21
-rw-r--r--src/plugins/dpdk/ipsec/esp_encrypt.c23
-rw-r--r--src/plugins/dpdk/ipsec/ipsec.c2
3 files changed, 24 insertions, 22 deletions
diff --git a/src/plugins/dpdk/ipsec/esp_decrypt.c b/src/plugins/dpdk/ipsec/esp_decrypt.c
index 20040433420..dcc276f99bc 100644
--- a/src/plugins/dpdk/ipsec/esp_decrypt.c
+++ b/src/plugins/dpdk/ipsec/esp_decrypt.c
@@ -234,13 +234,13 @@ dpdk_esp_decrypt_inline (vlib_main_t * vm,
}
/* anti-replay check */
- if (sa0->use_anti_replay)
+ if (ipsec_sa_is_set_USE_ANTI_REPLAY (sa0))
{
int rv = 0;
seq = clib_net_to_host_u32 (esp0->seq);
- if (PREDICT_TRUE (sa0->use_esn))
+ if (PREDICT_TRUE (ipsec_sa_is_set_USE_EXTENDED_SEQ_NUM (sa0)))
rv = esp_replay_check_esn (sa0, seq);
else
rv = esp_replay_check (sa0, seq);
@@ -339,7 +339,7 @@ dpdk_esp_decrypt_inline (vlib_main_t * vm,
clib_memcpy_fast (aad, esp0, 8);
/* _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;
@@ -348,7 +348,7 @@ dpdk_esp_decrypt_inline (vlib_main_t * vm,
{
auth_len = sizeof (esp_header_t) + iv_size + payload_len;
- if (sa0->use_esn)
+ if (ipsec_sa_is_set_USE_EXTENDED_SEQ_NUM (sa0))
{
clib_memcpy_fast (priv->icv, digest, trunc_size);
u32 *_digest = (u32 *) digest;
@@ -560,18 +560,19 @@ dpdk_esp_decrypt_post_inline (vlib_main_t * vm,
iv_size = cipher_alg->iv_len;
- if (sa0->use_anti_replay)
+ if (ipsec_sa_is_set_USE_ANTI_REPLAY (sa0))
{
u32 seq;
seq = clib_host_to_net_u32 (esp0->seq);
- if (PREDICT_TRUE (sa0->use_esn))
+ if (PREDICT_TRUE (ipsec_sa_is_set_USE_EXTENDED_SEQ_NUM (sa0)))
esp_replay_advance_esn (sa0, seq);
else
esp_replay_advance (sa0, seq);
}
/* if UDP encapsulation is used adjust the address of the IP header */
- if (sa0->udp_encap && (b0->flags & VNET_BUFFER_F_IS_IP4))
+ if (ipsec_sa_is_set_UDP_ENCAP (sa0)
+ && (b0->flags & VNET_BUFFER_F_IS_IP4))
{
udp_encap_adv = sizeof (udp_header_t);
}
@@ -599,11 +600,11 @@ dpdk_esp_decrypt_post_inline (vlib_main_t * vm,
goto trace;
}
#endif
- if (sa0->is_tunnel)
+ if (ipsec_sa_is_set_IS_TUNNEL (sa0))
{
if (f0->next_header == IP_PROTOCOL_IP_IN_IP)
next0 = ESP_DECRYPT_NEXT_IP4_INPUT;
- else if (sa0->is_tunnel_ip6
+ else if (ipsec_sa_is_set_IS_TUNNEL_V6 (sa0)
&& f0->next_header == IP_PROTOCOL_IPV6)
next0 = ESP_DECRYPT_NEXT_IP6_INPUT;
else
@@ -629,7 +630,7 @@ dpdk_esp_decrypt_post_inline (vlib_main_t * vm,
u16 ih4_len = ip4_header_bytes (ih4);
vlib_buffer_advance (b0, -ih4_len - udp_encap_adv);
next0 = ESP_DECRYPT_NEXT_IP4_INPUT;
- if (!sa0->udp_encap)
+ if (!ipsec_sa_is_set_UDP_ENCAP (sa0))
{
oh4 = vlib_buffer_get_current (b0);
memmove (oh4, ih4, ih4_len);
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));
}
diff --git a/src/plugins/dpdk/ipsec/ipsec.c b/src/plugins/dpdk/ipsec/ipsec.c
index f79b4301e9c..cc06a4a87d5 100644
--- a/src/plugins/dpdk/ipsec/ipsec.c
+++ b/src/plugins/dpdk/ipsec/ipsec.c
@@ -258,7 +258,7 @@ crypto_set_aead_xform (struct rte_crypto_sym_xform *xform,
crypto_op_get_priv_offset () + offsetof (dpdk_op_priv_t, cb);
xform->aead.iv.length = 12;
xform->aead.digest_length = c->trunc_size;
- xform->aead.aad_length = sa->use_esn ? 12 : 8;
+ xform->aead.aad_length = ipsec_sa_is_set_USE_EXTENDED_SEQ_NUM (sa) ? 12 : 8;
xform->next = NULL;
if (is_outbound)