BUG/MINOR: rhttp: ensure GOAWAY can be emitted after reversal

GOAWAY emission should not be emitted before preface. Thus, max_id field
from h2c acting as a server is initialized to -1, which prevents its
emission until preface is received from the peer. If acting as a client,
max_id is initialized to a valid value on the first h2s emission.

This causes an issue with reverse HTTP on the active side. First, it
starts as a client, so the peer does not emit a preface but instead a
simple SETTINGS frame. As role are switched, max_id is initialized much
later when the first h2s response is emitted. Thus, if the connection
must be terminated before any stream transfer, GOAWAY cannot be emitted.

To fix this, ensure max_id is initialized to 0 on h2_conn_reverse() for
active connect side. Thus, a GOAWAY indicating that no stream has been
handled can be generated.

Note that passive connect side is not impacted, as it max_id is
initialized thanks to preface reception.

This should be backported up to 2.9.
This commit is contained in:
Amaury Denoyelle 2025-04-10 17:41:39 +02:00
parent 2b8da5f9ab
commit 9e6f8ce328

View File

@ -3997,6 +3997,8 @@ static int h2_conn_reverse(struct h2c *h2c)
struct proxy *prx = l->bind_conf->frontend;
h2c->flags &= ~H2_CF_IS_BACK;
/* Must manually init max_id so that GOAWAY can be emitted. */
h2c->max_id = 0;
h2c->shut_timeout = h2c->timeout = prx->timeout.client;
if (tick_isset(prx->timeout.clientfin))