From patchwork Sat Feb 23 01:17:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Darrell Ball X-Patchwork-Id: 1047243 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=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IYNr5PDM"; dkim-atps=neutral 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 445r766nrQz9sBL for ; Sat, 23 Feb 2019 12:22:58 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A2E0A53CE; Sat, 23 Feb 2019 01:22:31 +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 0C9D24B08 for ; Sat, 23 Feb 2019 01:17:53 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id B55FA3D0 for ; Sat, 23 Feb 2019 01:17:52 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id i19so1876320pfd.0 for ; Fri, 22 Feb 2019 17:17:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4iewVQlI7cvrfadbgxqP2cuMAtaZACwCLqTLqDtN1s4=; b=IYNr5PDM7KMrK3bevIH6P3+xPom8SV1WLCqFA76kVa2nv7hGjLAiAjhUTkCUpgGGhD 9wt2dKpPWpnQxECryFvL7M4KGCSGT0WilIQHrFX9NBBnpN9iYhRVTs0A8Fs3GhETwqU4 pxz8BQdC8muuQ8ao68uECekHpcnzviWcD5aQhlmiOD8XBj/E905xNbuNEpzcZjoCK/+S wFjNXAaAeTGo/FUtsqj+7VnoGivQ91hQgCNT3ghWAf4qhXZPQqVxZUzhQgqwwbzPprtl 3/dM2nGXp3NvVdi65mtNOeHpd3eQPuMtkTiXu4Z77E7Yi8X7nQMLHx6WBVMsRVNQX4+q G8eg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4iewVQlI7cvrfadbgxqP2cuMAtaZACwCLqTLqDtN1s4=; b=loloFggB/Ame1MmTWmuE/qj5284HkAS3i6UgJ4vwTy65Zn5Xmc1LGiBfvTmZMC6twG PBV5wdT1qkv5sL6Cd1vDM7m12KD/XHSnQf3mcgSS2YRjcbH6E6ouNE9CF4b+Xi/xFPYP ir5CHKkrZLBBfVuAUMW0+sxXHtrf13ax45nlJcty3hlLabC2O7iWbQKS80cTyLeVztb6 P4bcjG9xQuG9w57BlzJOUdA2ofIenYEWvTVLeba6ux47VIF6inpjSgq/y+xAjoodNpHq 3PfeqKkObZqWnlyYAWU7TLphU/8Ygaq8oHpQd0xBsWFzsnIcYfaYP36lyiReFOrIeBKR pfjA== X-Gm-Message-State: AHQUAuYorvo1Wq0HUc+nwWoc2JJfsHKG6PJcvh1XwWmOKRswZblh6J1V JpGzGketfgxTP9K4OXUwqvY= X-Google-Smtp-Source: AHgI3IbPpc9zFCOvTCjhY8oDgtFdqjhcBEPQQm+i/xtgEK674q3YFNdzgDb1Q6PCEUmM0ljm8ZsKLQ== X-Received: by 2002:aa7:9152:: with SMTP id 18mr6941380pfi.215.1550884672307; Fri, 22 Feb 2019 17:17:52 -0800 (PST) Received: from ubuntu.localdomain ([208.91.2.2]) by smtp.gmail.com with ESMTPSA id o76sm6329760pfa.156.2019.02.22.17.17.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 22 Feb 2019 17:17:51 -0800 (PST) From: Darrell Ball To: dlu998@gmail.com, dev@openvswitch.org Date: Fri, 22 Feb 2019 17:17:42 -0800 Message-Id: <1550884662-119149-2-git-send-email-dlu998@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1550884662-119149-1-git-send-email-dlu998@gmail.com> References: <1550884662-119149-1-git-send-email-dlu998@gmail.com> X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [patch v2 2/2] conntrack: Fix L4 csum for V6 extension hdr pkts. 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 It is a day one issue that got copied to subsequent code. Fixes: a489b16854b5 ("conntrack: New userspace connection tracker.") Fixes: bd5e81a0e596 ("Userspace Datapath: Add ALG infra and FTP.") CC: Daniele Di Proietto Signed-off-by: Darrell Ball --- Fix will need to be backported as far back as 2.6 and the fix will need separate patches for some earlier releases, which I will do. v2: Fix compiler warnings. Split out from another series; this is version 2 of this patch itself. lib/conntrack.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/lib/conntrack.c b/lib/conntrack.c index 4d76552..4028ba9 100644 --- a/lib/conntrack.c +++ b/lib/conntrack.c @@ -686,10 +686,9 @@ reverse_nat_packet(struct dp_packet *pkt, const struct conn *conn) &conn->key.dst.addr.ipv6, true); } reverse_pat_packet(pkt, conn); - uint32_t icmp6_csum = packet_csum_pseudoheader6(nh6); icmp6->icmp6_base.icmp6_cksum = 0; - icmp6->icmp6_base.icmp6_cksum = csum_finish( - csum_continue(icmp6_csum, icmp6, tail - (char *) icmp6 - pad)); + icmp6->icmp6_base.icmp6_cksum = packet_csum_upperlayer6(nh6, icmp6, + IPPROTO_ICMPV6, tail - (char *) icmp6 - pad); } pkt->l3_ofs = orig_l3_ofs; pkt->l4_ofs = orig_l4_ofs; @@ -1591,19 +1590,14 @@ static inline bool checksum_valid(const struct conn_key *key, const void *data, size_t size, const void *l3) { - uint32_t csum = 0; - if (key->dl_type == htons(ETH_TYPE_IP)) { - csum = packet_csum_pseudoheader(l3); + uint32_t csum = packet_csum_pseudoheader(l3); + return csum_finish(csum_continue(csum, data, size)) == 0; } else if (key->dl_type == htons(ETH_TYPE_IPV6)) { - csum = packet_csum_pseudoheader6(l3); + return packet_csum_upperlayer6(l3, data, key->nw_proto, size) == 0; } else { return false; } - - csum = csum_continue(csum, data, size); - - return csum_finish(csum) == 0; } static inline bool @@ -3261,16 +3255,14 @@ handle_ftp_ctl(struct conntrack *ct, const struct conn_lookup_ctx *ctx, } th->tcp_csum = 0; - uint32_t tcp_csum; if (ctx->key.dl_type == htons(ETH_TYPE_IPV6)) { - tcp_csum = packet_csum_pseudoheader6(nh6); + th->tcp_csum = packet_csum_upperlayer6(nh6, th, ctx->key.nw_proto, + dp_packet_l4_size(pkt)); } else { - tcp_csum = packet_csum_pseudoheader(l3_hdr); + uint32_t tcp_csum = packet_csum_pseudoheader(l3_hdr); + th->tcp_csum = csum_finish( + csum_continue(tcp_csum, th, dp_packet_l4_size(pkt))); } - const char *tail = dp_packet_tail(pkt); - uint8_t pad = dp_packet_l2_pad_size(pkt); - th->tcp_csum = csum_finish( - csum_continue(tcp_csum, th, tail - (char *) th - pad)); if (seq_skew) { conn_seq_skew_set(ct, &ec->key, now, seq_skew + ec->seq_skew,