[MEDIUM] add support for TCP MSS adjustment for listeners
Sometimes it can be useful to limit the advertised TCP MSS on
incoming connections, for instance when requests come through
a VPN or when the system is running with jumbo frames enabled.
Passing the "mss <value>" arguments to a "bind" line will set
the value. This works under Linux >= 2.6.28, and maybe a few
earlier ones, though due to an old kernel bug most of earlier
versions will probably ignore it. It is also possible that some
other OSes will support this.
diff --git a/src/proto_tcp.c b/src/proto_tcp.c
index e9b3ae3..adf4e23 100644
--- a/src/proto_tcp.c
+++ b/src/proto_tcp.c
@@ -251,6 +251,15 @@
}
}
#endif
+#ifdef TCP_MAXSEG
+ if (listener->maxseg) {
+ if (setsockopt(fd, SOL_TCP, TCP_MAXSEG,
+ &listener->maxseg, sizeof(listener->maxseg)) == -1) {
+ msg = "cannot set MSS";
+ err |= ERR_WARN;
+ }
+ }
+#endif
if (bind(fd, (struct sockaddr *)&listener->addr, listener->proto->sock_addrlen) == -1) {
err |= ERR_RETRYABLE | ERR_ALERT;
msg = "cannot bind socket";