From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 318FC26C3A5 for ; Tue, 23 Sep 2025 15:47:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758642441; cv=none; b=ighLwOCS/UvvQvKjAO44oVOnwiC4wEvj1vb6BtcnJtikYwEGFKOLZY2epOkWYkDW4NL092xUrqRcHZ+ng1sWCbgbQz6YWKY0WqzrImPOce/SKhevSvy5RsDiBbsI2WBIvCq7iGau0bcBvfqv+iX3LYFUHLMPeF//nPAyX3ncDt0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758642441; c=relaxed/simple; bh=9p9i27tUyKdfKZGTPyYzDE0lmLfpf9V2AqPccZf7Pk4=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=sTGWjc3p58+LyF/1OtVxIOiTZ03oFAWKWQe/SfSiauxvqLPTEmquY5d6PAdf6l5E42YYuCGz4R9ciBSxn220CS5HYDhc1L/eXu1Xoqu0uy7iio8uau8eBpusDkGvfqUgZH4ZHQ7gmiSDjeh0YzPBG/AMebt5laL7DHL49XAF2tE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=EfN4LPFx; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EfN4LPFx" Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-2698384978dso48503095ad.0 for ; Tue, 23 Sep 2025 08:47:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1758642437; x=1759247237; darn=lists.linux.dev; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=yhpqH9TkrxXvAreo6l0vcwYoZQHmwa+llxfXYxYt+Qw=; b=EfN4LPFxBr2iOSA3in3U9+4QQ3j4668rKBWUAZ1314UZ/3e3BBYovgkbg5VPAsrcJY mpUL3o+yy9HPY85RlFJNeIAv6tVc5vem/T+ejNkFImBN50lS7LlQeJtYr06YK40/bkrm SH9hfnZ0XZDc48cfznLlbf0ORBujtg2Hh/0CEK1LWBhQVvP3fImqdSat8/V/O7hvOqr2 VGmhLet/S2a7aX83QJzLG1KnoiiLCMWimQVFaYlhXl4r7DttL1h8dhdXZHljTBF1nGjo a5Ei1rxZVhFfGMrq1bvMjaShPL/kE4IdMHfeVGfCIPc/oahA16BL7VzK1v24Qecxuhjv oFNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758642437; x=1759247237; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yhpqH9TkrxXvAreo6l0vcwYoZQHmwa+llxfXYxYt+Qw=; b=eH/gvRJIQ8I0qiq62+tYfrnvFfAk4dbcG1jp1hkgixuGw6XGTzfwOcQrHlYeLOdyro szpyJKdAM51XcLmWS+C4ifoiGLC1+TWKysGdDIlJlJCXHf69PH1sDi33AwXG6j//ECRW auK2w5VjwBq7qrpTsu1craRFr84d/dtqkJhNY4cjbBp8lg3bYdkbeX2kcGX2RwtHQWdM Swp1lmg/jJ3u4Icike0Mabau3LtTKIoCwYUhT+nOGFhup8PSmnSVRHn3Y03q8/WIxK84 4sohHSv6KBkKrd5AQD7ebyLvB66ZU7i0ebyn2QhLb2b4vivp7BfITBMtQhR6ke6J52xG tL9g== X-Forwarded-Encrypted: i=1; AJvYcCVnRpNSH9+B31vW3pH67it1bkAClLyC7y7u7EB0/rv9bvdJ/fKvNf9og9UralwFb0ITz8nm@lists.linux.dev X-Gm-Message-State: AOJu0Yz+G15K4LtlvIV4TM70aWTn64Djbhr0Y1pzE/hhYRlLlILU6Kxd 0rZZhqixpM42F2lXCKti9cuVPvcKO741B9Zx4QzXQXF4Vl0mMS5osUy+IlGtz7s9zkXDG98MsT8 IzFVIbSxQH7E75P/drqotTZrMJu1jq5g= X-Gm-Gg: ASbGncuEjlR446yxsyn9DJti027olLkMRFnukIqyZiX/+qTud3e9Sr6ntAAwYtl8/e1 4opOoCLGgk+zHRv8M3w0CtPtrY/3klH4fnTm3DTZTh5qNOSEihAGrZnH3Klhq+86PE9fuDzrwO+ vJGXVkNX8v4E6tOs/IMXLSicyd7Nc7NAH9c1ugI9YuAwW2ooM/tMZ4Ib+Vx3ow9g3SwI/0LEdZJ mRCdZ/nvAkyg4sJieFU/xIBpHn68nBJi7e+hxortA== X-Google-Smtp-Source: AGHT+IFN/oaB5/gk3KWElKiAaSQb1o1xjeVkko+CwZ/pASyULfoho/ZKUXbJLQUPfB5WBG+juhRExqZmRAnXZkeFJw0= X-Received: by 2002:a17:902:cf07:b0:26c:bcb5:1573 with SMTP id d9443c01a7336-27cc7120837mr31767975ad.53.1758642437350; Tue, 23 Sep 2025 08:47:17 -0700 (PDT) Precedence: bulk X-Mailing-List: quic@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <7fa38c12-eece-45ae-87b2-da1445c62134@redhat.com> In-Reply-To: <7fa38c12-eece-45ae-87b2-da1445c62134@redhat.com> From: Xin Long Date: Tue, 23 Sep 2025 11:47:05 -0400 X-Gm-Features: AS18NWDVh9Ut3oT-GZAbfWLi8dW5scSVH2ja6lUmEjpU4ERb5oyr4BIw0IFHYeE Message-ID: Subject: Re: [PATCH net-next v3 02/15] net: build socket infrastructure for QUIC protocol To: Paolo Abeni Cc: network dev , quic@lists.linux.dev, davem@davemloft.net, kuba@kernel.org, Eric Dumazet , Simon Horman , Stefan Metzmacher , Moritz Buhl , Tyler Fanelli , Pengtao He , linux-cifs@vger.kernel.org, Steve French , Namjae Jeon , Paulo Alcantara , Tom Talpey , kernel-tls-handshake@lists.linux.dev, Chuck Lever , Jeff Layton , Benjamin Coddington , Steve Dickson , Hannes Reinecke , Alexander Aring , David Howells , Matthieu Baerts , John Ericson , Cong Wang , "D . Wythe" , Jason Baron , illiliti , Sabrina Dubroca , Marcelo Ricardo Leitner , Daniel Stenberg , Andy Gospodarek Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Sep 23, 2025 at 7:07=E2=80=AFAM Paolo Abeni wro= te: > > On 9/19/25 12:34 AM, Xin Long wrote: > > This patch lays the groundwork for QUIC socket support in the kernel. > > It defines the core structures and protocol hooks needed to create > > QUIC sockets, without implementing any protocol behavior at this stage. > > > > Basic integration is included to allow building the module via > > CONFIG_IP_QUIC=3Dm. > > > > This provides the scaffolding necessary for adding actual QUIC socket > > behavior in follow-up patches. > > > > Signed-off-by: Pengtao He > > Signed-off-by: Xin Long > > --- > > v3: > > - Kconfig: add 'default n' for IP_QUIC (reported by Paolo). > > - quic_disconnect(): return -EOPNOTSUPP (suggested by Paolo). > > - quic_init/destroy_sock(): drop local_bh_disable/enable() calls (not= ed > > by Paolo). > > - sysctl: add alpn_demux option to en/disable ALPN-based demux. > > - SNMP: remove SNMP_MIB_SENTINEL, switch to > > snmp_get_cpu_field_batch_cnt() to align with latest net-next change= s. > > --- > > net/Kconfig | 1 + > > net/Makefile | 1 + > > net/quic/Kconfig | 36 +++++ > > net/quic/Makefile | 8 + > > net/quic/protocol.c | 379 ++++++++++++++++++++++++++++++++++++++++++++ > > net/quic/protocol.h | 56 +++++++ > > net/quic/socket.c | 207 ++++++++++++++++++++++++ > > net/quic/socket.h | 79 +++++++++ > > 8 files changed, 767 insertions(+) > > create mode 100644 net/quic/Kconfig > > create mode 100644 net/quic/Makefile > > create mode 100644 net/quic/protocol.c > > create mode 100644 net/quic/protocol.h > > create mode 100644 net/quic/socket.c > > create mode 100644 net/quic/socket.h > > > > diff --git a/net/Kconfig b/net/Kconfig > > index d5865cf19799..1205f5b7cf59 100644 > > --- a/net/Kconfig > > +++ b/net/Kconfig > > @@ -249,6 +249,7 @@ source "net/bridge/netfilter/Kconfig" > > > > endif # if NETFILTER > > > > +source "net/quic/Kconfig" > > source "net/sctp/Kconfig" > > source "net/rds/Kconfig" > > source "net/tipc/Kconfig" > > diff --git a/net/Makefile b/net/Makefile > > index aac960c41db6..7c6de28e9aa5 100644 > > --- a/net/Makefile > > +++ b/net/Makefile > > @@ -42,6 +42,7 @@ obj-$(CONFIG_PHONET) +=3D phonet/ > > ifneq ($(CONFIG_VLAN_8021Q),) > > obj-y +=3D 8021q/ > > endif > > +obj-$(CONFIG_IP_QUIC) +=3D quic/ > > obj-$(CONFIG_IP_SCTP) +=3D sctp/ > > obj-$(CONFIG_RDS) +=3D rds/ > > obj-$(CONFIG_WIRELESS) +=3D wireless/ > > diff --git a/net/quic/Kconfig b/net/quic/Kconfig > > new file mode 100644 > > index 000000000000..1f10a452b3a1 > > --- /dev/null > > +++ b/net/quic/Kconfig > > @@ -0,0 +1,36 @@ > > +# SPDX-License-Identifier: GPL-2.0-or-later > > +# > > +# QUIC configuration > > +# > > + > > +menuconfig IP_QUIC > > + tristate "QUIC: A UDP-Based Multiplexed and Secure Transport (Exp= erimental)" > > + depends on INET > > + depends on IPV6 > > + select CRYPTO > > + select CRYPTO_HMAC > > + select CRYPTO_HKDF > > + select CRYPTO_AES > > + select CRYPTO_GCM > > + select CRYPTO_CCM > > + select CRYPTO_CHACHA20POLY1305 > > + select NET_UDP_TUNNEL > > + default n > > + help > > + QUIC: A UDP-Based Multiplexed and Secure Transport > > + > > + From rfc9000 . > > + > > + QUIC provides applications with flow-controlled streams for str= uctured > > + communication, low-latency connection establishment, and networ= k path > > + migration. QUIC includes security measures that ensure > > + confidentiality, integrity, and availability in a range of depl= oyment > > + circumstances. Accompanying documents describe the integration= of > > + TLS for key negotiation, loss detection, and an exemplary conge= stion > > + control algorithm. > > + > > + To compile this protocol support as a module, choose M here: th= e > > + module will be called quic. Debug messages are handled by the > > + kernel's dynamic debugging framework. > > + > > + If in doubt, say N. > > diff --git a/net/quic/Makefile b/net/quic/Makefile > > new file mode 100644 > > index 000000000000..020e4dd133d8 > > --- /dev/null > > +++ b/net/quic/Makefile > > @@ -0,0 +1,8 @@ > > +# SPDX-License-Identifier: GPL-2.0-or-later > > +# > > +# Makefile for QUIC support code. > > +# > > + > > +obj-$(CONFIG_IP_QUIC) +=3D quic.o > > + > > +quic-y :=3D protocol.o socket.o > > diff --git a/net/quic/protocol.c b/net/quic/protocol.c > > new file mode 100644 > > index 000000000000..f79f43f0c17f > > --- /dev/null > > +++ b/net/quic/protocol.c > > @@ -0,0 +1,379 @@ > > +// SPDX-License-Identifier: GPL-2.0-or-later > > +/* QUIC kernel implementation > > + * (C) Copyright Red Hat Corp. 2023 > > + * > > + * This file is part of the QUIC kernel implementation > > + * > > + * Initialization/cleanup for QUIC protocol support. > > + * > > + * Written or modified by: > > + * Xin Long > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include "socket.h" > > + > > +static unsigned int quic_net_id __read_mostly; > > + > > +struct percpu_counter quic_sockets_allocated; > > + > > +long sysctl_quic_mem[3]; > > +int sysctl_quic_rmem[3]; > > +int sysctl_quic_wmem[3]; > > +int sysctl_quic_alpn_demux; > > + > > +static int quic_inet_connect(struct socket *sock, struct sockaddr *add= r, int addr_len, int flags) > > +{ > > + struct sock *sk =3D sock->sk; > > + const struct proto *prot; > > + > > + if (addr_len < (int)sizeof(addr->sa_family)) > > + return -EINVAL; > > + > > + prot =3D READ_ONCE(sk->sk_prot); > > Is the above _ONCE() annotation for ADDRFORM's sake? If so it should not > be needed (only UDP and TCP sockets are affected). I will delete it. > > > diff --git a/net/quic/socket.h b/net/quic/socket.h > > new file mode 100644 > > index 000000000000..ded8eb2e6a9c > > --- /dev/null > > +++ b/net/quic/socket.h > > @@ -0,0 +1,79 @@ > > +/* SPDX-License-Identifier: GPL-2.0-or-later */ > > +/* QUIC kernel implementation > > + * (C) Copyright Red Hat Corp. 2023 > > + * > > + * This file is part of the QUIC kernel implementation > > + * > > + * Written or modified by: > > + * Xin Long > > + */ > > + > > +#include > > + > > +#include "protocol.h" > > + > > +extern struct proto quic_prot; > > +extern struct proto quicv6_prot; > > + > > +enum quic_state { > > + QUIC_SS_CLOSED =3D TCP_CLOSE, > > + QUIC_SS_LISTENING =3D TCP_LISTEN, > > + QUIC_SS_ESTABLISHING =3D TCP_SYN_RECV, > > + QUIC_SS_ESTABLISHED =3D TCP_ESTABLISHED, > > +}; > > Any special reason to define protocol-specific states? I guess you could > re-use the TCP ones, as other protocols already do. > I know TIPC and SCTP define the states like this: enum { TIPC_LISTEN =3D TCP_LISTEN, TIPC_ESTABLISHED =3D TCP_ESTABLISHED, TIPC_OPEN =3D TCP_CLOSE, TIPC_DISCONNECTING =3D TCP_CLOSE_WAIT, TIPC_CONNECTING =3D TCP_SYN_SENT, }; and enum sctp_sock_state { SCTP_SS_CLOSED =3D TCP_CLOSE, SCTP_SS_LISTENING =3D TCP_LISTEN, SCTP_SS_ESTABLISHING =3D TCP_SYN_SENT, SCTP_SS_ESTABLISHED =3D TCP_ESTABLISHED, SCTP_SS_CLOSING =3D TCP_CLOSE_WAIT, }; It should be fine to keep as is, or you have more and better examples from other protocols. Thanks.