Skip to content

Commit bf096c7

Browse files
committed
protocol: drop support for kernels older than 6.1
Upstream is now at 6.16, and maintaining compatibility with older kernels adds unnecessary complexity. Remove support for < 6.1 to simplify the codebase. Meanwhile, add some missing LINUX_VERSION_CODE checks. Signed-off-by: Xin Long <lucien.xin@gmail.com>
1 parent ba9e142 commit bf096c7

File tree

8 files changed

+31
-48
lines changed

8 files changed

+31
-48
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ in [ktls-utils](https://github.com/oracle/ktls-utils) will handle the handshake
110110

111111
Both QUIC Kernel Module and Libquic will be built and installed simply by the commands below:
112112

113-
Packages Required: (kernel_version >= 5.14)
113+
Packages Required: (kernel_version >= 6.1)
114114
- make autoconf automake libtool pkg-config
115115
- gnutls-devel kernel-devel (yum)
116116
gnutls-dev linux-headers-$(uname -r) (apt-get)

modules/net/quic/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ menuconfig IP_QUIC
1515
select CRYPTO_CCM
1616
select CRYPTO_CHACHA20POLY1305
1717
select NET_UDP_TUNNEL
18+
default n
1819
help
1920
QUIC: A UDP-Based Multiplexed and Secure Transport
2021

modules/net/quic/family.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
* Xin Long <lucien.xin@gmail.com>
1111
*/
1212

13-
#include <net/sock.h>
1413
#include <net/inet_common.h>
1514
#include <net/udp_tunnel.h>
16-
#include <linux/version.h>
1715
#include <linux/icmp.h>
1816

1917
#include "common.h"
@@ -125,12 +123,8 @@ static int quic_v4_flow_route(struct sock *sk, union quic_addr *da, union quic_a
125123
fl4->flowi4_proto = IPPROTO_UDP;
126124
fl4->flowi4_oif = sk->sk_bound_dev_if;
127125

128-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
129126
fl4->flowi4_scope = ip_sock_rt_scope(sk);
130127
fl4->flowi4_tos = ip_sock_rt_tos(sk);
131-
#else
132-
fl4->flowi4_tos = RT_CONN_FLAGS_TOS(sk, READ_ONCE(inet_sk(sk)->tos));
133-
#endif
134128

135129
rt = ip_route_output_key(sock_net(sk), fl4);
136130
if (IS_ERR(rt))
@@ -166,7 +160,7 @@ static int quic_v6_flow_route(struct sock *sk, union quic_addr *da, union quic_a
166160
fl6->flowi6_proto = IPPROTO_UDP;
167161
fl6->flowi6_oif = sk->sk_bound_dev_if;
168162

169-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 7, 0)
163+
#ifdef inet6_test_bit
170164
if (inet6_test_bit(SNDFLOW, sk)) {
171165
#else
172166
if (np->sndflow) {

modules/net/quic/path.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212

1313
#include <net/udp_tunnel.h>
14+
#include <linux/version.h>
1415
#include <linux/quic.h>
1516

1617
#include "common.h"
@@ -161,7 +162,11 @@ int quic_path_bind(struct sock *sk, struct quic_path_group *paths, u8 path)
161162
return 0;
162163
}
163164

165+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
166+
inet_sk_get_local_port_range(sk, &low, &high);
167+
#else
164168
inet_get_local_port_range(net, &low, &high);
169+
#endif
165170
remaining = (high - low) + 1;
166171
rover = (int)(((u64)get_random_u32() * remaining) >> 32) + low;
167172
do {

modules/net/quic/protocol.c

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@
1010
* Xin Long <lucien.xin@gmail.com>
1111
*/
1212

13-
#include <net/sock.h>
1413
#include <net/inet_common.h>
1514
#include <linux/version.h>
1615
#include <linux/proc_fs.h>
1716
#include <net/protocol.h>
1817
#include <net/tls.h>
1918

19+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 9, 0)
20+
#include <net/rps.h>
21+
#endif
22+
2023
#include "socket.h"
2124

22-
static DEFINE_PER_CPU(int, quic_memory_per_cpu_fw_alloc);
2325
static unsigned int quic_net_id __read_mostly;
2426

2527
struct quic_transport_param quic_default_param __read_mostly;
@@ -131,8 +133,7 @@ static __poll_t quic_inet_poll(struct file *file, struct socket *sock, poll_tabl
131133

132134
poll_wait(file, sk_sleep(sk), wait);
133135

134-
/* Comment it out for compiling on the old kernel version for now. */
135-
/* sock_rps_record_flow(sk); */
136+
sock_rps_record_flow(sk); /* Record the flow's CPU association for RFS. */
136137

137138
/* A listening socket becomes readable when the accept queue is not empty. */
138139
if (quic_is_listen(sk))
@@ -201,8 +202,7 @@ static struct ctl_table quic_table[] = {
201202
.extra1 = SYSCTL_ZERO,
202203
.extra2 = SYSCTL_ONE,
203204
},
204-
205-
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 10, 0)
205+
#ifndef register_sysctl
206206
{ /* sentinel */ }
207207
#endif
208208
};
@@ -433,29 +433,13 @@ static struct inet_protosw quicv6_dgram_protosw = {
433433

434434
static int quic_protosw_init(void)
435435
{
436-
struct proto *proto;
437-
void *offset;
438436
int err;
439437

440-
proto = &quic_prot;
441-
offset = (void *)(&proto->memory_allocated) + sizeof(proto->memory_allocated);
442-
if (offset != (void *)&proto->sockets_allocated) /* per_cpu_fw_alloc */
443-
*(int __percpu **)offset = &quic_memory_per_cpu_fw_alloc;
444-
445-
err = proto_register(proto, 1);
438+
err = proto_register(&quic_prot, 1);
446439
if (err)
447440
return err;
448441

449-
proto = &quicv6_prot;
450-
offset = (void *)(&proto->memory_allocated) + sizeof(proto->memory_allocated);
451-
if (offset != (void *)&proto->sockets_allocated) /* per_cpu_fw_alloc */
452-
*(int __percpu **)offset = &quic_memory_per_cpu_fw_alloc;
453-
454-
offset = (void *)(&proto->obj_size) + sizeof(proto->obj_size);
455-
if (offset != &proto->slab_flags) /* ipv6_pinfo_offset */
456-
*(unsigned int *)offset = offsetof(struct quic6_sock, inet6);
457-
458-
err = proto_register(proto, 1);
442+
err = proto_register(&quicv6_prot, 1);
459443
if (err) {
460444
proto_unregister(&quic_prot);
461445
return err;

modules/net/quic/socket.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
* Xin Long <lucien.xin@gmail.com>
1111
*/
1212

13-
#include <net/sock.h>
1413
#include <net/inet_common.h>
1514
#include <linux/version.h>
1615
#include <asm/ioctls.h>
1716
#include <net/tls.h>
1817

1918
#include "socket.h"
2019

20+
static DEFINE_PER_CPU(int, quic_memory_per_cpu_fw_alloc);
2121
static unsigned long quic_memory_pressure;
2222
static atomic_long_t quic_memory_allocated;
2323

@@ -288,8 +288,7 @@ static void quic_sock_fetch_transport_param(struct sock *sk, struct quic_transpo
288288
quic_stream_get_param(quic_streams(sk), p, quic_is_serv(sk));
289289
}
290290

291-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0) || \
292-
(defined(RHEL_RELEASE_CODE) && RHEL_RELEASE_CODE >= 2308) /* RHEL-9.4 */
291+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 5, 0)
293292
static int quic_ioctl(struct sock *sk, int cmd, int *karg)
294293
{
295294
int err = 0;
@@ -1058,10 +1057,10 @@ static int quic_sendmsg(struct sock *sk, struct msghdr *msg, size_t msg_len)
10581057
}
10591058

10601059
/* Wait for an incoming QUIC packet. */
1061-
static int quic_wait_for_packet(struct sock *sk, int nonblock)
1060+
static int quic_wait_for_packet(struct sock *sk, u32 flags)
10621061
{
1062+
long timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
10631063
struct list_head *head = &quic_inq(sk)->recv_list;
1064-
long timeo = sock_rcvtimeo(sk, nonblock);
10651064
DEFINE_WAIT(wait);
10661065
int err = 0;
10671066

@@ -1096,16 +1095,9 @@ static int quic_wait_for_packet(struct sock *sk, int nonblock)
10961095
return err;
10971096
}
10981097

1099-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 19, 0)
11001098
static int quic_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int flags,
11011099
int *addr_len)
11021100
{
1103-
int nonblock = flags & MSG_DONTWAIT;
1104-
#else
1105-
static int quic_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int nonblock,
1106-
int flags, int *addr_len)
1107-
{
1108-
#endif
11091101
u32 copy, copied = 0, freed = 0, bytes = 0;
11101102
struct quic_handshake_info hinfo = {};
11111103
struct quic_stream_info sinfo = {};
@@ -1116,7 +1108,7 @@ static int quic_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, int non
11161108

11171109
lock_sock(sk);
11181110

1119-
err = quic_wait_for_packet(sk, nonblock);
1111+
err = quic_wait_for_packet(sk, flags);
11201112
if (err)
11211113
goto out;
11221114

@@ -1418,8 +1410,7 @@ static int quic_accept_sock_setup(struct sock *sk, struct quic_request_sock *req
14181410
return err;
14191411
}
14201412

1421-
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 10, 0) || \
1422-
(defined(RHEL_RELEASE_CODE) && RHEL_RELEASE_CODE >= 2310) /* RHEL-9.6 */
1413+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 10, 0)
14231414
static struct sock *quic_accept(struct sock *sk, struct proto_accept_arg *arg)
14241415
{
14251416
int flags = arg->flags, *errp = &arg->err;
@@ -2547,6 +2538,7 @@ struct proto quic_prot = {
25472538
.memory_pressure = &quic_memory_pressure,
25482539
.enter_memory_pressure = quic_enter_memory_pressure,
25492540
.memory_allocated = &quic_memory_allocated,
2541+
.per_cpu_fw_alloc = &quic_memory_per_cpu_fw_alloc,
25502542
.sockets_allocated = &quic_sockets_allocated,
25512543
};
25522544

@@ -2572,11 +2564,15 @@ struct proto quicv6_prot = {
25722564
.release_cb = quic_release_cb,
25732565
.no_autobind = true,
25742566
.obj_size = sizeof(struct quic6_sock),
2567+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
2568+
.ipv6_pinfo_offset = offsetof(struct quic6_sock, inet6),
2569+
#endif
25752570
.sysctl_mem = sysctl_quic_mem,
25762571
.sysctl_rmem = sysctl_quic_rmem,
25772572
.sysctl_wmem = sysctl_quic_wmem,
25782573
.memory_pressure = &quic_memory_pressure,
25792574
.enter_memory_pressure = quic_enter_memory_pressure,
25802575
.memory_allocated = &quic_memory_allocated,
2576+
.per_cpu_fw_alloc = &quic_memory_per_cpu_fw_alloc,
25812577
.sockets_allocated = &quic_sockets_allocated,
25822578
};

modules/net/quic/test/unit_test.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
* Xin Long <lucien.xin@gmail.com>
1111
*/
1212

13-
#include <linux/version.h>
1413
#include <linux/skbuff.h>
1514
#include <linux/delay.h>
1615
#include <linux/quic.h>

modules/net/quic/timer.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,11 @@ void quic_timer_stop(struct sock *sk, u8 type)
234234
sock_put(sk);
235235
return;
236236
}
237+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 2, 0)
237238
if (timer_delete(quic_timer(sk, type)))
239+
#else
240+
if (del_timer(quic_timer(sk, type)))
241+
#endif
238242
sock_put(sk);
239243
}
240244

0 commit comments

Comments
 (0)