From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f44.google.com (mail-dl1-f44.google.com [74.125.82.44]) (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 919B486334 for ; Thu, 15 Jan 2026 17:15:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768497361; cv=none; b=cY8x19NTra7asB+PjL/nFO1oI51D+ZGK//DurWKcCWA9eJHqgKezV0TKUZlIz75pumWWWttnyAvDwurGAr1cK+bahHZOVsKUfrp4pK9aIjHtYrpdJQQ7jo1KLP2NJAW3uR/vUtJW5N+zBRSA8FFG9WLfTLvmYv5Cfuj9648sqxE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768497361; c=relaxed/simple; bh=hdmty16Y3UPCJ85uyPbUwOr7VFEIdxCMDgYIwpvvJX0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F8RatXI5999TuPg54Fs+RvslAoDHwPVE2b8YNyt33XgjaD297f8oYYNIrqgs6mJUtWhyOD8etYVI+1esZmXG0p2Ybsnxud8T2uWzMj1fsWE0rOeg860MDb/WApW67P8UtbjRYOkBu8JXYD+FGlJtTn0hyQb9oVe7adJ1D4QH9q4= 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=XvpSxEZx; arc=none smtp.client-ip=74.125.82.44 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="XvpSxEZx" Received: by mail-dl1-f44.google.com with SMTP id a92af1059eb24-1232d9f25e9so2044668c88.0 for ; Thu, 15 Jan 2026 09:15:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768497359; x=1769102159; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yiYjAOIUiN8obs6nhzXenHSK+BjcngnjF6Yf7NvozL4=; b=XvpSxEZxYzi83+UVfcYcRFcx8PLB3aG/ugfmdfQa8K2nk3GD3OHK9QnMCR2bhw71Ny FuC+d0w5rTrTc/bFUEQl7stLr7qSq/vmHdSwSJCfSh+84Tlgsk7gZ8qogCpDG8Z8qgzm jqfsOO5FQ1EfypO7H+hK6dB6qg9rvsn//++amJnMKnSy1z6XhxW5caUl3ODLRwg0nuSh 0IxVSuVa17d/EMXYr9Q1sgcH5YSpdnwuk7dVNCDCwiWP79leYXy6Tp9v19a/tRbtMNxA j+7Cfnp8Fq5FLjHgkQHH2g74Fvw3qHJ3hHHiGyNISfgVln0WIs+u+4BgiLbnOYwpEQrZ xkMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768497359; x=1769102159; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=yiYjAOIUiN8obs6nhzXenHSK+BjcngnjF6Yf7NvozL4=; b=cqXL/FYZpT89DcLqHAwXGAvjd6Ztx4Zonh5/ECfBolKc2+2xGbp8UJRHUI6rh17vjr j9olH1/Tv8jKm/iT8BwYTWtu2DOIYqjxJHmiqkUymcnmHLj+P+RxjS8Cfk1+YdY735n7 lU5KF95YllOvaf+Ufw7MDcKEdvlqsONg7beSVSDdHO/kcxPCZYH7WakhV1PK7TYAB5ZM hGfFwh7l9uJJPmCEOuZGUmzinw2GnL9j0v/iOK7j/35dsiagDe115ufFosCDThyANcnv D9jvFCfjzIoJZue2qy0yht4cMtdXrkHIjx+32cTCqIgHERR06/rUBSBOtsFfeJeD/zrK E7ag== X-Forwarded-Encrypted: i=1; AJvYcCU9z8mehrYoZPfpyvSTLaCfPfV1NgNXnhXmWwMlaDMV/iuFUxmgcQCh5PTsgPX0RX7cOVpw@lists.linux.dev X-Gm-Message-State: AOJu0YwrQd9Xn5XYUeS+yww+aEj/n/oRMaemQgFcjvD0jYYxa6TOb+ew fI/a6oP62hL55e92aeKieLrLUVLOIa1pyHbEJhN1vlkvc1QeeKPuiGdep/2ASrtk X-Gm-Gg: AY/fxX7GTU0LpcWbcsUtbfe/K8t0rCyDdQf31Lh/HQ5ocUlgd3OhIyEBU0DOC04ExSD P7vnCDp3dereyIn+TRQ4EwyOq9YG8wOdym1v47D9+KyustEEOdTazRTfAj6JzOINCdK05PHL0W/ SOl/Mg1FWkiuy0fWT4gMwCyMUwB/RqzEzQOOuSOoXQpzUU4XKWcwmJAa2RdF45YDxzzF3rMNI69 5zSFf0bX9EhIaXPGQT+2mqJ1AVO+WGiJvX41o/pkaXxm03Aa6AK+Akmk0mSsufoT4/tqPuKJEtq zhUbg7CPJaLc3mnBYfKs2g1ITv3L9k2aI50L8J8kO8WjbgZf38tXToTLGwX+t8Gc71uKbbMDw+4 HQnrAIOHJffuXNv4Ya8QwYAiuQIJoYuyKblgbYZ4ZG3MI7YM4++Km8SlB6pwuF8V8RL5yFUGaIg JqOtm9Ecv1H/RPLwVBg1f9wnjP63SFZwSUEkBFM8sZIejtix03Vfg= X-Received: by 2002:a05:6214:1c8a:b0:87c:268d:bbda with SMTP id 6a1803df08f44-89275c6335dmr76896256d6.60.1768490130053; Thu, 15 Jan 2026 07:15:30 -0800 (PST) Received: from wsfd-netdev58.anl.eng.rdu2.dc.redhat.com ([66.187.232.140]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-890770cc6edsm201030056d6.4.2026.01.15.07.15.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Jan 2026 07:15:29 -0800 (PST) From: Xin Long To: network dev , quic@lists.linux.dev Cc: davem@davemloft.net, kuba@kernel.org, Eric Dumazet , Paolo Abeni , Simon Horman , Stefan Metzmacher , Moritz Buhl , Tyler Fanelli , Pengtao He , Thomas Dreibholz , linux-cifs@vger.kernel.org, Steve French , Namjae Jeon , Paulo Alcantara , Tom Talpey , kernel-tls-handshake@lists.linux.dev, Chuck Lever , Jeff Layton , 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 Subject: [PATCH net-next v7 05/16] quic: provide quic.h header files for kernel and userspace Date: Thu, 15 Jan 2026 10:11:05 -0500 Message-ID: <32a34bfa4fcd69de5c738db95dbd71ac8e361d24.1768489876.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: quic@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This commit adds quic.h to include/uapi/linux, providing the necessary definitions for the QUIC socket API. Exporting this header allows both user space applications and kernel subsystems to access QUIC-related control messages, socket options, and event/notification interfaces. Since kernel_get/setsockopt() is no longer available to kernel consumers, a corresponding internal header, include/linux/quic.h, is added. This exposes quic_do_get/setsockopt() to handle QUIC socket options directly for kernel subsystems. Detailed descriptions of these structures are available in [1], and will be also provided when adding corresponding socket interfaces in the later patches. [1] https://datatracker.ietf.org/doc/html/draft-lxin-quic-socket-apis Signed-off-by: Tyler Fanelli Signed-off-by: Stefan Metzmacher Signed-off-by: Thomas Dreibholz Signed-off-by: Xin Long --- v2: - Fix a kernel API description warning, found by Jakub. - Replace uintN_t with __uN, capitalize _UAPI_LINUX_QUIC_H, and assign explicit values for QUIC_TRANSPORT_ERROR_ enum in UAPI quic.h, suggested by David Howells. v4: - Use MSG_QUIC_ prefix for MSG_* flags to avoid conflicts with other protocols, such as MSG_NOTIFICATION in SCTP (reported by Thomas). - Remove QUIC_CONG_ALG_CUBIC; only NEW RENO congestion control is supported in this version. v5: - Add include/linux/quic.h and include/uapi/linux/quic.h to the QUIC PROTOCOL entry in MAINTAINERS. v6: - Fix the copy/pasted the uAPI path for SCTP to the QUIC entry (noted by Jakub). v7: - Expose quic_do_get/setsockopt() instead of quic_kernel_get/setsockopt() (suggested by Paolo). --- MAINTAINERS | 2 + include/linux/quic.h | 20 ++++ include/uapi/linux/quic.h | 235 ++++++++++++++++++++++++++++++++++++++ net/quic/socket.c | 32 +++++- net/quic/socket.h | 7 ++ 5 files changed, 294 insertions(+), 2 deletions(-) create mode 100644 include/linux/quic.h create mode 100644 include/uapi/linux/quic.h diff --git a/MAINTAINERS b/MAINTAINERS index e129a03590be..fd770b20ab03 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -21661,6 +21661,8 @@ M: Xin Long L: quic@lists.linux.dev S: Maintained W: https://github.com/lxin/quic +F: include/linux/quic.h +F: include/uapi/linux/quic.h F: net/quic/ RADEON and AMDGPU DRM DRIVERS diff --git a/include/linux/quic.h b/include/linux/quic.h new file mode 100644 index 000000000000..c246f6349f9c --- /dev/null +++ b/include/linux/quic.h @@ -0,0 +1,20 @@ +/* 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 + */ + +#ifndef _LINUX_QUIC_H +#define _LINUX_QUIC_H + +#include +#include + +int quic_do_setsockopt(struct sock *sk, int optname, sockptr_t optval, unsigned int optlen); +int quic_do_getsockopt(struct sock *sk, int optname, sockptr_t optval, sockptr_t optlen); + +#endif diff --git a/include/uapi/linux/quic.h b/include/uapi/linux/quic.h new file mode 100644 index 000000000000..990b70c3afb0 --- /dev/null +++ b/include/uapi/linux/quic.h @@ -0,0 +1,235 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* QUIC kernel implementation + * (C) Copyright Red Hat Corp. 2023 + * + * This file is part of the QUIC kernel implementation + * + * Written or modified by: + * Xin Long + */ + +#ifndef _UAPI_LINUX_QUIC_H +#define _UAPI_LINUX_QUIC_H + +#include +#ifdef __KERNEL__ +#include +#else +#include +#endif + +/* NOTE: Structure descriptions are specified in: + * https://datatracker.ietf.org/doc/html/draft-lxin-quic-socket-apis + */ + +/* Send or Receive Options APIs */ +enum quic_cmsg_type { + QUIC_STREAM_INFO, + QUIC_HANDSHAKE_INFO, +}; + +#define QUIC_STREAM_TYPE_SERVER_MASK 0x01 +#define QUIC_STREAM_TYPE_UNI_MASK 0x02 +#define QUIC_STREAM_TYPE_MASK 0x03 + +enum quic_msg_flags { + /* flags for stream_flags */ + MSG_QUIC_STREAM_NEW = MSG_SYN, + MSG_QUIC_STREAM_FIN = MSG_FIN, + MSG_QUIC_STREAM_UNI = MSG_CONFIRM, + MSG_QUIC_STREAM_DONTWAIT = MSG_WAITFORONE, + MSG_QUIC_STREAM_SNDBLOCK = MSG_ERRQUEUE, + + /* extented flags for msg_flags */ + MSG_QUIC_DATAGRAM = MSG_RST, + MSG_QUIC_NOTIFICATION = MSG_MORE, +}; + +enum quic_crypto_level { + QUIC_CRYPTO_APP, + QUIC_CRYPTO_INITIAL, + QUIC_CRYPTO_HANDSHAKE, + QUIC_CRYPTO_EARLY, + QUIC_CRYPTO_MAX, +}; + +struct quic_handshake_info { + __u8 crypto_level; +}; + +struct quic_stream_info { + __s64 stream_id; + __u32 stream_flags; +}; + +/* Socket Options APIs */ +#define QUIC_SOCKOPT_EVENT 0 +#define QUIC_SOCKOPT_STREAM_OPEN 1 +#define QUIC_SOCKOPT_STREAM_RESET 2 +#define QUIC_SOCKOPT_STREAM_STOP_SENDING 3 +#define QUIC_SOCKOPT_CONNECTION_ID 4 +#define QUIC_SOCKOPT_CONNECTION_CLOSE 5 +#define QUIC_SOCKOPT_CONNECTION_MIGRATION 6 +#define QUIC_SOCKOPT_KEY_UPDATE 7 +#define QUIC_SOCKOPT_TRANSPORT_PARAM 8 +#define QUIC_SOCKOPT_CONFIG 9 +#define QUIC_SOCKOPT_TOKEN 10 +#define QUIC_SOCKOPT_ALPN 11 +#define QUIC_SOCKOPT_SESSION_TICKET 12 +#define QUIC_SOCKOPT_CRYPTO_SECRET 13 +#define QUIC_SOCKOPT_TRANSPORT_PARAM_EXT 14 + +#define QUIC_VERSION_V1 0x1 +#define QUIC_VERSION_V2 0x6b3343cf + +struct quic_transport_param { + __u8 remote; + __u8 disable_active_migration; + __u8 grease_quic_bit; + __u8 stateless_reset; + __u8 disable_1rtt_encryption; + __u8 disable_compatible_version; + __u8 active_connection_id_limit; + __u8 ack_delay_exponent; + __u16 max_datagram_frame_size; + __u16 max_udp_payload_size; + __u32 max_idle_timeout; + __u32 max_ack_delay; + __u16 max_streams_bidi; + __u16 max_streams_uni; + __u64 max_data; + __u64 max_stream_data_bidi_local; + __u64 max_stream_data_bidi_remote; + __u64 max_stream_data_uni; + __u64 reserved; +}; + +struct quic_config { + __u32 version; + __u32 plpmtud_probe_interval; + __u32 initial_smoothed_rtt; + __u32 payload_cipher_type; + __u8 congestion_control_algo; + __u8 validate_peer_address; + __u8 stream_data_nodelay; + __u8 receive_session_ticket; + __u8 certificate_request; + __u8 reserved[3]; +}; + +struct quic_crypto_secret { + __u8 send; /* send or recv */ + __u8 level; /* crypto level */ + __u32 type; /* TLS_CIPHER_* */ +#define QUIC_CRYPTO_SECRET_BUFFER_SIZE 48 + __u8 secret[QUIC_CRYPTO_SECRET_BUFFER_SIZE]; +}; + +enum quic_cong_algo { + QUIC_CONG_ALG_RENO, + QUIC_CONG_ALG_MAX, +}; + +struct quic_errinfo { + __s64 stream_id; + __u32 errcode; +}; + +struct quic_connection_id_info { + __u8 dest; + __u32 active; + __u32 prior_to; +}; + +struct quic_event_option { + __u8 type; + __u8 on; +}; + +/* Event APIs */ +enum quic_event_type { + QUIC_EVENT_NONE, + QUIC_EVENT_STREAM_UPDATE, + QUIC_EVENT_STREAM_MAX_DATA, + QUIC_EVENT_STREAM_MAX_STREAM, + QUIC_EVENT_CONNECTION_ID, + QUIC_EVENT_CONNECTION_CLOSE, + QUIC_EVENT_CONNECTION_MIGRATION, + QUIC_EVENT_KEY_UPDATE, + QUIC_EVENT_NEW_TOKEN, + QUIC_EVENT_NEW_SESSION_TICKET, + QUIC_EVENT_MAX, +}; + +enum { + QUIC_STREAM_SEND_STATE_READY, + QUIC_STREAM_SEND_STATE_SEND, + QUIC_STREAM_SEND_STATE_SENT, + QUIC_STREAM_SEND_STATE_RECVD, + QUIC_STREAM_SEND_STATE_RESET_SENT, + QUIC_STREAM_SEND_STATE_RESET_RECVD, + + QUIC_STREAM_RECV_STATE_RECV, + QUIC_STREAM_RECV_STATE_SIZE_KNOWN, + QUIC_STREAM_RECV_STATE_RECVD, + QUIC_STREAM_RECV_STATE_READ, + QUIC_STREAM_RECV_STATE_RESET_RECVD, + QUIC_STREAM_RECV_STATE_RESET_READ, +}; + +struct quic_stream_update { + __s64 id; + __u8 state; + __u32 errcode; + __u64 finalsz; +}; + +struct quic_stream_max_data { + __s64 id; + __u64 max_data; +}; + +struct quic_connection_close { + __u32 errcode; + __u8 frame; + __u8 phrase[]; +}; + +union quic_event { + struct quic_stream_update update; + struct quic_stream_max_data max_data; + struct quic_connection_close close; + struct quic_connection_id_info info; + __u64 max_stream; + __u8 local_migration; + __u8 key_update_phase; +}; + +enum { + QUIC_TRANSPORT_ERROR_NONE = 0x00, + QUIC_TRANSPORT_ERROR_INTERNAL = 0x01, + QUIC_TRANSPORT_ERROR_CONNECTION_REFUSED = 0x02, + QUIC_TRANSPORT_ERROR_FLOW_CONTROL = 0x03, + QUIC_TRANSPORT_ERROR_STREAM_LIMIT = 0x04, + QUIC_TRANSPORT_ERROR_STREAM_STATE = 0x05, + QUIC_TRANSPORT_ERROR_FINAL_SIZE = 0x06, + QUIC_TRANSPORT_ERROR_FRAME_ENCODING = 0x07, + QUIC_TRANSPORT_ERROR_TRANSPORT_PARAM = 0x08, + QUIC_TRANSPORT_ERROR_CONNECTION_ID_LIMIT = 0x09, + QUIC_TRANSPORT_ERROR_PROTOCOL_VIOLATION = 0x0a, + QUIC_TRANSPORT_ERROR_INVALID_TOKEN = 0x0b, + QUIC_TRANSPORT_ERROR_APPLICATION = 0x0c, + QUIC_TRANSPORT_ERROR_CRYPTO_BUF_EXCEEDED = 0x0d, + QUIC_TRANSPORT_ERROR_KEY_UPDATE = 0x0e, + QUIC_TRANSPORT_ERROR_AEAD_LIMIT_REACHED = 0x0f, + QUIC_TRANSPORT_ERROR_NO_VIABLE_PATH = 0x10, + + /* The cryptographic handshake failed. A range of 256 values is reserved + * for carrying error codes specific to the cryptographic handshake that + * is used. Codes for errors occurring when TLS is used for the + * cryptographic handshake are described in Section 4.8 of [QUIC-TLS]. + */ + QUIC_TRANSPORT_ERROR_CRYPTO = 0x0100, +}; + +#endif /* _UAPI_LINUX_QUIC_H */ diff --git a/net/quic/socket.c b/net/quic/socket.c index a0eedf59545a..b86989080184 100644 --- a/net/quic/socket.c +++ b/net/quic/socket.c @@ -107,10 +107,24 @@ static void quic_close(struct sock *sk, long timeout) sk_common_release(sk); } -static int quic_do_setsockopt(struct sock *sk, int optname, sockptr_t optval, unsigned int optlen) +/** + * quic_do_setsockopt - set a QUIC socket option + * @sk: socket to configure + * @optname: option name (QUIC-level) + * @optval: user buffer containing the option value + * @optlen: size of the option value + * + * Sets a QUIC socket option on a given socket. + * + * Return: + * - On success, 0 is returned. + * - On error, a negative error value is returned. + */ +int quic_do_setsockopt(struct sock *sk, int optname, sockptr_t optval, unsigned int optlen) { return -EOPNOTSUPP; } +EXPORT_SYMBOL_GPL(quic_do_setsockopt); static int quic_setsockopt(struct sock *sk, int level, int optname, sockptr_t optval, unsigned int optlen) @@ -121,10 +135,24 @@ static int quic_setsockopt(struct sock *sk, int level, int optname, return quic_do_setsockopt(sk, optname, optval, optlen); } -static int quic_do_getsockopt(struct sock *sk, int optname, sockptr_t optval, sockptr_t optlen) +/** + * quic_do_getsockopt - get a QUIC socket option + * @sk: socket to query + * @optname: option name (QUIC-level) + * @optval: user buffer to receive the option value + * @optlen: in/out parameter for buffer size; updated with actual length on return + * + * Gets a QUIC socket option from a given socket. + * + * Return: + * - On success, 0 is returned. + * - On error, a negative error value is returned. + */ +int quic_do_getsockopt(struct sock *sk, int optname, sockptr_t optval, sockptr_t optlen) { return -EOPNOTSUPP; } +EXPORT_SYMBOL_GPL(quic_do_getsockopt); static int quic_getsockopt(struct sock *sk, int level, int optname, char __user *optval, int __user *optlen) diff --git a/net/quic/socket.h b/net/quic/socket.h index 0aa642e3b0ae..7ee190af4454 100644 --- a/net/quic/socket.h +++ b/net/quic/socket.h @@ -9,6 +9,7 @@ */ #include +#include #include "common.h" #include "family.h" @@ -29,6 +30,7 @@ struct quic_sock { struct inet_sock inet; struct list_head reqs; + struct quic_config config; struct quic_data ticket; struct quic_data token; struct quic_data alpn; @@ -49,6 +51,11 @@ static inline struct list_head *quic_reqs(const struct sock *sk) return &quic_sk(sk)->reqs; } +static inline struct quic_config *quic_config(const struct sock *sk) +{ + return &quic_sk(sk)->config; +} + static inline struct quic_data *quic_token(const struct sock *sk) { return &quic_sk(sk)->token; -- 2.47.1