@@ -196,26 +196,24 @@ impl TunnelMonitor {
196
196
/// Calculates and appropriate tunnel MTU based on the given peer MTU minus header sizes
197
197
#[ cfg( any( target_os = "linux" , target_os = "windows" ) ) ]
198
198
fn clamp_mtu ( params : & wireguard_types:: TunnelParameters , peer_mtu : u16 ) -> u16 {
199
+ use talpid_tunnel:: {
200
+ IPV4_HEADER_SIZE , IPV6_HEADER_SIZE , MIN_IPV4_MTU , MIN_IPV6_MTU , WIREGUARD_HEADER_SIZE ,
201
+ } ;
199
202
// Some users experience fragmentation issues even when we take the interface MTU and
200
203
// subtract the header sizes. This is likely due to some program that they use which does
201
204
// not change the interface MTU but adds its own header onto the outgoing packets. For this
202
205
// reason we subtract some extra bytes from our MTU in order to give other programs some
203
206
// safety margin.
204
-
205
- use talpid_tunnel:: {
206
- IPV4_HEADER_SIZE , IPV6_HEADER_SIZE , MIN_IPV4_MTU , MIN_IPV6_MTU , WIREGUARD_HEADER_SIZE ,
207
- } ;
207
+ const MTU_SAFETY_MARGIN : u16 = 60 ;
208
208
209
209
let total_header_size = WIREGUARD_HEADER_SIZE
210
210
+ match params. connection . peer . endpoint . is_ipv6 ( ) {
211
211
false => IPV4_HEADER_SIZE ,
212
212
true => IPV6_HEADER_SIZE ,
213
213
} ;
214
214
215
- const MTU_SAFETY_MARGIN : u16 = 60 ;
216
215
// The largest peer MTU that we allow
217
216
let max_peer_mtu: u16 = 1500 - MTU_SAFETY_MARGIN - total_header_size;
218
- // The minimum allowed MTU size for our tunnel in IPv6 is 1280 and 576 for IPv4
219
217
220
218
let min_mtu = match params. generic_options . enable_ipv6 {
221
219
false => MIN_IPV4_MTU ,
0 commit comments