aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Sliwa <szs@semihalf.com>2018-01-31 19:00:26 +0100
committerSzymon Sliwa <szs@semihalf.com>2018-02-19 17:47:48 +0100
commit817aabfc08f12a5726b2863fd24c1ffe87bb5ad1 (patch)
treebb73db7fd64d2e055c9b355258aa3d4391f480ca
parent84cc712ed30960bd4b4598ce387fc9ed6a610987 (diff)
plugins: odp: remove copying the ip header twice
Change-Id: Ib32d9df19bb9b0db1b3a0d30d991f1a1f11d66c7 Signed-off-by: Szymon Sliwa <szs@semihalf.com>
-rw-r--r--src/plugins/odp/ipsec/esp_decrypt.c34
1 files changed, 6 insertions, 28 deletions
diff --git a/src/plugins/odp/ipsec/esp_decrypt.c b/src/plugins/odp/ipsec/esp_decrypt.c
index 20b3b30..bbdf578 100644
--- a/src/plugins/odp/ipsec/esp_decrypt.c
+++ b/src/plugins/odp/ipsec/esp_decrypt.c
@@ -140,9 +140,7 @@ esp_decrypt_node_fn (vlib_main_t * vm,
u32 sa_index0 = ~0;
u32 seq;
ip4_header_t *ih4 = 0, *oh4 = 0;
- ip6_header_t *oh6 = 0;
- ip4_header_t old_ip4_hdr;
- ip6_header_t old_ip6_hdr;
+ ip6_header_t *ih6 = 0, *oh6 = 0;
u8 tunnel_mode = 1;
u8 transport_ip6 = 0;
sa_data_t *sa_sess_data;
@@ -246,6 +244,8 @@ esp_decrypt_node_fn (vlib_main_t * vm,
((ih4->ip_version_and_header_length & 0xF0) != 0x40))
{
ip_hdr_size = sizeof (ip6_header_t);
+ ih6 =
+ (ip6_header_t *) (b0->data + sizeof (ethernet_header_t));
}
else
{
@@ -273,10 +273,6 @@ esp_decrypt_node_fn (vlib_main_t * vm,
+ sizeof (esp_header_t) +
IV_SIZE -
sizeof (ip6_header_t));
- old_ip6_hdr =
- *((ip6_header_t *) ((uintptr_t)
- vlib_buffer_get_current (b0) -
- ip_hdr_size));
}
else
{
@@ -294,10 +290,6 @@ esp_decrypt_node_fn (vlib_main_t * vm,
vlib_buffer_get_current (b0) +
sizeof (esp_header_t) + IV_SIZE -
sizeof (ip4_header_t));
- old_ip4_hdr =
- *((ip4_header_t *) ((uintptr_t)
- vlib_buffer_get_current (b0) -
- ip_hdr_size));
}
}
@@ -363,20 +355,10 @@ esp_decrypt_node_fn (vlib_main_t * vm,
{
if (PREDICT_FALSE (transport_ip6))
{
+ memmove(oh6, ih6, sizeof(ip6_header_t));
next0 = ESP_DECRYPT_NEXT_IP6_INPUT;
- oh6->ip_version_traffic_class_and_flow_label =
- old_ip6_hdr.ip_version_traffic_class_and_flow_label;
oh6->protocol = f0->next_header;
- oh6->hop_limit = old_ip6_hdr.hop_limit;
- oh6->src_address.as_u64[0] =
- old_ip6_hdr.src_address.as_u64[0];
- oh6->src_address.as_u64[1] =
- old_ip6_hdr.src_address.as_u64[1];
- oh6->dst_address.as_u64[0] =
- old_ip6_hdr.dst_address.as_u64[0];
- oh6->dst_address.as_u64[1] =
- old_ip6_hdr.dst_address.as_u64[1];
oh6->payload_length =
clib_host_to_net_u16 (vlib_buffer_length_in_chain
(vm,
@@ -384,17 +366,13 @@ esp_decrypt_node_fn (vlib_main_t * vm,
}
else
{
+ memmove(oh4, ih4, sizeof(ip4_header_t));
+
next0 = ESP_DECRYPT_NEXT_IP4_INPUT;
oh4->ip_version_and_header_length = 0x45;
- oh4->tos = old_ip4_hdr.tos;
oh4->fragment_id = 0;
oh4->flags_and_fragment_offset = 0;
- oh4->ttl = old_ip4_hdr.ttl;
oh4->protocol = f0->next_header;
- oh4->src_address.as_u32 =
- old_ip4_hdr.src_address.as_u32;
- oh4->dst_address.as_u32 =
- old_ip4_hdr.dst_address.as_u32;
oh4->length =
clib_host_to_net_u16 (vlib_buffer_length_in_chain
(vm, b0));