diff --git a/NEWS b/NEWS index 73dd7bcb..b7125d54 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,9 @@ the suggested values and ignores the other. - Reduce limit of output buffer on DTLS socket to reduce latency (following similar openconnect change). +- Added config option "output-buffer" to allow selecting between high throughput + or low latency. +- Enabled config option "mtu". * Version 0.1.6 (released 2013-09-02) diff --git a/doc/sample.config b/doc/sample.config index 63c8b8a9..72199d49 100644 --- a/doc/sample.config +++ b/doc/sample.config @@ -161,6 +161,11 @@ ping-leases = false # Leave empty to assign the default MTU of the device # mtu = +# The number of packets (of MTU size) that are available in +# the output buffer. The default is low to improve latency. +# Setting it higher will improve throughput. +output-buffer = 10 + route = 192.168.1.0/255.255.255.0 #route = 192.168.5.0/255.255.255.0 diff --git a/src/config.c b/src/config.c index a6951853..6ecf7081 100644 --- a/src/config.c +++ b/src/config.c @@ -202,6 +202,9 @@ unsigned j; READ_STRING("tls-priorities", config->priorities, 0); READ_STRING("chroot-dir", config->chroot_dir, 0); + READ_NUMERIC("mtu", config->default_mtu, 0); + READ_NUMERIC("output-buffer", config->output_buffer, 0); + READ_NUMERIC("cookie-validity", config->cookie_validity, 1); READ_NUMERIC("auth-timeout", config->auth_timeout, 0); READ_NUMERIC("max-clients", config->max_clients, 0); diff --git a/src/ocserv-args.c b/src/ocserv-args.c index 0dc53e3e..73a2d123 100644 --- a/src/ocserv-args.c +++ b/src/ocserv-args.c @@ -2,7 +2,7 @@ * * DO NOT EDIT THIS FILE (ocserv-args.c) * - * It has been AutoGen-ed October 5, 2013 at 09:36:46 AM by AutoGen 5.17 + * It has been AutoGen-ed October 20, 2013 at 05:44:06 PM by AutoGen 5.17 * From the definitions ocserv-args.def * and the template file options * diff --git a/src/ocserv-args.def b/src/ocserv-args.def index 7616655f..18007649 100644 --- a/src/ocserv-args.def +++ b/src/ocserv-args.def @@ -249,6 +249,11 @@ ping-leases = false # Unset to assign the default MTU of the device # mtu = +# The number of packets (of MTU size) that are available in +# the output buffer. The default is low to improve latency. +# Setting it higher will improve throughput. +output-buffer = 10 + # Routes to be forwarded to the client. If you need the # client to forward routes to the server, you may use the connect # and disconnect scripts. diff --git a/src/ocserv-args.h b/src/ocserv-args.h index d3160e4b..f9078cc0 100644 --- a/src/ocserv-args.h +++ b/src/ocserv-args.h @@ -2,7 +2,7 @@ * * DO NOT EDIT THIS FILE (ocserv-args.h) * - * It has been AutoGen-ed October 5, 2013 at 09:36:46 AM by AutoGen 5.17 + * It has been AutoGen-ed October 20, 2013 at 05:44:06 PM by AutoGen 5.17 * From the definitions ocserv-args.def * and the template file options * diff --git a/src/vpn.h b/src/vpn.h index f7cc6618..1eac35e6 100644 --- a/src/vpn.h +++ b/src/vpn.h @@ -112,6 +112,9 @@ struct cfg_st { unsigned force_cert_auth; /* always require client certificate */ unsigned rate_limit_ms; /* if non zero force a connection every rate_limit milliseconds */ unsigned ping_leases; /* non zero if we need to ping prior to leasing */ + + unsigned output_buffer; + unsigned default_mtu; char *connect_script; char *disconnect_script; diff --git a/src/worker-vpn.c b/src/worker-vpn.c index 869e4b20..e6c8590b 100644 --- a/src/worker-vpn.c +++ b/src/worker-vpn.c @@ -912,6 +912,10 @@ socklen_t sl; ); SEND_ERR(ret); + if (ws->config->default_mtu > 0) { + vinfo.mtu = ws->config->default_mtu; + } + mtu_overhead = CSTP_OVERHEAD; ws->conn_mtu = vinfo.mtu - mtu_overhead; if (req->cstp_mtu > 0) { @@ -979,8 +983,10 @@ socklen_t sl; tls_printf(ws->session, "X-DTLS-MTU: %u\r\n", dtls_mtu); oclog(ws, LOG_INFO, "suggesting DTLS MTU %u", dtls_mtu); - sndbuf = ws->conn_mtu * 4; - setsockopt( ws->udp_fd, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(sndbuf)); + if (ws->config->output_buffer > 0) { + sndbuf = ws->conn_mtu * ws->config->output_buffer; + setsockopt( ws->udp_fd, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof(sndbuf)); + } } else dtls_mtu = 0;