summaryrefslogtreecommitdiffstats
path: root/src/vnet/ip/ip6_forward.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/ip/ip6_forward.c')
-rw-r--r--src/vnet/ip/ip6_forward.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/vnet/ip/ip6_forward.c b/src/vnet/ip/ip6_forward.c
index b990d7c45d2..f9e3e0a0ab3 100644
--- a/src/vnet/ip/ip6_forward.c
+++ b/src/vnet/ip/ip6_forward.c
@@ -910,7 +910,8 @@ ip6_tcp_udp_icmp_compute_checksum (vlib_main_t * vm, vlib_buffer_t * p0,
u16 sum16, payload_length_host_byte_order;
u32 i, n_this_buffer, n_bytes_left;
u32 headers_size = sizeof (ip0[0]);
- void *data_this_buffer;
+ u8 *data_this_buffer;
+ u8 length_odd;
ASSERT (bogus_lengthp);
*bogus_lengthp = 0;
@@ -918,7 +919,7 @@ ip6_tcp_udp_icmp_compute_checksum (vlib_main_t * vm, vlib_buffer_t * p0,
/* Initialize checksum with ip header. */
sum0 = ip0->payload_length + clib_host_to_net_u16 (ip0->protocol);
payload_length_host_byte_order = clib_net_to_host_u16 (ip0->payload_length);
- data_this_buffer = (void *) (ip0 + 1);
+ data_this_buffer = (u8 *) (ip0 + 1);
for (i = 0; i < ARRAY_LEN (ip0->src_address.as_uword); i++)
{
@@ -971,14 +972,27 @@ ip6_tcp_udp_icmp_compute_checksum (vlib_main_t * vm, vlib_buffer_t * p0,
if (n_bytes_left == 0)
break;
+ ASSERT (p0->flags & VLIB_BUFFER_NEXT_PRESENT);
if (!(p0->flags & VLIB_BUFFER_NEXT_PRESENT))
{
*bogus_lengthp = 1;
return 0xfefe;
}
+
+ length_odd = (n_this_buffer & 1);
+
p0 = vlib_get_buffer (vm, p0->next_buffer);
data_this_buffer = vlib_buffer_get_current (p0);
n_this_buffer = clib_min (p0->current_length, n_bytes_left);
+
+ if (PREDICT_FALSE (length_odd))
+ {
+ /* Prepend a 0 or the resulting checksum will be incorrect. */
+ data_this_buffer--;
+ n_this_buffer++;
+ n_bytes_left++;
+ data_this_buffer[0] = 0;
+ }
}
sum16 = ~ip_csum_fold (sum0);