summaryrefslogtreecommitdiffstats
path: root/src/vnet/ipsec/ipsec_output.c
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2018-06-24 22:49:55 +0200
committerKlement Sekera <ksekera@cisco.com>2018-06-24 22:53:37 +0200
commit31da2e30317bc1fcb4586e1dc0d560600d9b29d3 (patch)
tree4c025f26e8aa9e4f6499144deea9028154b63fe0 /src/vnet/ipsec/ipsec_output.c
parent2a8d02df15e71881754bab0bb16b85ccd65f8f74 (diff)
Revert "Revert "ipsec: VPP-1316 calculate IP/TCP/UDP inner checksums""
This reverts commit e0d2bd6bd7fc59c0c6ac48195d7f825dc99bfd91. Change-Id: If491e16f9ea66b2493a6a7c7f3c684ed585f8f51 Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'src/vnet/ipsec/ipsec_output.c')
-rw-r--r--src/vnet/ipsec/ipsec_output.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/vnet/ipsec/ipsec_output.c b/src/vnet/ipsec/ipsec_output.c
index 4bfbf603072..a62c0a53458 100644
--- a/src/vnet/ipsec/ipsec_output.c
+++ b/src/vnet/ipsec/ipsec_output.c
@@ -190,6 +190,7 @@ ipsec_output_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t *f = 0;
u32 spd_index0 = ~0;
ipsec_spd_t *spd0 = 0;
+ int bogus;
u64 nc_protect = 0, nc_bypass = 0, nc_discard = 0, nc_nomatch = 0;
from = vlib_frame_vector_args (from_frame);
@@ -204,6 +205,7 @@ ipsec_output_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
ip6_header_t *ip6_0 = 0;
udp_header_t *udp0;
u32 iph_offset = 0;
+ tcp_header_t *tcp0;
bi0 = from[0];
b0 = vlib_get_buffer (vm, bi0);
@@ -269,6 +271,7 @@ ipsec_output_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
clib_net_to_host_u16
(udp0->dst_port));
}
+ tcp0 = (void *) udp0;
if (PREDICT_TRUE (p0 != NULL))
{
@@ -282,18 +285,53 @@ ipsec_output_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
else
next_node_index = im->ah_encrypt_node_index;
vnet_buffer (b0)->ipsec.sad_index = p0->sa_index;
- vlib_buffer_advance (b0, iph_offset);
p0->counter.packets++;
if (is_ipv6)
{
p0->counter.bytes +=
clib_net_to_host_u16 (ip6_0->payload_length);
p0->counter.bytes += sizeof (ip6_header_t);
+ if (PREDICT_FALSE
+ (b0->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM))
+ {
+ tcp0->checksum =
+ ip6_tcp_udp_icmp_compute_checksum (vm, b0, ip6_0,
+ &bogus);
+ b0->flags &= ~VNET_BUFFER_F_OFFLOAD_TCP_CKSUM;
+ }
+ if (PREDICT_FALSE
+ (b0->flags & VNET_BUFFER_F_OFFLOAD_UDP_CKSUM))
+ {
+ udp0->checksum =
+ ip6_tcp_udp_icmp_compute_checksum (vm, b0, ip6_0,
+ &bogus);
+ b0->flags &= ~VNET_BUFFER_F_OFFLOAD_UDP_CKSUM;
+ }
}
else
{
p0->counter.bytes += clib_net_to_host_u16 (ip0->length);
+ if (b0->flags & VNET_BUFFER_F_OFFLOAD_IP_CKSUM)
+ {
+ ip0->checksum = ip4_header_checksum (ip0);
+ b0->flags &= ~VNET_BUFFER_F_OFFLOAD_IP_CKSUM;
+ }
+ if (PREDICT_FALSE
+ (b0->flags & VNET_BUFFER_F_OFFLOAD_TCP_CKSUM))
+ {
+ tcp0->checksum =
+ ip4_tcp_udp_compute_checksum (vm, b0, ip0);
+ b0->flags &= ~VNET_BUFFER_F_OFFLOAD_TCP_CKSUM;
+ }
+ if (PREDICT_FALSE
+ (b0->flags & VNET_BUFFER_F_OFFLOAD_UDP_CKSUM))
+ {
+ udp0->checksum =
+ ip4_tcp_udp_compute_checksum (vm, b0, ip0);
+ b0->flags &= ~VNET_BUFFER_F_OFFLOAD_UDP_CKSUM;
+ }
}
+ vlib_buffer_advance (b0, iph_offset);
}
else if (p0->policy == IPSEC_POLICY_ACTION_BYPASS)
{