Skip to content

Commit

Permalink
Tweak maximum MTU for paths using IPv4-mapped IPv6 addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
iyangsj committed May 30, 2024
1 parent 2d26bff commit 64ee2d4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/connection/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use std::cmp;
use std::collections::BTreeMap;
use std::collections::VecDeque;
use std::net::IpAddr;
use std::net::SocketAddr;
use std::time;
use std::time::Duration;
Expand Down Expand Up @@ -119,7 +120,7 @@ impl Path {
let dplpmtud = Dplpmtud::new(
conf.enable_dplpmtud,
conf.max_datagram_size,
remote_addr.is_ipv6(),
Self::is_ipv6(&remote_addr),
);

Self {
Expand Down Expand Up @@ -326,6 +327,17 @@ impl Path {
pub fn state(&self) -> PathState {
self.state
}

/// Return true if the given address is a pure IPv6 adress, rather than an
/// IPv4-mapped IPv6 address.
fn is_ipv6(addr: &SocketAddr) -> bool {
if let IpAddr::V6(ip) = addr.ip() {
if !matches!(ip.segments(), [0, 0, 0, 0, 0, 0xffff, _, _]) {
return true;
}
}
false
}
}

impl std::fmt::Debug for Path {
Expand Down

0 comments on commit 64ee2d4

Please sign in to comment.