add log message for MPTCP bind failure

This commit is contained in:
Rob Ede 2023-07-17 03:48:45 +01:00
parent 7ee0c08740
commit b3804361d2
No known key found for this signature in database
GPG Key ID: 97C636207D3EF933
2 changed files with 9 additions and 6 deletions

View File

@ -13,6 +13,8 @@ use crate::{
};
/// Multipath TCP (MPTCP) preference.
///
/// Also see [`ServerBuilder::mptcp()`].
#[derive(Debug, Clone)]
pub enum MpTcp {
/// MPTCP will not be used when binding sockets.

View File

@ -240,13 +240,14 @@ pub(crate) fn create_mio_tcp_listener(
let socket = match Socket::new(Domain::for_address(addr), Type::STREAM, Some(protocol)) {
Ok(sock) => sock,
Err(err) => {
if matches!(mptcp, MpTcp::TcpFallback) {
Socket::new(Domain::for_address(addr), Type::STREAM, Some(Protocol::TCP))?
} else {
return Err(err);
}
Err(err) if matches!(mptcp, MpTcp::TcpFallback) => {
tracing::warn!("binding socket as MPTCP failed: {err}");
tracing::warn!("falling back to TCP");
Socket::new(Domain::for_address(addr), Type::STREAM, Some(Protocol::TCP))?
}
Err(err) => return Err(err),
};
socket.set_reuse_address(true)?;