[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aCbAsCkTPMNE6Ogb@infradead.org>
Date: Thu, 15 May 2025 21:36:00 -0700
From: Christoph Hellwig <hch@...radead.org>
To: Eric Biggers <ebiggers@...nel.org>
Cc: netdev@...r.kernel.org, linux-nvme@...ts.infradead.org,
linux-sctp@...r.kernel.org, linux-rdma@...r.kernel.org,
linux-kernel@...r.kernel.org,
Daniel Borkmann <daniel@...earbox.net>,
Marcelo Ricardo Leitner <marcelo.leitner@...il.com>,
Sagi Grimberg <sagi@...mberg.me>, Ard Biesheuvel <ardb@...nel.org>
Subject: Re: [PATCH net-next 09/10] nvme-tcp: use crc32c() and
skb_copy_and_crc32c_datagram_iter()
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.
Powered by blists - more mailing lists