aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2016-09-06 15:18:21 +0200
committerDamjan Marion <dmarion.lists@gmail.com>2016-09-07 19:35:47 +0000
commitfb28e9a80c8e36db0a3a484a20e9e0114be517bd (patch)
treec469c677459167c479473272d8a6a7b0842b916c
parentbf1fa7fa397b3be95a9c83e27f18dc896a174287 (diff)
VPP-388 Improve IP header lookup in ipsec_output
Change-Id: I5df0067c9ce56d7a15a991b82d4761924d91758b Signed-off-by: Florin Coras <fcoras@cisco.com>
-rw-r--r--vnet/vnet/ipsec/ipsec_output.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/vnet/vnet/ipsec/ipsec_output.c b/vnet/vnet/ipsec/ipsec_output.c
index c27e8e6a0a5..ee21b777af4 100644
--- a/vnet/vnet/ipsec/ipsec_output.c
+++ b/vnet/vnet/ipsec/ipsec_output.c
@@ -225,14 +225,14 @@ ipsec_output_node_fn (vlib_main_t * vm,
ip6_header_t *ip6_0 = 0;
udp_header_t *udp0;
u8 is_ipv6 = 0;
+ u32 iph_offset = 0;
bi0 = from[0];
b0 = vlib_get_buffer (vm, bi0);
sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_TX];
-
-
- ip0 = (ip4_header_t *) ((u8 *) vlib_buffer_get_current (b0) +
- sizeof (ethernet_header_t));
+ iph_offset = vnet_buffer (b0)->ip.save_rewrite_length;
+ ip0 = (ip4_header_t *) ((u8 *) vlib_buffer_get_current (b0)
+ + iph_offset);
/* just forward non ipv4 packets */
if (PREDICT_FALSE ((ip0->ip_version_and_header_length & 0xF0) != 0x40))
@@ -242,8 +242,8 @@ ipsec_output_node_fn (vlib_main_t * vm,
((ip0->ip_version_and_header_length & 0xF0) == 0x60))
{
is_ipv6 = 1;
- ip6_0 = (ip6_header_t *) ((u8 *) vlib_buffer_get_current (b0) +
- sizeof (ethernet_header_t));
+ ip6_0 = (ip6_header_t *) ((u8 *) vlib_buffer_get_current (b0)
+ + iph_offset);
}
else
{
@@ -315,7 +315,7 @@ ipsec_output_node_fn (vlib_main_t * vm,
next_node_index = im->esp_encrypt_node_index;
vnet_buffer (b0)->output_features.ipsec_sad_index =
p0->sa_index;
- vlib_buffer_advance (b0, sizeof (ethernet_header_t));
+ vlib_buffer_advance (b0, iph_offset);
p0->counter.packets++;
if (is_ipv6)
{