From: Christoph Hellwig <hch@infradead.org>
To: Eric Biggers <ebiggers@kernel.org>
Cc: netdev@vger.kernel.org, linux-nvme@lists.infradead.org,
linux-sctp@vger.kernel.org, linux-rdma@vger.kernel.org,
linux-kernel@vger.kernel.org,
Daniel Borkmann <daniel@iogearbox.net>,
Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
Sagi Grimberg <sagi@grimberg.me>,
Ard Biesheuvel <ardb@kernel.org>
Subject: Re: [PATCH net-next 09/10] nvme-tcp: use crc32c() and skb_copy_and_crc32c_datagram_iter()
Date: Thu, 15 May 2025 21:36:00 -0700 [thread overview]
Message-ID: <aCbAsCkTPMNE6Ogb@infradead.org> (raw)
In-Reply-To: <20250511004110.145171-10-ebiggers@kernel.org>
On Sat, May 10, 2025 at 05:41:09PM -0700, Eric Biggers wrote:
> +static inline void nvme_tcp_ddgst_init(u32 *crcp)
> {
> + *crcp = ~0;
> }
This helper looks really odd. It coud just return the value, or
we could just assign it there using a seed define, e.g. this is what
XFS does:
#define XFS_CRC_SEED (~(uint32_t)0)
nd that might in fact be worth lifting to common code with a good
comment on why all-d is used as the typical crc32 seed.
> +static inline void nvme_tcp_ddgst_final(u32 *crcp, __le32 *ddgst)
> {
> + *ddgst = cpu_to_le32(~*crcp);
> +}
Just return the big endian version calculated here?
> +static inline void nvme_tcp_hdgst(void *pdu, size_t len)
> +{
> + put_unaligned_le32(~crc32c(~0, pdu, len), pdu + len);
> }
This could also use the seed define mentioned above.
> recv_digest = *(__le32 *)(pdu + hdr->hlen);
> - nvme_tcp_hdgst(queue->rcv_hash, pdu, pdu_len);
> + nvme_tcp_hdgst(pdu, pdu_len);
> exp_digest = *(__le32 *)(pdu + hdr->hlen);
> if (recv_digest != exp_digest) {
This code looks really weird, as it samples the on-the-wire digest
first and then overwrites it. I'd expect to just check the on-the-wire
on against one calculated in a local variable.
Sagi, any idea what is going on here?
Otherwise this looks great. It's always good to get rid of the
horrendous crypto API calls.
next prev parent reply other threads:[~2025-05-16 4:36 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-11 0:41 [PATCH net-next 00/10] net: faster and simpler CRC32C computation Eric Biggers
2025-05-11 0:41 ` [PATCH net-next 01/10] net: introduce CONFIG_NET_CRC32C Eric Biggers
2025-05-11 0:41 ` [PATCH net-next 02/10] net: add skb_crc32c() Eric Biggers
2025-05-11 0:41 ` [PATCH net-next 03/10] net: use skb_crc32c() in skb_crc32c_csum_help() Eric Biggers
2025-05-11 0:41 ` [PATCH net-next 04/10] RDMA/siw: use skb_crc32c() instead of __skb_checksum() Eric Biggers
2025-05-15 20:02 ` Bart Van Assche
2025-05-15 20:12 ` Eric Biggers
2025-05-16 10:42 ` Bernard Metzler
2025-05-19 9:04 ` Bernard Metzler
2025-05-20 13:18 ` Leon Romanovsky
2025-05-20 15:18 ` Eric Biggers
2025-05-21 10:38 ` Leon Romanovsky
2025-05-11 0:41 ` [PATCH net-next 05/10] sctp: " Eric Biggers
2025-05-11 0:41 ` [PATCH net-next 06/10] net: fold __skb_checksum() into skb_checksum() Eric Biggers
2025-05-11 0:41 ` [PATCH net-next 07/10] lib/crc32: remove unused support for CRC32C combination Eric Biggers
2025-05-11 0:41 ` [PATCH net-next 08/10] net: add skb_copy_and_crc32c_datagram_iter() Eric Biggers
2025-05-13 21:41 ` Jakub Kicinski
2025-05-15 18:09 ` Eric Biggers
2025-05-11 0:41 ` [PATCH net-next 09/10] nvme-tcp: use crc32c() and skb_copy_and_crc32c_datagram_iter() Eric Biggers
2025-05-16 4:36 ` Christoph Hellwig [this message]
2025-05-16 5:31 ` Eric Biggers
2025-05-16 6:06 ` Christoph Hellwig
2025-05-17 17:45 ` Eric Biggers
2025-05-17 20:32 ` Sagi Grimberg
2025-05-17 9:58 ` Sagi Grimberg
2025-05-17 17:29 ` Eric Biggers
2025-05-17 20:30 ` Sagi Grimberg
2025-05-11 0:41 ` [PATCH net-next 10/10] net: remove skb_copy_and_hash_datagram_iter() Eric Biggers
2025-05-11 16:30 ` [PATCH net-next 00/10] net: faster and simpler CRC32C computation Andrew Lunn
2025-05-11 17:29 ` Eric Biggers
2025-05-11 21:22 ` Andrew Lunn
2025-05-11 21:45 ` Ard Biesheuvel
2025-05-11 23:07 ` Eric Biggers
2025-05-15 19:21 ` David Laight
2025-05-15 19:50 ` Eric Biggers
2025-05-13 21:40 ` Jakub Kicinski
2025-05-15 18:10 ` Eric Biggers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aCbAsCkTPMNE6Ogb@infradead.org \
--to=hch@infradead.org \
--cc=ardb@kernel.org \
--cc=daniel@iogearbox.net \
--cc=ebiggers@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=linux-rdma@vger.kernel.org \
--cc=linux-sctp@vger.kernel.org \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).