]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-h2: obey http-ignore-probes during the preface
authorWilly Tarreau <w@1wt.eu>
Thu, 17 Jun 2021 06:08:48 +0000 (08:08 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 17 Jun 2021 06:08:48 +0000 (08:08 +0200)
We're seeing some browsers setting up multiple connections and closing
some to just keep one. It looks like they do this in case they'd
negotiate H1. This results in aborted prefaces and log pollution about
bad requests and "PR--" in the status flags.

We already have an option to ignore connections with no data, it's called
http-ignore-probes. But it was not used by the H2 mux. However it totally
makes sense to use it during the preface.

This patch changes this so that connections aborted before sending the
preface can avoid being logged.

This should be backported to 2.4 and 2.3 at least, and probably even
as far as 2.0.

src/mux_h2.c

index dfd437e700d59ea0e1648dad775f0e2edc70f96a..1150660b9c47f8b3cd8f1ab5a45ffb1074dfebe1 100644 (file)
@@ -1701,7 +1701,9 @@ static int h2c_frt_recv_preface(struct h2c *h2c)
                if (ret1 < 0 || conn_xprt_read0_pending(h2c->conn)) {
                        TRACE_ERROR("I/O error or short read", H2_EV_RX_FRAME|H2_EV_RX_PREFACE, h2c->conn);
                        h2c_error(h2c, H2_ERR_PROTOCOL_ERROR);
-                       HA_ATOMIC_INC(&h2c->px_counters->conn_proto_err);
+                       if (b_data(&h2c->dbuf) ||
+                           !(((const struct session *)h2c->conn->owner)->fe->options & PR_O_IGNORE_PRB))
+                               HA_ATOMIC_INC(&h2c->px_counters->conn_proto_err);
                }
                ret2 = 0;
                goto out;
@@ -3128,7 +3130,9 @@ static void h2_process_demux(struct h2c *h2c)
                                if (h2c->st0 == H2_CS_ERROR) {
                                        TRACE_PROTO("failed to receive preface", H2_EV_RX_PREFACE|H2_EV_PROTO_ERR, h2c->conn);
                                        h2c->st0 = H2_CS_ERROR2;
-                                       sess_log(h2c->conn->owner);
+                                       if (b_data(&h2c->dbuf) ||
+                                           !(((const struct session *)h2c->conn->owner)->fe->options & PR_O_IGNORE_PRB))
+                                               sess_log(h2c->conn->owner);
                                }
                                goto fail;
                        }