From c3a3b210da852cb6e2a51d2759f0a58401c7270d Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 6 Nov 2019 14:36:58 +0200 Subject: [PATCH] lib: Add net_set_tcp_quickack() --- src/lib/net.c | 12 ++++++++++++ src/lib/net.h | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/src/lib/net.c b/src/lib/net.c index 25645c39bb..7eeed6319f 100644 --- a/src/lib/net.c +++ b/src/lib/net.c @@ -366,6 +366,18 @@ int net_set_tcp_nodelay(int fd, bool nodelay) return setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)); } +int net_set_tcp_quickack(int fd, bool quickack) +{ +#ifdef TCP_QUICKACK + int val = quickack; + + return setsockopt(fd, IPPROTO_TCP, TCP_QUICKACK, &val, sizeof(val)); +#else + errno = ENOPROTOOPT; + return -1; +#endif +} + int net_set_send_buffer_size(int fd, size_t size) { int opt; diff --git a/src/lib/net.h b/src/lib/net.h index 84d2f45b01..7f8abb7181 100644 --- a/src/lib/net.h +++ b/src/lib/net.h @@ -98,6 +98,10 @@ void net_set_nonblock(int fd, bool nonblock); int net_set_cork(int fd, bool cork) ATTR_NOWARN_UNUSED_RESULT; /* Set TCP_NODELAY, which disables the Nagle algorithm. */ int net_set_tcp_nodelay(int fd, bool nodelay); +/* Set TCP_QUICKACK, which tells the kernel to not delay ACKs. Note that the + kernel can (and will) re-enable delayed ACKs while processing the TCP stack. + This means that this function needs to be called repeatedly. */ +int net_set_tcp_quickack(int fd, bool quickack); /* Set socket kernel buffer sizes */ int net_set_send_buffer_size(int fd, size_t size); -- 2.47.3