You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openvswitch/0001-ovn-Calculate-UDP-chec...

62 lines
2.2 KiB

From b91dd29864d853228add9d9d432ca3d1bbc4fa43 Mon Sep 17 00:00:00 2001
From: Mark Michelson <mmichels@redhat.com>
Date: Wed, 7 Mar 2018 09:31:00 -0600
Subject: [PATCH] ovn: Calculate UDP checksum for DNS over IPv6
Unlike IPv4, IPv6 mandates the calculation of the UDP checksum. For DNS
resolution in OVN, we were setting the checksum to 0, which results in
errors.
This patch fixes the problem by calculating the checksum for DNS over
IPv6. It also alters the applicable test by skipping the checksum when
comparing the expected and actual packets.
Signed-off-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
---
ovn/controller/pinctrl.c | 11 +++++++++++
tests/ovn.at | 5 +++--
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c
index 9fc7a0326..980f51fc9 100644
--- a/ovn/controller/pinctrl.c
+++ b/ovn/controller/pinctrl.c
@@ -927,6 +927,17 @@ pinctrl_handle_dns_lookup(
} else {
struct ovs_16aligned_ip6_hdr *nh = dp_packet_l3(&pkt_out);
nh->ip6_plen = htons(new_l4_size);
+
+ /* IPv6 needs UDP checksum calculated */
+ uint32_t csum;
+ csum = packet_csum_pseudoheader6(nh);
+ csum = csum_continue(csum, out_udp, dp_packet_size(&pkt_out) -
+ ((const unsigned char *)out_udp -
+ (const unsigned char *)eth));
+ out_udp->udp_csum = csum_finish(csum);
+ if (!out_udp->udp_csum) {
+ out_udp->udp_csum = htons(0xffff);
+ }
}
pin->packet = dp_packet_data(&pkt_out);
diff --git a/tests/ovn.at b/tests/ovn.at
index b57a93d3f..83c0e9d6e 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -7099,8 +7099,9 @@ test_dns6 1 f00000000001 f000000000f0 $src_ip $dst_ip $dns_reply $dns_req_data $
OVS_WAIT_UNTIL([test 9 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`])
$PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets
-cat 1.expected > expout
-AT_CHECK([cat 1.packets], [0], [expout])
+# Skipping the UDP checksum.
+cat 1.expected | cut -c 1-120,125- > expout
+AT_CHECK([cat 1.packets | cut -c 1-120,125-], [0], [expout])
reset_pcap_file hv1-vif1 hv1/vif1
reset_pcap_file hv1-vif2 hv1/vif2
--
2.14.3