From: Xin Long <lucien.xin@gmail.com>
To: Paolo Abeni <pabeni@redhat.com>
Cc: network dev <netdev@vger.kernel.org>,
quic@lists.linux.dev, davem@davemloft.net, kuba@kernel.org,
Eric Dumazet <edumazet@google.com>,
Simon Horman <horms@kernel.org>,
Stefan Metzmacher <metze@samba.org>,
Moritz Buhl <mbuhl@openbsd.org>,
Tyler Fanelli <tfanelli@redhat.com>,
Pengtao He <hepengtao@xiaomi.com>,
linux-cifs@vger.kernel.org, Steve French <smfrench@gmail.com>,
Namjae Jeon <linkinjeon@kernel.org>,
Paulo Alcantara <pc@manguebit.com>, Tom Talpey <tom@talpey.com>,
kernel-tls-handshake@lists.linux.dev,
Chuck Lever <chuck.lever@oracle.com>,
Jeff Layton <jlayton@kernel.org>,
Benjamin Coddington <bcodding@redhat.com>,
Steve Dickson <steved@redhat.com>, Hannes Reinecke <hare@suse.de>,
Alexander Aring <aahringo@redhat.com>,
David Howells <dhowells@redhat.com>,
Matthieu Baerts <matttbe@kernel.org>,
John Ericson <mail@johnericson.me>,
Cong Wang <xiyou.wangcong@gmail.com>,
"D . Wythe" <alibuda@linux.alibaba.com>,
Jason Baron <jbaron@akamai.com>,
illiliti <illiliti@protonmail.com>,
Sabrina Dubroca <sd@queasysnail.net>,
Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>,
Daniel Stenberg <daniel@haxx.se>,
Andy Gospodarek <andrew.gospodarek@broadcom.com>
Subject: Re: [PATCH net-next v3 03/15] quic: provide common utilities and data structures
Date: Tue, 23 Sep 2025 12:06:41 -0400 [thread overview]
Message-ID: <CADvbK_e20TrcgprXmnZzvoEO6yzoo4Zx7B0qFS0kQPT8Sf63LQ@mail.gmail.com> (raw)
In-Reply-To: <871ed254-c3d8-49aa-9aac-eeb72e82f55d@redhat.com>
On Tue, Sep 23, 2025 at 7:21 AM Paolo Abeni <pabeni@redhat.com> wrote:
>
> On 9/19/25 12:34 AM, Xin Long wrote:
> > This patch provides foundational data structures and utilities used
> > throughout the QUIC stack.
> >
> > It introduces packet header types, connection ID support, and address
> > handling. Hash tables are added to manage socket lookup and connection
> > ID mapping.
> >
> > A flexible binary data type is provided, along with helpers for parsing,
> > matching, and memory management. Helpers for encoding and decoding
> > transport parameters and frames are also included.
> >
> > Signed-off-by: Xin Long <lucien.xin@gmail.com>
> > ---
> > v3:
> > - Rework hashtables: split into two types and size them based on
> > totalram_pages(), similar to SCTP (reported by Paolo).
> > - struct quic_shash_table: use rwlock instead of spinlock.
>
> Why? rwlock usage should be avoided in networking (as it's unfair, see
> the many refactors replacing rwlock with rcu/plain spinlock)
Interesting, I thought rwlock works better than spinlock in this case.
I will change back to spinlock.
>
> [...]
> > +
> > +static int quic_uhash_table_init(struct quic_uhash_table *ht, u32 max_size, int order)
> > +{
> > + int i, max_order, size;
> > +
> > + /* Same sizing logic as in quic_shash_table_init(). */
> > + max_order = get_order(max_size * sizeof(struct quic_uhash_head));
> > + order = min(order, max_order);
> > + do {
> > + ht->hash = (struct quic_uhash_head *)
> > + __get_free_pages(GFP_KERNEL | __GFP_NOWARN, order);
> > + } while (!ht->hash && --order > 0);
>
> You can avoid a little complexity, and see more consistent behaviour,
> using plain vmalloc() or alloc_large_system_hash() with no fallback.
>
I wanted to use alloc_large_system_hash(), but the memory allocated
by it is usually NOT meant to be freed at runtime. I don't see a free_
function to do it either.
If QUIC works as a kernel module, what should I do with this memory
in module_exit()?
>
> > +/* rfc9000#section-a.3: DecodePacketNumber()
> > + *
> > + * Reconstructs the full packet number from a truncated one.
> > + */
> > +s64 quic_get_num(s64 max_pkt_num, s64 pkt_num, u32 n)
> > +{
> > + s64 expected = max_pkt_num + 1;
> > + s64 win = BIT_ULL(n * 8);
> > + s64 hwin = win / 2;
> > + s64 mask = win - 1;
> > + s64 cand;
> > +
> > + cand = (expected & ~mask) | pkt_num;
> > + if (cand <= expected - hwin && cand < (1ULL << 62) - win)
> > + return cand + win;
> > + if (cand > expected + hwin && cand >= win)
> > + return cand - win;
> > + return cand;
>
> The above is a bit obscure to me; replacing magic nubers (62) with macro
> could help. Some more comments also would do.
>
The code is exactly from the commented doc:
/* rfc9000#section-a.3: DecodePacketNumber()
See:
https://datatracker.ietf.org/doc/html/rfc9000#section-a.3
I will bring some comments from there.
Thanks.
next prev parent reply other threads:[~2025-09-23 16:06 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-18 22:34 [PATCH net-next v3 00/15] net: introduce QUIC infrastructure and core subcomponents Xin Long
2025-09-18 22:34 ` [PATCH net-next v3 01/15] net: define IPPROTO_QUIC and SOL_QUIC constants Xin Long
2025-09-18 22:34 ` [PATCH net-next v3 02/15] net: build socket infrastructure for QUIC protocol Xin Long
2025-09-23 11:07 ` Paolo Abeni
2025-09-23 15:47 ` Xin Long
2025-09-25 15:53 ` Paolo Abeni
2025-09-18 22:34 ` [PATCH net-next v3 03/15] quic: provide common utilities and data structures Xin Long
2025-09-23 9:06 ` Simon Horman
2025-09-23 15:49 ` Xin Long
2025-09-23 11:21 ` Paolo Abeni
2025-09-23 16:06 ` Xin Long [this message]
2025-09-25 15:50 ` Paolo Abeni
2025-09-18 22:34 ` [PATCH net-next v3 04/15] quic: provide family ops for address and protocol Xin Long
2025-09-23 11:30 ` Paolo Abeni
2025-09-23 16:15 ` Xin Long
2025-09-18 22:34 ` [PATCH net-next v3 05/15] quic: provide quic.h header files for kernel and userspace Xin Long
2025-09-18 22:34 ` [PATCH net-next v3 06/15] quic: add stream management Xin Long
2025-09-23 9:09 ` Simon Horman
2025-09-23 17:30 ` Xin Long
2025-09-23 13:39 ` Paolo Abeni
2025-09-23 17:57 ` Xin Long
2025-09-25 16:03 ` Paolo Abeni
2025-09-18 22:34 ` [PATCH net-next v3 07/15] quic: add connection id management Xin Long
2025-09-18 22:34 ` [PATCH net-next v3 08/15] quic: add path management Xin Long
2025-09-18 22:34 ` [PATCH net-next v3 09/15] quic: add congestion control Xin Long
2025-09-23 13:55 ` Paolo Abeni
2025-09-23 19:37 ` Xin Long
2025-09-18 22:34 ` [PATCH net-next v3 10/15] quic: add packet number space Xin Long
2025-09-18 22:35 ` [PATCH net-next v3 11/15] quic: add crypto key derivation and installation Xin Long
2025-09-18 22:35 ` [PATCH net-next v3 12/15] quic: add crypto packet encryption and decryption Xin Long
2025-09-18 22:35 ` [PATCH net-next v3 13/15] quic: add timer management Xin Long
2025-09-18 22:35 ` [PATCH net-next v3 14/15] quic: add frame encoder and decoder base Xin Long
2025-09-18 22:35 ` [PATCH net-next v3 15/15] quic: add packet builder and parser base Xin Long
2025-09-19 6:43 ` [PATCH net-next v3 00/15] net: introduce QUIC infrastructure and core subcomponents Hannes Reinecke
2025-09-19 14:41 ` Xin Long
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=CADvbK_e20TrcgprXmnZzvoEO6yzoo4Zx7B0qFS0kQPT8Sf63LQ@mail.gmail.com \
--to=lucien.xin@gmail.com \
--cc=aahringo@redhat.com \
--cc=alibuda@linux.alibaba.com \
--cc=andrew.gospodarek@broadcom.com \
--cc=bcodding@redhat.com \
--cc=chuck.lever@oracle.com \
--cc=daniel@haxx.se \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=edumazet@google.com \
--cc=hare@suse.de \
--cc=hepengtao@xiaomi.com \
--cc=horms@kernel.org \
--cc=illiliti@protonmail.com \
--cc=jbaron@akamai.com \
--cc=jlayton@kernel.org \
--cc=kernel-tls-handshake@lists.linux.dev \
--cc=kuba@kernel.org \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=mail@johnericson.me \
--cc=marcelo.leitner@gmail.com \
--cc=matttbe@kernel.org \
--cc=mbuhl@openbsd.org \
--cc=metze@samba.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pc@manguebit.com \
--cc=quic@lists.linux.dev \
--cc=sd@queasysnail.net \
--cc=smfrench@gmail.com \
--cc=steved@redhat.com \
--cc=tfanelli@redhat.com \
--cc=tom@talpey.com \
--cc=xiyou.wangcong@gmail.com \
/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