MEDIUM: tcp: add the "tfo" option to support TCP fastopen on the server
This implements support for the new API which relies on a call to
setsockopt().
On systems that support it (currently, only Linux >= 4.11), this enables
using TCP fast open when connecting to server.
Please note that you should use the retry-on "conn-failure", "empty-response"
and "response-timeout" keywords, or the request won't be able to be retried
on failure.
Co-authored-by: Olivier Houchard <ohouchard@haproxy.com>
diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h
index 8a4b77a..2f6a7a5 100644
--- a/include/proto/stream_interface.h
+++ b/include/proto/stream_interface.h
@@ -484,13 +484,17 @@
static inline int si_connect(struct stream_interface *si, struct connection *conn)
{
int ret = SF_ERR_NONE;
+ int conn_flags = 0;
if (unlikely(!conn || !conn->ctrl || !conn->ctrl->connect))
return SF_ERR_INTERNAL;
+ if (!channel_is_empty(si_oc(si)))
+ conn_flags |= CONNECT_HAS_DATA;
+ if (si->conn_retries == si_strm(si)->be->conn_retries)
+ conn_flags |= CONNECT_CAN_USE_TFO;
if (!conn_ctrl_ready(conn) || !conn_xprt_ready(conn)) {
- ret = conn->ctrl->connect(conn, channel_is_empty(si_oc(si)) ?
- CONNECT_HAS_DATA : 0);
+ ret = conn->ctrl->connect(conn, conn_flags);
if (ret != SF_ERR_NONE)
return ret;