summaryrefslogtreecommitdiff
path: root/src/socket.c
diff options
context:
space:
mode:
authorTomasz Torcz <tomek@pipebreaker.pl>2010-08-03 13:33:40 +0200
committerLennart Poettering <lennart@poettering.net>2010-08-03 23:23:47 +0200
commitcebf8b209237db381a504c50eeba76c4c28fb677 (patch)
tree9dcbfd743121a2327ecd3f1cb7af9b703ffa8652 /src/socket.c
parent07424048b52f8b22b472bf0370a185c1eb443417 (diff)
socket: Allow selection of TCP Congestion Avoidance algorithm to socket
Hi, attached path extends socket configurables with another knob - TCP Congestion Avoidance selection. Linux implements handful of those, useful in various situations. For example, TCP Low Priority may be used by FTP service to gracefully yield bandwidth for more important TCP/IP streams. Until recently TCP_CONGESTION was Linux-specific, recently FreeBSD 8 and OpenSolaris gained compatible support.
Diffstat (limited to 'src/socket.c')
-rw-r--r--src/socket.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/socket.c b/src/socket.c
index 82a9348d13..2da3215a3d 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -31,6 +31,7 @@
#include "unit.h"
#include "socket.h"
+#include "netinet/tcp.h"
#include "log.h"
#include "load-dropin.h"
#include "load-fragment.h"
@@ -116,6 +117,9 @@ static void socket_done(Unit *u) {
s->service = NULL;
+ free(s->tcp_congestion);
+ s->tcp_congestion = NULL;
+
free(s->bind_to_device);
s->bind_to_device = NULL;
@@ -371,14 +375,16 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) {
"%sSocketMode: %04o\n"
"%sDirectoryMode: %04o\n"
"%sKeepAlive: %s\n"
- "%sFreeBind: %s\n",
+ "%sFreeBind: %s\n"
+ "%sTCPCongestion: %s\n",
prefix, socket_state_to_string(s->state),
prefix, socket_address_bind_ipv6_only_to_string(s->bind_ipv6_only),
prefix, s->backlog,
prefix, s->socket_mode,
prefix, s->directory_mode,
prefix, yes_no(s->keep_alive),
- prefix, yes_no(s->free_bind));
+ prefix, yes_no(s->free_bind),
+ prefix, s->tcp_congestion);
if (s->control_pid > 0)
fprintf(f,
@@ -632,6 +638,10 @@ static void socket_apply_socket_options(Socket *s, int fd) {
if (r < 0 && x < 0)
log_warning("IP_TTL/IPV6_UNICAST_HOPS failed: %m");
}
+
+ if (s->tcp_congestion)
+ if (setsockopt(fd, SOL_TCP, TCP_CONGESTION, s->tcp_congestion, strlen(s->tcp_congestion)+1) < 0)
+ log_warning("TCP_CONGESTION failed: %m");
}
static void socket_apply_fifo_options(Socket *s, int fd) {