From fdb41acd53febebce3101636947aa671f86ecec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Sun, 12 Apr 2026 20:44:18 +0200 Subject: [PATCH] socket: support TCP_CORK option in Linux Enable getting and setting the corking state of a tcp connection. See man:tcp(7). Closes: #2758 --- changelog/2769.added.md | 1 + src/sys/socket/sockopt.rs | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 changelog/2769.added.md diff --git a/changelog/2769.added.md b/changelog/2769.added.md new file mode 100644 index 0000000000..94aff9d09a --- /dev/null +++ b/changelog/2769.added.md @@ -0,0 +1 @@ +Add `nix::sys::socket::sockopt:TcpCork` on Linux. diff --git a/src/sys/socket/sockopt.rs b/src/sys/socket/sockopt.rs index 03a55d407c..5bc5ead46b 100644 --- a/src/sys/socket/sockopt.rs +++ b/src/sys/socket/sockopt.rs @@ -1315,6 +1315,16 @@ sockopt_impl!( libc::SO_ATTACH_REUSEPORT_CBPF, libc::sock_fprog ); +#[cfg(target_os = "linux")] +sockopt_impl!( + /// Enable/disable TCP corking. If enabled all queued partial frames are + /// sent when the option is cleared again. + TcpCork, + Both, + libc::IPPROTO_TCP, + libc::TCP_CORK, + bool +); #[allow(missing_docs)] // Not documented by Linux!