From patchwork Wed Mar 7 15:31:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Michelson X-Patchwork-Id: 882655 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zxHfc53mLz9ryJ for ; Thu, 8 Mar 2018 02:31:04 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 1BE7B119D; Wed, 7 Mar 2018 15:31:03 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id E89B01104 for ; Wed, 7 Mar 2018 15:31:01 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 402555F7 for ; Wed, 7 Mar 2018 15:31:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 68566402881B for ; Wed, 7 Mar 2018 15:31:00 +0000 (UTC) Received: from monae.redhat.com (ovpn-124-182.rdu2.redhat.com [10.10.124.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B5927C4C for ; Wed, 7 Mar 2018 15:31:00 +0000 (UTC) From: Mark Michelson To: dev@openvswitch.org Date: Wed, 7 Mar 2018 09:31:00 -0600 Message-Id: <20180307153100.23342-1-mmichels@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 07 Mar 2018 15:31:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 07 Mar 2018 15:31:00 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mmichels@redhat.com' RCPT:'' X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] ovn: Calculate UDP checksum for DNS over IPv6 X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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 --- 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 2a3f7d3f3..75516bf4e 100644 --- a/ovn/controller/pinctrl.c +++ b/ovn/controller/pinctrl.c @@ -929,6 +929,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 8ee3bf0b5..df8c538fd 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -7116,8 +7116,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