Re: [PATCH net-next v3 02/15] net: build socket infrastructure for QUIC protocol
Paolo Abeni <[email protected]> Tue, 23 Sep 2025 13:07:29 +0200
| Newsgroups | dev.linux.lists.quic,dev.linux.lists.kernel-tls-handshake,org.kernel.vger.linux-cifs,org.kernel.vger.netdev |
|---|---|
| Message-ID | <[email protected]> |
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=m. > > This provides the scaffolding necessary for adding actual QUIC socket > behavior in follow-up patches. > > Signed-off-by: Pengtao He <[email protected]> > Signed-off-by: Xin Long <[email protected]> > --- > 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 (noted > 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 changes. > --- > 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) += phonet/ > ifneq ($(CONFIG_VLAN_8021Q),) > obj-y += 8021q/ > endif > +obj-$(CONFIG_IP_QUIC) += quic/ > obj-$(CONFIG_IP_SCTP) += sctp/ > obj-$(CONFIG_RDS) += rds/ > obj-$(CONFIG_WIRELESS) += 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 (Experimental)" > + 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 <https://www.rfc-editor.org/rfc/rfc9000.html>. > + > + QUIC provides applications with flow-controlled streams for structured > + communication, low-latency connection establishment, and network path > + migration. QUIC includes security measures that ensure > + confidentiality, integrity, and availability in a range of deployment > + circumstances. Accompanying documents describe the integration of > + TLS for key negotiation, loss detection, and an exemplary congestion > + control algorithm. > + > + To compile this protocol support as a module, choose M here: the > + 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) += quic.o > + > +quic-y := 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 <[email protected]> > + */ > + > +#include <net/inet_common.h> > +#include <linux/proc_fs.h> > +#include <net/protocol.h> > +#include <net/rps.h> > +#include <net/tls.h> > + > +#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 *addr, int addr_len, int flags) > +{ > + struct sock *sk = sock->sk; > + const struct proto *prot; > + > + if (addr_len < (int)sizeof(addr->sa_family)) > + return -EINVAL; > + > + prot = 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). > 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 <[email protected]> > + */ > + > +#include <net/udp_tunnel.h> > + > +#include "protocol.h" > + > +extern struct proto quic_prot; > +extern struct proto quicv6_prot; > + > +enum quic_state { > + QUIC_SS_CLOSED = TCP_CLOSE, > + QUIC_SS_LISTENING = TCP_LISTEN, > + QUIC_SS_ESTABLISHING = TCP_SYN_RECV, > + QUIC_SS_ESTABLISHED = TCP_ESTABLISHED, > +}; Any special reason to define protocol-specific states? I guess you could re-use the TCP ones, as other protocols already do. /P