Skip to content

Commit

Permalink
Fix Linux DF bit setting for IPv6-mapped IPv4 addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralith committed Jul 2, 2022
1 parent 4395b96 commit 5d07ad6
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions quinn-udp/src/unix.rs
Expand Up @@ -147,20 +147,21 @@ fn init(io: &std::net::UdpSocket) -> io::Result<()> {
)
};

if addr.is_ipv4() {
let rc = unsafe {
libc::setsockopt(
io.as_raw_fd(),
libc::IPPROTO_IP,
libc::IP_MTU_DISCOVER,
&libc::IP_PMTUDISC_PROBE as *const _ as _,
mem::size_of_val(&libc::IP_PMTUDISC_PROBE) as _,
)
};
if rc == -1 {
return Err(io::Error::last_os_error());
}
// Forbid IPv4 fragmentation. Set even for IPv6 to account for IPv6 mapped IPv4 addresses.
let rc = unsafe {
libc::setsockopt(
io.as_raw_fd(),
libc::IPPROTO_IP,
libc::IP_MTU_DISCOVER,
&libc::IP_PMTUDISC_PROBE as *const _ as _,
mem::size_of_val(&libc::IP_PMTUDISC_PROBE) as _,
)
};
if rc == -1 {
return Err(io::Error::last_os_error());
}

if addr.is_ipv4() {
let on: libc::c_int = 1;
let rc = unsafe {
libc::setsockopt(
Expand Down

0 comments on commit 5d07ad6

Please sign in to comment.