summaryrefslogtreecommitdiffstats
path: root/src/vnet/ip/ip6_forward.c
diff options
context:
space:
mode:
authorJohn Lo <loj@cisco.com>2019-08-03 14:36:39 -0400
committerJohn Lo <loj@cisco.com>2019-08-05 13:08:20 +0000
commit1e567ddb35cb2b1c3b0200c9e8b6c8d2ec2533ae (patch)
tree6817367e34c1f8e7013e851a9d266b66333079ad /src/vnet/ip/ip6_forward.c
parent5672495dc096f165714c5ce3a321059c35b545f1 (diff)
ip: fix ip6/udp checksum for pkts using buffer chaining
Fix ip6_tcp_udp_icmp_compute_checksum to work properly for packets with multiple buffers. Fix ip4_tcp_udp_compute_checksum to exit upon detecting error. Type: fix Signed-off-by: John Lo <loj@cisco.com> Change-Id: I673547f4479d72cd60757383343fc562cff10265 (cherry picked from commit 3bc6bc21fb79a9da4ec674f5e6a3303e7e2be625)
Diffstat (limited to 'src/vnet/ip/ip6_forward.c')
-rw-r--r--src/vnet/ip/ip6_forward.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/vnet/ip/ip6_forward.c b/src/vnet/ip/ip6_forward.c
index 6df3d4b036b..3410a5dc8f9 100644
--- a/src/vnet/ip/ip6_forward.c
+++ b/src/vnet/ip/ip6_forward.c
@@ -993,10 +993,18 @@ ip6_tcp_udp_icmp_compute_checksum (vlib_main_t * vm, vlib_buffer_t * p0,
}
n_bytes_left = n_this_buffer = payload_length_host_byte_order;
- if (p0 && n_this_buffer + headers_size > p0->current_length)
- n_this_buffer =
- p0->current_length >
- headers_size ? p0->current_length - headers_size : 0;
+
+ if (p0)
+ {
+ u32 n_ip_bytes_this_buffer =
+ p0->current_length - (((u8 *) ip0 - p0->data) - p0->current_data);
+ if (n_this_buffer + headers_size > n_ip_bytes_this_buffer)
+ {
+ n_this_buffer = p0->current_length > headers_size ?
+ n_ip_bytes_this_buffer - headers_size : 0;
+ }
+ }
+
while (1)
{
sum0 = ip_incremental_checksum (sum0, data_this_buffer, n_this_buffer);