Welcome! Log In Create A New Profile

Advanced

[PATCH] Stream: added config option for TCP_FASTOPEN

Anbang Wen
April 15, 2021 12:42AM
# HG changeset patch
# User Anbang Wen <anb@papla.net>
# Date 1618433103 25200
# Wed Apr 14 13:45:03 2021 -0700
# Node ID 495a4d1d58835f7a05b24fb1aad84027f43f90c9
# Parent b56c45e3bd5029f98e1e847eebad75430e2cca27
Stream: added config option for TCP_FASTOPEN

This commit adds a "fastopen" option to stream module. The option
behaves exactly the same as the one in HTTP core module.

diff -r b56c45e3bd50 -r 495a4d1d5883 src/stream/ngx_stream.c
--- a/src/stream/ngx_stream.c Tue Apr 13 18:13:59 2021 +0300
+++ b/src/stream/ngx_stream.c Wed Apr 14 13:45:03 2021 -0700
@@ -514,6 +514,10 @@
ls->reuseport = addr[i].opt.reuseport;
#endif

+#if (NGX_HAVE_TCP_FASTOPEN)
+ ls->fastopen = addr[i].opt.fastopen;
+#endif
+
stport = ngx_palloc(cf->pool, sizeof(ngx_stream_port_t));
if (stport == NULL) {
return NGX_CONF_ERROR;
diff -r b56c45e3bd50 -r 495a4d1d5883 src/stream/ngx_stream.h
--- a/src/stream/ngx_stream.h Tue Apr 13 18:13:59 2021 +0300
+++ b/src/stream/ngx_stream.h Wed Apr 14 13:45:03 2021 -0700
@@ -66,6 +66,9 @@
int rcvbuf;
int sndbuf;
int type;
+#if (NGX_HAVE_TCP_FASTOPEN)
+ int fastopen;
+#endif
} ngx_stream_listen_t;


diff -r b56c45e3bd50 -r 495a4d1d5883 src/stream/ngx_stream_core_module.c
--- a/src/stream/ngx_stream_core_module.c Tue Apr 13 18:13:59 2021 +0300
+++ b/src/stream/ngx_stream_core_module.c Wed Apr 14 13:45:03 2021 -0700
@@ -619,6 +619,10 @@
ls->ipv6only = 1;
#endif

+#if (NGX_HAVE_TCP_FASTOPEN)
+ ls->fastopen = -1;
+#endif
+
backlog = 0;

for (i = 2; i < cf->args->nelts; i++) {
@@ -836,6 +840,19 @@
continue;
}

+#if (NGX_HAVE_TCP_FASTOPEN)
+ if (ngx_strncmp(value[i].data, "fastopen=", 9) == 0) {
+ ls->fastopen = ngx_atoi(value[i].data + 9, value[i].len - 9);
+ if (ls->fastopen == NGX_ERROR) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "invalid fastopen \"%V\"", &value[i]);
+ return NGX_CONF_ERROR;
+ }
+
+ continue;
+ }
+#endif
+
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"the invalid \"%V\" parameter", &value[i]);
return NGX_CONF_ERROR;
@@ -859,6 +876,10 @@
if (ls->proxy_protocol) {
return "\"proxy_protocol\" parameter is incompatible with \"udp\"";
}
+
+ if (ls->fastopen >= 0) {
+ return "\"fastopen\" parameter is incompatible with \"udp\"";
+ }
}

als = cmcf->listen.elts;


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Stream: added config option for TCP_FASTOPEN

Anbang Wen 447 April 15, 2021 12:42AM

Re: [PATCH] Stream: added config option for TCP_FASTOPEN

ru@nginx.com 393 May 17, 2021 09:42AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 262
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready