mirror of https://github.com/fafhrd91/actix-net
update mptcp docs
This commit is contained in:
parent
e6764a4ff4
commit
786fe7af1f
|
@ -2,9 +2,7 @@
|
||||||
|
|
||||||
## Unreleased - 2023-xx-xx
|
## Unreleased - 2023-xx-xx
|
||||||
|
|
||||||
- Add support for Multipath TCP (MPTCP).
|
- Add support for MultiPath TCP (MPTCP) with `Mptcp` enum and `ServerBuilder::mptcp()` method.
|
||||||
- Add `MPTCP` enum.
|
|
||||||
- Add `ServerBuilder::mptcp()` method.
|
|
||||||
- Minimum supported Rust version (MSRV) is now 1.65.
|
- Minimum supported Rust version (MSRV) is now 1.65.
|
||||||
|
|
||||||
## 2.2.0 - 2022-12-21
|
## 2.2.0 - 2022-12-21
|
||||||
|
|
|
@ -12,10 +12,17 @@ use crate::{
|
||||||
Server,
|
Server,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Copy, Clone)]
|
/// Multipath TCP (MPTCP) preference.
|
||||||
pub enum MPTCP {
|
#[derive(Debug, Clone)]
|
||||||
|
pub enum Mptcp {
|
||||||
|
/// MPTCP will not be used when binding sockets.
|
||||||
Disabled,
|
Disabled,
|
||||||
|
|
||||||
|
/// MPTCP will be attempted when binding sockets. If errors occur, regular TCP will be
|
||||||
|
/// attempted, too.
|
||||||
TcpFallback,
|
TcpFallback,
|
||||||
|
|
||||||
|
/// MPTCP will be used when binding sockets (with no fallback).
|
||||||
NoFallback,
|
NoFallback,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +33,7 @@ pub struct ServerBuilder {
|
||||||
pub(crate) backlog: u32,
|
pub(crate) backlog: u32,
|
||||||
pub(crate) factories: Vec<Box<dyn InternalServiceFactory>>,
|
pub(crate) factories: Vec<Box<dyn InternalServiceFactory>>,
|
||||||
pub(crate) sockets: Vec<(usize, String, MioListener)>,
|
pub(crate) sockets: Vec<(usize, String, MioListener)>,
|
||||||
pub(crate) mptcp: MPTCP,
|
pub(crate) mptcp: Mptcp,
|
||||||
pub(crate) exit: bool,
|
pub(crate) exit: bool,
|
||||||
pub(crate) listen_os_signals: bool,
|
pub(crate) listen_os_signals: bool,
|
||||||
pub(crate) cmd_tx: UnboundedSender<ServerCommand>,
|
pub(crate) cmd_tx: UnboundedSender<ServerCommand>,
|
||||||
|
@ -105,21 +112,20 @@ impl ServerBuilder {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Enable the MPTCP protocol at the socket level.
|
/// Sets MultiPath TCP (MPTCP) preference on bound sockets.
|
||||||
///
|
///
|
||||||
/// This enable the Multiple Path TCP protocol at the socket level. This means it's managed
|
/// Multipath TCP (MPTCP) builds on top of TCP to improve connection redundancy and performance
|
||||||
/// by the kernel and the application (userspace) doesn't have to deal with path management.
|
/// by sharing a network data stream across multiple underlying TCP sessions. See [mptcp.dev]
|
||||||
|
/// for more info about MPTCP itself.
|
||||||
///
|
///
|
||||||
/// Only available in Linux Kernel >= 5.6. If you try to set it on a Windows machine or on
|
/// MPTCP is available on Linux kernel version 5.6 and higher. In addition, you'll also need to
|
||||||
/// an older Linux machine, this will fail with a panic.
|
/// ensure the kernel option is enabled using `sysctl net.mptcp.enabled=1`.
|
||||||
///
|
|
||||||
/// In Addition to a recent Linux Kernel, you also need to enable the sysctl (if it's not on
|
|
||||||
/// by default):
|
|
||||||
/// `sysctl sysctl net.mptcp.enabled=1`
|
|
||||||
///
|
///
|
||||||
/// This method will have no effect if called after a `bind()`.
|
/// This method will have no effect if called after a `bind()`.
|
||||||
|
///
|
||||||
|
/// [mptcp.dev]: https://www.mptcp.dev
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub fn mptcp(mut self, mptcp_enabled: MPTCP) -> Self {
|
pub fn mptcp(mut self, mptcp_enabled: Mptcp) -> Self {
|
||||||
self.mptcp = mptcp_enabled;
|
self.mptcp = mptcp_enabled;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,14 +225,14 @@ mod unix_impl {
|
||||||
pub(crate) fn create_mio_tcp_listener(
|
pub(crate) fn create_mio_tcp_listener(
|
||||||
addr: StdSocketAddr,
|
addr: StdSocketAddr,
|
||||||
backlog: u32,
|
backlog: u32,
|
||||||
mptcp: &MPTCP,
|
mptcp: &Mptcp,
|
||||||
) -> io::Result<MioTcpListener> {
|
) -> io::Result<MioTcpListener> {
|
||||||
use socket2::{Domain, Protocol, Socket, Type};
|
use socket2::{Domain, Protocol, Socket, Type};
|
||||||
|
|
||||||
#[cfg(not(target_os = "linux"))]
|
#[cfg(not(target_os = "linux"))]
|
||||||
let protocol = Protocol::TCP;
|
let protocol = Protocol::TCP;
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
let protocol = if mptcp == &MPTCP::Disabled {
|
let protocol = if matches!(mptcp, Mptcp::Disabled) {
|
||||||
Protocol::TCP
|
Protocol::TCP
|
||||||
} else {
|
} else {
|
||||||
Protocol::MPTCP
|
Protocol::MPTCP
|
||||||
|
@ -241,7 +241,7 @@ pub(crate) fn create_mio_tcp_listener(
|
||||||
let socket = match Socket::new(Domain::for_address(addr), Type::STREAM, Some(protocol)) {
|
let socket = match Socket::new(Domain::for_address(addr), Type::STREAM, Some(protocol)) {
|
||||||
Ok(sock) => sock,
|
Ok(sock) => sock,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
if mptcp == &MPTCP::TcpFallback {
|
if mptcp == &Mptcp::TcpFallback {
|
||||||
Socket::new(Domain::for_address(addr), Type::STREAM, Some(Protocol::TCP))?
|
Socket::new(Domain::for_address(addr), Type::STREAM, Some(Protocol::TCP))?
|
||||||
} else {
|
} else {
|
||||||
return Err(err);
|
return Err(err);
|
||||||
|
|
Loading…
Reference in New Issue