]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stream: support a dynamic tunnel timeout
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 10 Dec 2020 12:43:53 +0000 (13:43 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 11 Dec 2020 11:01:07 +0000 (12:01 +0100)
Allow the modification of the tunnel timeout on the stream side.
Use a new field in the stream for the tunnel timeout. It is initialized
by the tunnel timeout from backend unless it has already been set by a
set-timeout tunnel rule.

include/haproxy/stream-t.h
src/stream.c

index b2c8378f1ff5a5ad6000c715ec194c6faa7f874e..5d9d2452cdd8035a2e358ddb09152150c0bb69a3 100644 (file)
@@ -191,6 +191,8 @@ struct stream {
                /* 4 unused bytes here */
                struct act_rule *parent;        /* rule which requested this resolution */
        } dns_ctx;                              /* context information for DNS resolution */
+
+       int tunnel_timeout;
 };
 
 #endif /* _HAPROXY_STREAM_T_H */
index bed65b266fc9bc44f34ea1b7d1e44868d045f4b4..e43eace13a7d462512cf202f2963fb1a86f0955c 100644 (file)
@@ -504,6 +504,8 @@ struct stream *stream_new(struct session *sess, enum obj_type *origin, struct bu
        s->dns_ctx.hostname_dn_len = 0;
        s->dns_ctx.parent = NULL;
 
+       s->tunnel_timeout = TICK_ETERNITY;
+
        HA_SPIN_LOCK(STRMS_LOCK, &streams_lock);
        LIST_ADDQ(&streams, &s->list);
        HA_SPIN_UNLOCK(STRMS_LOCK, &streams_lock);
@@ -819,6 +821,10 @@ int stream_set_timeout(struct stream *s, enum act_timeout_name name, int timeout
                s->res.rto = timeout;
                return 1;
 
+       case ACT_TIMEOUT_TUNNEL:
+               s->tunnel_timeout = timeout;
+               return 1;
+
        default:
                return 0;
        }
@@ -900,6 +906,8 @@ static void back_establish(struct stream *s)
                        req->wto = s->be->timeout.server;
                if (!tick_isset(rep->rto))
                        rep->rto = s->be->timeout.server;
+               if (!tick_isset(s->tunnel_timeout))
+                       s->tunnel_timeout = s->be->timeout.tunnel;
 
                /* The connection is now established, try to read data from the
                 * underlying layer, and subscribe to recv events. We use a
@@ -2186,9 +2194,9 @@ struct task *process_stream(struct task *t, void *context, unsigned short state)
                 * tunnel timeout set, use it now. Note that we must respect
                 * the half-closed timeouts as well.
                 */
-               if (!req->analysers && s->be->timeout.tunnel) {
+               if (!req->analysers && s->tunnel_timeout) {
                        req->rto = req->wto = res->rto = res->wto =
-                               s->be->timeout.tunnel;
+                               s->tunnel_timeout;
 
                        if ((req->flags & CF_SHUTR) && tick_isset(sess->fe->timeout.clientfin))
                                res->wto = sess->fe->timeout.clientfin;