summaryrefslogtreecommitdiffstats
path: root/src/vnet/ipsec
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/ipsec')
-rw-r--r--src/vnet/ipsec/ah_encrypt.c10
-rw-r--r--src/vnet/ipsec/esp_encrypt.c2
-rw-r--r--src/vnet/ipsec/ipsec_format.c4
-rw-r--r--src/vnet/ipsec/ipsec_sa.c19
-rw-r--r--src/vnet/ipsec/ipsec_sa.h5
5 files changed, 16 insertions, 24 deletions
diff --git a/src/vnet/ipsec/ah_encrypt.c b/src/vnet/ipsec/ah_encrypt.c
index 1620f877baa..d12ca6704f0 100644
--- a/src/vnet/ipsec/ah_encrypt.c
+++ b/src/vnet/ipsec/ah_encrypt.c
@@ -294,9 +294,8 @@ ah_encrypt_inline (vlib_main_t * vm,
&sa0->ip4_hdr.address_pair,
sizeof (ip4_address_t));
- next[0] = sa0->dpo[IPSEC_PROTOCOL_AH].dpoi_next_node;
- vnet_buffer (b[0])->ip.adj_index[VLIB_TX] =
- sa0->dpo[IPSEC_PROTOCOL_AH].dpoi_index;
+ next[0] = sa0->dpo.dpoi_next_node;
+ vnet_buffer (b[0])->ip.adj_index[VLIB_TX] = sa0->dpo.dpoi_index;
}
else if (is_ip6 && ipsec_sa_is_set_IS_TUNNEL (sa0) &&
ipsec_sa_is_set_IS_TUNNEL_V6 (sa0))
@@ -304,9 +303,8 @@ ah_encrypt_inline (vlib_main_t * vm,
clib_memcpy_fast (&oh6_0->ip6.src_address,
&sa0->ip6_hdr.src_address,
sizeof (ip6_address_t) * 2);
- next[0] = sa0->dpo[IPSEC_PROTOCOL_AH].dpoi_next_node;
- vnet_buffer (b[0])->ip.adj_index[VLIB_TX] =
- sa0->dpo[IPSEC_PROTOCOL_AH].dpoi_index;
+ next[0] = sa0->dpo.dpoi_next_node;
+ vnet_buffer (b[0])->ip.adj_index[VLIB_TX] = sa0->dpo.dpoi_index;
}
if (PREDICT_TRUE (sa0->integ_op_id))
diff --git a/src/vnet/ipsec/esp_encrypt.c b/src/vnet/ipsec/esp_encrypt.c
index ef1f5bbca58..d7cda052c92 100644
--- a/src/vnet/ipsec/esp_encrypt.c
+++ b/src/vnet/ipsec/esp_encrypt.c
@@ -367,7 +367,7 @@ esp_encrypt_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
esp_update_ip4_hdr (ip4, len, /* is_transport */ 0, 0);
}
- dpo = sa0->dpo + IPSEC_PROTOCOL_ESP;
+ dpo = &sa0->dpo;
if (!is_tun)
{
next[0] = dpo->dpoi_next_node;
diff --git a/src/vnet/ipsec/ipsec_format.c b/src/vnet/ipsec/ipsec_format.c
index 5bcfcdbeff1..d0d073bd2bb 100644
--- a/src/vnet/ipsec/ipsec_format.c
+++ b/src/vnet/ipsec/ipsec_format.c
@@ -326,9 +326,7 @@ format_ipsec_sa (u8 * s, va_list * args)
format (s, "\n resovle via fib-entry: %d",
sa->fib_entry_index);
s = format (s, "\n stacked on:");
- s =
- format (s, "\n %U", format_dpo_id,
- &sa->dpo[IPSEC_PROTOCOL_ESP], 6);
+ s = format (s, "\n %U", format_dpo_id, &sa->dpo, 6);
}
}
diff --git a/src/vnet/ipsec/ipsec_sa.c b/src/vnet/ipsec/ipsec_sa.c
index 633f640ced2..e8a015957ce 100644
--- a/src/vnet/ipsec/ipsec_sa.c
+++ b/src/vnet/ipsec/ipsec_sa.c
@@ -80,14 +80,14 @@ ipsec_sa_stack (ipsec_sa_t * sa)
fib_entry_contribute_forwarding (sa->fib_entry_index, fct, &tmp);
- dpo_stack_from_node ((ipsec_sa_is_set_IS_TUNNEL_V6 (sa) ?
- im->ah6_encrypt_node_index :
- im->ah4_encrypt_node_index),
- &sa->dpo[IPSEC_PROTOCOL_AH], &tmp);
- dpo_stack_from_node ((ipsec_sa_is_set_IS_TUNNEL_V6 (sa) ?
- im->esp6_encrypt_node_index :
- im->esp4_encrypt_node_index),
- &sa->dpo[IPSEC_PROTOCOL_ESP], &tmp);
+ if (IPSEC_PROTOCOL_AH == sa->protocol)
+ dpo_stack_from_node ((ipsec_sa_is_set_IS_TUNNEL_V6 (sa) ?
+ im->ah6_encrypt_node_index :
+ im->ah4_encrypt_node_index), &sa->dpo, &tmp);
+ else
+ dpo_stack_from_node ((ipsec_sa_is_set_IS_TUNNEL_V6 (sa) ?
+ im->esp6_encrypt_node_index :
+ im->esp4_encrypt_node_index), &sa->dpo, &tmp);
dpo_reset (&tmp);
}
@@ -305,8 +305,7 @@ ipsec_sa_del (u32 id)
fib_table_entry_special_remove
(sa->tx_fib_index,
fib_entry_get_prefix (sa->fib_entry_index), FIB_SOURCE_RR);
- dpo_reset (&sa->dpo[IPSEC_PROTOCOL_AH]);
- dpo_reset (&sa->dpo[IPSEC_PROTOCOL_ESP]);
+ dpo_reset (&sa->dpo);
}
vnet_crypto_key_del (vm, sa->crypto_key_index);
vnet_crypto_key_del (vm, sa->integ_key_index);
diff --git a/src/vnet/ipsec/ipsec_sa.h b/src/vnet/ipsec/ipsec_sa.h
index 969b5d142ee..53035aa2a20 100644
--- a/src/vnet/ipsec/ipsec_sa.h
+++ b/src/vnet/ipsec/ipsec_sa.h
@@ -71,8 +71,6 @@ typedef enum
IPSEC_PROTOCOL_ESP = 1
} ipsec_protocol_t;
-#define IPSEC_N_PROTOCOLS (IPSEC_PROTOCOL_ESP+1)
-
#define IPSEC_KEY_MAX_LEN 128
typedef struct ipsec_key_t_
{
@@ -124,6 +122,7 @@ typedef struct
u32 last_seq;
u32 last_seq_hi;
u64 replay_window;
+ dpo_id_t dpo;
vnet_crypto_key_index_t crypto_key_index;
vnet_crypto_key_index_t integ_key_index;
@@ -131,8 +130,6 @@ typedef struct
vnet_crypto_op_id_t crypto_dec_op_id:16;
vnet_crypto_op_id_t integ_op_id:16;
- dpo_id_t dpo[IPSEC_N_PROTOCOLS];
-
/* data accessed by dataplane code should be above this comment */
CLIB_CACHE_LINE_ALIGN_MARK (cacheline1);