return BSTR (&out);
}
+static const char *
+print_str (const char *str, struct gc_arena *gc)
+{
+ struct buffer out = alloc_buf_gc (128, gc);
+ buf_printf (&out, "%s", str);
+ return BSTR (&out);
+}
+
static void
helper_add_route (const in_addr_t network, const in_addr_t netmask, struct options *o)
{
}
}
}
+
+/*
+ *
+ * HELPER DIRECTIVE:
+ *
+ * tcp-nodelay
+ *
+ * EXPANDS TO:
+ *
+ * if mode server:
+ * socket-flags TCP_NODELAY
+ * push "socket-flags TCP_NODELAY"
+ */
+void
+helper_tcp_nodelay (struct options *o)
+{
+#if P2MP_SERVER
+ if (o->server_flags & SF_TCP_NODELAY_HELPER)
+ {
+ if (o->mode == MODE_SERVER)
+ {
+ o->sockflags |= SF_TCP_NODELAY;
+ push_option (o, print_str ("socket-flags TCP_NODELAY", &o->gc), M_USAGE);
+ }
+ else
+ {
+ ASSERT (0);
+ }
+ }
+#endif
+}
void helper_keepalive (struct options *o);
void helper_client_server (struct options *o);
+void helper_tcp_nodelay (struct options *o);
#endif
at this client.
.\"*********************************************************
.TP
+.B --tcp-nodelay
+This macro sets the TCP_NODELAY socket flag on the server
+as well as pushes it to connecting clients. The TCP_NODELAY
+flag disables the Nagle algorithm on TCP sockets causing
+packets to be transmitted immediately with low latency,
+rather than waiting a short period of time in order
+to aggregate several packets into a larger containing
+packet. In VPN applications over TCP, TCP_NODELAY
+is generally a good latency optimization.
+
+The macro expands as follows:
+
+.RS
+.ft 3
+.nf
+.sp
+ if mode server:
+ socket-flags TCP_NODELAY
+ push "socket-flags TCP_NODELAY"
+.ft
+.LP
+.RE
+.fi
+.\"*********************************************************
+.TP
.B --max-clients n
Limit server to a maximum of
.B n
" virtual address table to v.\n"
"--bcast-buffers n : Allocate n broadcast buffers.\n"
"--tcp-queue-limit n : Maximum number of queued TCP output packets.\n"
+ "--tcp-nodelay : Macro that sets TCP_NODELAY socket flag on the server\n"
+ " as well as pushes it to connecting clients.\n"
"--learn-address cmd : Run script cmd to validate client virtual addresses.\n"
"--connect-freq n s : Allow a maximum of n new connections per s seconds.\n"
"--max-clients n : Allow a maximum of n simultaneously connected clients.\n"
msg (M_USAGE, "--no-name-remapping requires --mode server");
if (options->ssl_flags & SSLF_OPT_VERIFY)
msg (M_USAGE, "--opt-verify requires --mode server");
+ if (options->server_flags & SF_TCP_NODELAY_HELPER)
+ msg (M_USAGE, "--tcp-nodelay requires --mode server");
if (options->auth_user_pass_verify_script)
msg (M_USAGE, "--auth-user-pass-verify requires --mode server");
#if PORT_SHARE
*/
helper_client_server (o);
helper_keepalive (o);
+ helper_tcp_nodelay (o);
options_postprocess_mutate_invariant (o);
VERIFY_PERMISSION (OPT_P_INSTANCE);
options->disable = true;
}
+ else if (streq (p[0], "tcp-nodelay"))
+ {
+ VERIFY_PERMISSION (OPT_P_GENERAL);
+ options->server_flags |= SF_TCP_NODELAY_HELPER;
+ }
#endif /* P2MP_SERVER */
else if (streq (p[0], "client"))
in_addr_t server_netmask;
# define SF_NOPOOL (1<<0)
+# define SF_TCP_NODELAY_HELPER (1<<1)
unsigned int server_flags;
bool server_bridge_proxy_dhcp;