From befc6e430add4b322e01c492e69dd4ccb2f02b9d Mon Sep 17 00:00:00 2001 From: Vladislav Grishenko Date: Sat, 1 Aug 2020 14:18:20 +0500 Subject: sstp: allow to configure send & receive buffer sizes magic value of 65535 reported to have thoughput issues on unreliable transports (3G/4G), so let it be configurable. zero value means use system defaults: [sstp] sndbuf=0 rvcbuf=0 --- accel-pppd/ctrl/sstp/sstp.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'accel-pppd/ctrl/sstp/sstp.c') diff --git a/accel-pppd/ctrl/sstp/sstp.c b/accel-pppd/ctrl/sstp/sstp.c index 9a285ca6..847851c7 100644 --- a/accel-pppd/ctrl/sstp/sstp.c +++ b/accel-pppd/ctrl/sstp/sstp.c @@ -165,6 +165,8 @@ static const char *conf_ipv6_pool; static const char *conf_dpv6_pool; static const char *conf_ifname; static int conf_proxyproto = 0; +static int conf_sndbuf = 0; +static int conf_rcvbuf = 0; static int conf_hash_protocol = CERT_HASH_PROTOCOL_SHA1 | CERT_HASH_PROTOCOL_SHA256; static struct hash_t conf_hash_sha1 = { .len = 0 }; @@ -2299,9 +2301,17 @@ static int sstp_connect(struct triton_md_handler_t *h) } if (addr.u.sa.sa_family != AF_UNIX) { - value = 65536; - if (setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &value, sizeof(value)) < 0) { - log_error("sstp: failed to set send buffer: %s, closing connection...\n", strerror(errno)); + if (conf_sndbuf && + setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &conf_sndbuf, sizeof(conf_sndbuf)) < 0) { + log_error("sstp: failed to set send buffer to %d: %s, closing connection...\n", + conf_sndbuf, strerror(errno)); + close(sock); + continue; + } + if (conf_rcvbuf && + setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &conf_rcvbuf, sizeof(conf_rcvbuf)) < 0) { + log_error("sstp: failed to set recv buffer to %d: %s, closing connection...\n", + conf_rcvbuf, strerror(errno)); close(sock); continue; } @@ -2800,6 +2810,14 @@ static void load_config(void) conf_dpv6_pool = conf_get_opt("sstp", "ipv6-pool-delegate"); conf_ifname = conf_get_opt("sstp", "ifname"); + opt = conf_get_opt("sstp", "sndbuf"); + if (opt && atoi(opt) > 0) + conf_sndbuf = atoi(opt); + + opt = conf_get_opt("sstp", "rcvbuf"); + if (opt && atoi(opt) > 0) + conf_rcvbuf = atoi(opt); + ipmode = (serv.addr.u.sa.sa_family == AF_INET && !conf_proxyproto) ? iprange_check_activation() : -1; switch (ipmode) { -- cgit v1.2.3