mirror of
https://github.com/n0-computer/noq.git
synced 2026-10-03 12:40:46 +00:00
Disable IP fragmentation on Linux
This commit is contained in:
+1
-1
@@ -31,7 +31,7 @@ azure-devops = { project = "dochtman/Projects", pipeline = "Quinn", build = "1"
|
||||
bytes = "0.5.2"
|
||||
err-derive = "0.2.3"
|
||||
futures = "0.3.1"
|
||||
libc = "0.2.49"
|
||||
libc = "0.2.67"
|
||||
mio = "0.6"
|
||||
proto = { package = "quinn-proto", path = "../quinn-proto", version = "0.5.0" }
|
||||
rustls = { version = "0.17", features = ["quic"], optional = true }
|
||||
|
||||
@@ -53,6 +53,39 @@ impl super::UdpExt for UdpSocket {
|
||||
return Err(io::Error::last_os_error());
|
||||
}
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
// TODO: Replace with constants from libc > 0.2.67
|
||||
const IP_PMTUDISC_PROBE: libc::c_int = 2;
|
||||
if addr.is_ipv4() {
|
||||
const IP_MTU_DISCOVER: libc::c_int = 10;
|
||||
let rc = unsafe {
|
||||
libc::setsockopt(
|
||||
self.as_raw_fd(),
|
||||
libc::IPPROTO_IP,
|
||||
IP_MTU_DISCOVER,
|
||||
&IP_PMTUDISC_PROBE as *const _ as _,
|
||||
mem::size_of_val(&IP_PMTUDISC_PROBE) as _,
|
||||
)
|
||||
};
|
||||
if rc == -1 {
|
||||
return Err(io::Error::last_os_error());
|
||||
}
|
||||
} else if addr.is_ipv6() {
|
||||
let rc = unsafe {
|
||||
libc::setsockopt(
|
||||
self.as_raw_fd(),
|
||||
libc::IPPROTO_IPV6,
|
||||
libc::IPV6_MTU_DISCOVER,
|
||||
&IP_PMTUDISC_PROBE as *const _ as _,
|
||||
mem::size_of_val(&IP_PMTUDISC_PROBE) as _,
|
||||
)
|
||||
};
|
||||
if rc == -1 {
|
||||
return Err(io::Error::last_os_error());
|
||||
}
|
||||
}
|
||||
}
|
||||
if addr.is_ipv6() {
|
||||
let on: libc::c_int = 1;
|
||||
let rc = unsafe {
|
||||
|
||||
Reference in New Issue
Block a user