File tree Expand file tree Collapse file tree 3 files changed +25
-6
lines changed Expand file tree Collapse file tree 3 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,10 @@ use crate::{
18
18
ip:: IpProtocol ,
19
19
ipv4:: Ipv4Header ,
20
20
tcp:: {
21
- constants:: FALLBACK_MSS ,
21
+ constants:: {
22
+ FALLBACK_MSS ,
23
+ MAX_WINDOW_SCALE ,
24
+ } ,
22
25
established:: {
23
26
congestion_control:: {
24
27
self ,
@@ -180,14 +183,25 @@ impl<N: NetworkRuntime> SharedActiveOpenSocket<N> {
180
183
}
181
184
}
182
185
183
- let ( local_window_scale, remote_window_scale) = match remote_window_scale {
184
- Some ( w) => ( self . tcp_config . get_window_scale ( ) as u32 , w) ,
186
+ let ( local_window_scale, remote_window_scale) : ( u32 , u8 ) = match remote_window_scale {
187
+ Some ( remote_window_scale) => {
188
+ let local: u32 = if self . tcp_config . get_window_scale ( ) > 14 {
189
+ warn ! ( "local windows scale larger than 14 is incorrect, so setting to 14. See RFC 1323." ) ;
190
+ MAX_WINDOW_SCALE as u32
191
+ } else {
192
+ self . tcp_config . get_window_scale ( ) as u32
193
+ } ;
194
+ let remote: u8 = if remote_window_scale > 14 {
195
+ warn ! ( "remote windows scale larger than 14 is incorrect, so setting to 14. See RFC 1323." ) ;
196
+ MAX_WINDOW_SCALE as u8
197
+ } else {
198
+ remote_window_scale
199
+ } ;
200
+ ( local, remote)
201
+ } ,
185
202
None => ( 0 , 0 ) ,
186
203
} ;
187
204
188
- // TODO(RFC1323): Clamp the scale to 14 instead of panicking.
189
- assert ! ( local_window_scale <= 14 && remote_window_scale <= 14 ) ;
190
-
191
205
let rx_window_size: u32 = expect_ok ! (
192
206
expect_some!(
193
207
( self . tcp_config. get_receive_window_size( ) as u32 ) . checked_shl( local_window_scale as u32 ) ,
Original file line number Diff line number Diff line change @@ -5,5 +5,6 @@ pub use crate::runtime::network::consts::{
5
5
DEFAULT_MSS ,
6
6
FALLBACK_MSS ,
7
7
MAX_MSS ,
8
+ MAX_WINDOW_SCALE ,
8
9
MIN_MSS ,
9
10
} ;
Original file line number Diff line number Diff line change @@ -36,3 +36,7 @@ pub const DEFAULT_MSS: usize = 1450;
36
36
///
37
37
/// TODO: This Should be Generic
38
38
pub const RECEIVE_BATCH_SIZE : usize = 4 ;
39
+
40
+ /// Maximum local and remote window scaling factor.
41
+ /// See: RFC 1323, Section 2.3.
42
+ pub const MAX_WINDOW_SCALE : usize = 14 ;
You can’t perform that action at this time.
0 commit comments