Fix ip-udp encap checksum for ip6
Thanks to Chris Luke for reporting.
Change-Id: I4f2ac5bb0eb565738755ddb00e8c918134ff67b6
Signed-off-by: Florin Coras <fcoras@cisco.com>
diff --git a/vnet/vnet/ip/udp.h b/vnet/vnet/ip/udp.h
index 151f2a8..a699148 100644
--- a/vnet/vnet/ip/udp.h
+++ b/vnet/vnet/ip/udp.h
@@ -152,6 +152,8 @@
else
{
ip6_header_t * ip0;
+ int bogus0;
+
ip0 = vlib_buffer_get_current(b0);
/* Apply the encap string. */
@@ -164,6 +166,12 @@
/* Fix UDP length */
udp0 = (udp_header_t *)(ip0+1);
udp0->length = new_l0;
+
+ udp0->checksum = ip6_tcp_udp_icmp_compute_checksum (vm, b0, ip0, &bogus0);
+ ASSERT(bogus0 == 0);
+
+ if (udp0->checksum == 0)
+ udp0->checksum = 0xffff;
}
}
@@ -225,6 +233,8 @@
else
{
ip6_header_t * ip0, * ip1;
+ int bogus0, bogus1;
+
ip0 = vlib_buffer_get_current(b0);
ip1 = vlib_buffer_get_current(b1);
@@ -245,6 +255,16 @@
udp0->length = new_l0;
udp1->length = new_l1;
+
+ udp0->checksum = ip6_tcp_udp_icmp_compute_checksum (vm, b0, ip0, &bogus0);
+ udp1->checksum = ip6_tcp_udp_icmp_compute_checksum (vm, b1, ip1, &bogus1);
+ ASSERT(bogus0 == 0);
+ ASSERT(bogus1 == 0);
+
+ if (udp0->checksum == 0)
+ udp0->checksum = 0xffff;
+ if (udp1->checksum == 0)
+ udp1->checksum = 0xffff;
}
}