@@ -12,7 +12,7 @@ use std::time::Duration;
1212use anyhow:: anyhow;
1313use async_trait:: async_trait;
1414use log:: { info, warn} ;
15- use quinn:: { Connection , Endpoint , Incoming } ;
15+ use quinn:: { Connection , Endpoint , EndpointConfig , Incoming , ServerConfig } ;
1616use tokio:: runtime:: Handle ;
1717use tokio:: sync:: broadcast;
1818
@@ -43,6 +43,7 @@ pub struct ListenQuicRuntime<S> {
4343 server : S ,
4444 listen_config : UdpListenConfig ,
4545 listen_stats : Arc < ListenStats > ,
46+ payload_max_size : Option < u16 > ,
4647 #[ cfg( feature = "ebpf" ) ]
4748 socket_selector : Option < QuicSocketSelector > ,
4849}
@@ -51,11 +52,17 @@ impl<S> ListenQuicRuntime<S>
5152where
5253 S : AcceptQuicServer + ReloadServer + Clone + Send + Sync + ' static ,
5354{
54- pub fn new ( server : S , listen_stats : Arc < ListenStats > , listen_config : UdpListenConfig ) -> Self {
55+ pub fn new (
56+ server : S ,
57+ listen_stats : Arc < ListenStats > ,
58+ listen_config : UdpListenConfig ,
59+ payload_max_size : Option < u16 > ,
60+ ) -> Self {
5561 ListenQuicRuntime {
5662 server,
5763 listen_config,
5864 listen_stats,
65+ payload_max_size,
5966 #[ cfg( feature = "ebpf" ) ]
6067 socket_selector : None ,
6168 }
6471 pub fn run_all_instances (
6572 & mut self ,
6673 listen_in_worker : bool ,
67- quic_config : & quinn :: ServerConfig ,
74+ quic_config : & ServerConfig ,
6875 ingress_net_filter : Option < & Arc < AclNetworkRule > > ,
6976 accept_timeout : Duration ,
7077 server_reload_sender : & broadcast:: Sender < ServerReloadCommand < ListenQuicInPlaceConfig > > ,
@@ -116,6 +123,13 @@ where
116123 } ;
117124 let listen_addr = socket. local_addr ( ) ?;
118125
126+ let mut endpoint_config = EndpointConfig :: default ( ) ;
127+ if let Some ( payload_max_size) = self . payload_max_size
128+ && let Err ( e) = endpoint_config. max_udp_payload_size ( payload_max_size)
129+ {
130+ warn ! ( "ignored UDP payload size {payload_max_size}: {e}" ) ;
131+ }
132+
119133 let runtime = ListenQuicRuntimeInstance {
120134 server : self . server . clone ( ) ,
121135 server_type : self . server . r#type ( ) ,
@@ -134,6 +148,7 @@ where
134148 } ;
135149 runtime. into_running (
136150 socket,
151+ endpoint_config,
137152 quic_config. clone ( ) ,
138153 server_reload_sender. subscribe ( ) ,
139154 ) ;
@@ -460,16 +475,17 @@ where
460475 fn into_running (
461476 mut self ,
462477 socket : UdpSocket ,
463- config : quinn:: ServerConfig ,
478+ endpoint_config : EndpointConfig ,
479+ server_config : ServerConfig ,
464480 server_reload_channel : broadcast:: Receiver < ServerReloadCommand < ListenQuicInPlaceConfig > > ,
465481 ) {
466482 let handle = self . get_rt_handle ( ) ;
467483 handle. spawn ( async move {
468484 let raw_socket = RawSocket :: from ( & socket) ;
469485 // make sure the listen socket associated with the correct reactor
470486 match Endpoint :: new (
471- Default :: default ( ) ,
472- Some ( config ) ,
487+ endpoint_config ,
488+ Some ( server_config ) ,
473489 socket,
474490 Arc :: new ( quinn:: TokioRuntime ) ,
475491 ) {
0 commit comments