From 78401c614f168ffca7efb182436f033abebb2195 Mon Sep 17 00:00:00 2001 From: Damien Deville Date: Wed, 23 Nov 2022 16:21:41 +0100 Subject: [PATCH] Fix GSO / GRO auto detection when IPv6 is disabled. --- quinn-udp/src/unix.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/quinn-udp/src/unix.rs b/quinn-udp/src/unix.rs index 0fef6aa81..2e8b22735 100644 --- a/quinn-udp/src/unix.rs +++ b/quinn-udp/src/unix.rs @@ -571,7 +571,9 @@ mod gso { pub fn max_gso_segments() -> usize { const GSO_SIZE: libc::c_int = 1500; - let socket = match std::net::UdpSocket::bind("[::]:0") { + let socket = match std::net::UdpSocket::bind("[::]:0") + .or_else(|_| std::net::UdpSocket::bind("127.0.0.1:0")) + { Ok(socket) => socket, Err(_) => return 1, }; @@ -618,7 +620,9 @@ mod gro { use super::*; pub fn gro_segments() -> usize { - let socket = match std::net::UdpSocket::bind("[::]:0") { + let socket = match std::net::UdpSocket::bind("[::]:0") + .or_else(|_| std::net::UdpSocket::bind("127.0.0.1:0")) + { Ok(socket) => socket, Err(_) => return 1, };