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 ) ;
2121static unsigned long quic_memory_pressure ;
2222static 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 )
293292static 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 )
11001098static 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 )
14231414static 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};
0 commit comments