From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B8D3645C85; Tue, 5 Nov 2024 09:59:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4C3B04025D; Tue, 5 Nov 2024 09:59:35 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id B9AFF400EF for ; Tue, 5 Nov 2024 09:59:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730797173; 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; bh=SKOrEfp9st+cC7UYSJc4rAKNAyBjysG8GMFXp3vC2Vs=; b=MKHqIcwXDYQ6bGOo6fLNfGOYMUqeA5AQSm7LdeYqrdqnYIKMsrfV1zzs2oYJAADrfNMpoW rEVClrgMI6DWERUfXLlMXzfPTL+GSnuA7W447iRm338Y7rkAY61HMWKLi+FQfX0ibUoi0G X4j5izUrQwzo1Sk1GTuxVmqgkWQrRQo= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-650-GEJSB-q1MGK2xrZ3V8CN5A-1; Tue, 05 Nov 2024 03:59:30 -0500 X-MC-Unique: GEJSB-q1MGK2xrZ3V8CN5A-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 588741955F3C; Tue, 5 Nov 2024 08:59:28 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.57]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 072571956086; Tue, 5 Nov 2024 08:59:25 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Stephen Hemminger , Chengwen Feng , Bruce Richardson , =?UTF-8?q?Morten=20Br=C3=B8rup?= Subject: [PATCH] net: fix IPv4 cksum simple function Date: Tue, 5 Nov 2024 09:59:11 +0100 Message-ID: <20241105085912.4148208-1-david.marchand@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The new function breaks compilation with -Wcast-align. In file included from /home/runner/work/ovs/ovs/dpdk-dir/include/rte_ip.h:9: /home/runner/work/ovs/ovs/dpdk-dir/include/rte_ip4.h:191:10: error: cast from 'const uint8_t *' (aka 'const unsigned char *') to 'const unaligned_uint16_t *' (aka 'const unsigned short *') increases required alignment from 1 to 2 [-Werror,-Wcast-align] v16_h = (const unaligned_uint16_t *)&ipv4_hdr->version_ihl; ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fix this by aligning rte_ipv4_hdr to two bytes, and point at the start of the structure rather than the first field (which happens to be 1 byte large). Fixes: f9e1d67f237a ("net: add IPv4 cksum function for simple cases") Signed-off-by: David Marchand --- doc/guides/rel_notes/release_24_11.rst | 2 ++ lib/net/rte_ip4.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/guides/rel_notes/release_24_11.rst b/doc/guides/rel_notes/release_24_11.rst index 53a5ffebe5..d0152c558c 100644 --- a/doc/guides/rel_notes/release_24_11.rst +++ b/doc/guides/rel_notes/release_24_11.rst @@ -291,6 +291,8 @@ API Changes releases: it handles key=value and only-key cases. * Both ``rte_kvargs_process`` and ``rte_kvargs_process_opt`` reject a NULL ``kvlist`` parameter. +* net: The IPv4 header structure ``rte_ipv4_hdr`` has been marked as two bytes aligned. + * net: The ICMP message types ``RTE_IP_ICMP_ECHO_REPLY`` and ``RTE_IP_ICMP_ECHO_REQUEST`` are marked as deprecated, and are replaced by ``RTE_ICMP_TYPE_ECHO_REPLY`` and ``RTE_ICMP_TYPE_ECHO_REQUEST``. diff --git a/lib/net/rte_ip4.h b/lib/net/rte_ip4.h index 4dd0058cc5..f9b8333332 100644 --- a/lib/net/rte_ip4.h +++ b/lib/net/rte_ip4.h @@ -39,7 +39,7 @@ extern "C" { /** * IPv4 Header */ -struct rte_ipv4_hdr { +struct __rte_aligned(2) rte_ipv4_hdr { __extension__ union { uint8_t version_ihl; /**< version and header length */ @@ -188,7 +188,7 @@ rte_ipv4_cksum_simple(const struct rte_ipv4_hdr *ipv4_hdr) * Compute the sum of successive 16-bit words of the IPv4 header, * skipping the checksum field of the header. */ - v16_h = (const unaligned_uint16_t *)&ipv4_hdr->version_ihl; + v16_h = (const uint16_t *)ipv4_hdr; ip_cksum = v16_h[0] + v16_h[1] + v16_h[2] + v16_h[3] + v16_h[4] + v16_h[6] + v16_h[7] + v16_h[8] + v16_h[9]; -- 2.46.2