Skip to content

Commit 9a7e881

Browse files
committed
Clean up clamp_mtu comments
1 parent ec05dd4 commit 9a7e881

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

talpid-core/src/tunnel/mod.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -196,26 +196,24 @@ impl TunnelMonitor {
196196
/// Calculates and appropriate tunnel MTU based on the given peer MTU minus header sizes
197197
#[cfg(any(target_os = "linux", target_os = "windows"))]
198198
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+
};
199202
// Some users experience fragmentation issues even when we take the interface MTU and
200203
// subtract the header sizes. This is likely due to some program that they use which does
201204
// not change the interface MTU but adds its own header onto the outgoing packets. For this
202205
// reason we subtract some extra bytes from our MTU in order to give other programs some
203206
// 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;
208208

209209
let total_header_size = WIREGUARD_HEADER_SIZE
210210
+ match params.connection.peer.endpoint.is_ipv6() {
211211
false => IPV4_HEADER_SIZE,
212212
true => IPV6_HEADER_SIZE,
213213
};
214214

215-
const MTU_SAFETY_MARGIN: u16 = 60;
216215
// The largest peer MTU that we allow
217216
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
219217

220218
let min_mtu = match params.generic_options.enable_ipv6 {
221219
false => MIN_IPV4_MTU,

0 commit comments

Comments
 (0)