From patchwork Thu Feb 15 21:59:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Pattrick X-Patchwork-Id: 1899755 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GnHj82gC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TbTWQ5jdRz23j8 for ; Fri, 16 Feb 2024 09:00:02 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 901C8606C9; Thu, 15 Feb 2024 21:59:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TzDvmGM4Z3TE; Thu, 15 Feb 2024 21:59:57 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.9.56; helo=lists.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 601726061C Authentication-Results: smtp3.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GnHj82gC Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id 601726061C; Thu, 15 Feb 2024 21:59:57 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id EA78EC0DD2; Thu, 15 Feb 2024 21:59:56 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6EF1DC0037 for ; Thu, 15 Feb 2024 21:59:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 5FF1360689 for ; Thu, 15 Feb 2024 21:59:55 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id N6UvUlfyThM6 for ; Thu, 15 Feb 2024 21:59:54 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=170.10.129.124; helo=us-smtp-delivery-124.mimecast.com; envelope-from=mkp@redhat.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp3.osuosl.org 9D2596061C Authentication-Results: smtp3.osuosl.org; dmarc=pass (p=none dis=none) header.from=redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 9D2596061C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 9D2596061C for ; Thu, 15 Feb 2024 21:59:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708034393; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iOz6yH9K71wRXl4wGC52EuX3IbgKxxHIollyzPhQ2ss=; b=GnHj82gCRXmRxyXVbzRW05Nhk/mIn0tRZxqB6BmFl0XxmiE0rSlhFBnC05M5xraI0skZnt DbSQ7jcRsrYJyo41ZRmR5ce/nOwxUCNBUE3QtW3/B7pWpy3dXptAyQQiFoGBwJ8xgVXFqJ Y16QVlUUkGWtJlTWsL3sYh3diU97QjU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-131-r47bO1zaP-OkZWbYOYureQ-1; Thu, 15 Feb 2024 16:59:51 -0500 X-MC-Unique: r47bO1zaP-OkZWbYOYureQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A73AD85A588 for ; Thu, 15 Feb 2024 21:59:51 +0000 (UTC) Received: from mpattric.remote.csb (unknown [10.22.32.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF12F2166B32; Thu, 15 Feb 2024 21:59:50 +0000 (UTC) From: Mike Pattrick To: dev@openvswitch.org Date: Thu, 15 Feb 2024 16:59:44 -0500 Message-Id: <20240215215946.403341-2-mkp@redhat.com> In-Reply-To: <20240215215946.403341-1-mkp@redhat.com> References: <20240215215946.403341-1-mkp@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Cc: David Marchand Subject: [ovs-dev] [PATCH v3 2/5] netdev-linux: Only repair IP checksum in IPv4. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Previously a change was added to the vnet prepend code to solve for the case where no L4 checksum offloading was needed but the L3 checksum hadn't been calculated. But the added check didn't properly account for IPv6 traffic. Fixes: 85bcbbed839a ("userspace: Enable tunnel tests with TSO.") Reported-by: David Marchand Signed-off-by: Mike Pattrick --- lib/dp-packet.h | 18 +++++++++++++++++- lib/netdev-linux.c | 9 +++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lib/dp-packet.h b/lib/dp-packet.h index 802d3f385..770ddc1b9 100644 --- a/lib/dp-packet.h +++ b/lib/dp-packet.h @@ -1184,7 +1184,7 @@ dp_packet_hwol_is_tunnel_vxlan(struct dp_packet *b) /* Returns 'true' if packet 'b' is marked for outer IPv4 checksum offload. */ static inline bool -dp_packet_hwol_is_outer_ipv4_cksum(struct dp_packet *b) +dp_packet_hwol_is_outer_ipv4_cksum(const struct dp_packet *b) { return !!(*dp_packet_ol_flags_ptr(b) & DP_PACKET_OL_TX_OUTER_IP_CKSUM); } @@ -1384,6 +1384,22 @@ dp_packet_ip_checksum_bad(const struct dp_packet *p) DP_PACKET_OL_RX_IP_CKSUM_BAD; } +/* Return 'true' is packet 'b' is not encapsulated and is marked for IPv4 + * checksum offload, or if 'b' is encapsulated and the outer layer is marked + * for IPv4 checksum offload. IPv6 packets and non offloaded packets return + * 'false'. */ +static inline bool +dp_packet_hwol_l3_csum_ipv4_ol(const struct dp_packet *b) +{ + if (dp_packet_hwol_is_outer_ipv4(b)) { + return dp_packet_hwol_is_outer_ipv4_cksum(b); + } else if (!dp_packet_hwol_is_outer_ipv6(b)) { + return dp_packet_hwol_tx_ip_csum(b) && + !dp_packet_ip_checksum_good(b); + } + return false; +} + /* Calculate and set the IPv4 header checksum in packet 'p'. */ static inline void dp_packet_ip_set_header_csum(struct dp_packet *p, bool inner) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 8964cd670..bf91ef462 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -7199,10 +7199,11 @@ netdev_linux_prepend_vnet_hdr(struct dp_packet *b, int mtu) /* The packet has good L4 checksum. No need to validate again. */ vnet->csum_start = vnet->csum_offset = (OVS_FORCE __virtio16) 0; vnet->flags = VIRTIO_NET_HDR_F_DATA_VALID; - if (!dp_packet_ip_checksum_good(b)) { - /* It is possible that L4 is good but the IP checksum isn't - * complete. For example in the case of UDP encapsulation of an ARP - * packet where the UDP checksum is 0. */ + + /* It is possible that L4 is good but the IPv4 checksum isn't + * complete. For example in the case of UDP encapsulation of an ARP + * packet where the UDP checksum is 0. */ + if (dp_packet_hwol_l3_csum_ipv4_ol(b)) { dp_packet_ip_set_header_csum(b, false); } } else if (dp_packet_hwol_tx_l4_checksum(b)) {