Commit Graph

8 Commits

Author SHA1 Message Date
George Barnett 19b878f461
Add support for UDP_SEGMENT (#2372)
Motivation:

On Linux, the UDP_SEGMENT socket option allows for large buffers to be
written to the kernel and segmented by the kernel (or in some cases the
NIC) into smaller datagrams. This can substantially decrease the number
of syscalls.

This can be set on a per message basis on a per socket basis. This
change adds per socket configuration.

Modifications:

- Add a CNIOLinux function to check whether UDP_SEGMENT is supported on
  that particular Linux.
- Add a helper to `System` to check whether UDP_SEGMENT is supported on
  the current platform.
- On Linux only:
  - add the udp socket option level
  - add the udp_segment socket option
- Add the `DatagramSegmentSize` channel option.
- Get/Set the option in `DatagramChannel`

Results:

UDP GSO is supported on Linux.

Co-authored-by: Cory Benfield <lukasa@apple.com>
2023-02-27 13:18:58 +00:00
David Nadoba 0b4edd8329
Add `NIOBSDSocket.ProtocolSubtype` (#2317)
* RawSocket prototype

* Conform `ProtocolSubtype` to `Hashable`

* Add public `NIOIPProtocol` type

Make `ProtocolSubtype` internal

* Subset of IANA protocols with an RFC

* Add `CustomStringConvertible` to `NIOIPProtocol`

* Add `init(_ rawValue: Int)`

* Rename `NIOBSDSocket.ProtocolSubtype.ip` to `.default`

* Add `NIOBSDSocket.ProtocolSubtype.mptcp`

and remove `NIOBSDSocket.mptcpProtocolSubtype`
2022-11-22 06:01:52 -08:00
Cory Benfield 558e4f2fb8
MPTCP support on Linux (#2308)
Motivation

MPTCP provides multipath capability for TCP connections. This
allows TCP connections to consume multiple independent network
paths, providing devices with a number of capabilities to
improve throughput, latency, or reliability.

MPTCP is not totally transparent, and requires servers to support
the functionality as well as clients. To that end, we should expose
some MPTCP capability.

Importantly, MPTCP uses a number of new socket flags and options.
To enable us to support this when it is available but gracefully fail
when it is not, we've hardcoded a number of Linux kernel constants
instead of relying on libc to expose them. This is safe to do on Linux
because its syscall layer is ABI stable.

Modifications

- Add ClientBootstrap and ServerBootstrap flags for MPTCP
- Plumb MPTCP through the stack
- Add new socket options for MPTCP

Result

MPTCP is supported on Linux
2022-11-09 11:02:45 +00:00
Saleem Abdulrasool b393d39603
NIOPosix: add missing import for Windows (#2188)
Add an import of `NIOCore` on Windows which mirrors the other platforms.
This greatly reduces the noise in the error list.

Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-06-14 04:37:27 -07:00
Saleem Abdulrasool cd70dd3ec1
NIOPosix: shuffle typealias location (#2174)
Move the `sockaddr` typealias for Windows into the `BSDSocketAPIWindows`
file which is a better home for the platform specific typealias.
2022-06-07 10:24:35 -07:00
Saleem Abdulrasool 65c3f576b1
NIOPosix: reduce imports for Windows (#2170)
Reduce unnecessary noise in the files after previous refactoring
shuffled the use of the imported interfaces.  We can centralise most of
the imports and internal typealiases which avoids cluttering the shared
interfaces with compatibility handling for Windows.
2022-06-07 09:37:11 -07:00
Saleem Abdulrasool 207e6e0f7e
NIOPosix: add additional imports and typealiases on Windows (#2168)
Extend more of the internal interfaces for the BSD API coverage on
Windows to get the same API surface when possible.

Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-06-07 07:38:50 -07:00
Cory Benfield b05c6f2206
Move NIO to NIOPosix, make NIO a shell. (#1936)
Motivation:

The remaining NIO code really conceptually belongs in a module called
NIOPosix, and NIOCore should really be called NIO. We can't really do
that last step, but we can prepare by pushing the bulk of the remaining
code into a module called NIOPosix.

Modifications:

- Move NIO to NIOPosix
- Make NIO an umbrella module.

Result:

NIOPosix exists.
2021-08-16 16:50:40 +01:00