From: Willy Tarreau Date: Wed, 23 Oct 2019 09:06:35 +0000 (+0200) Subject: BUG/MINOR: mux-h2: do not emit logs on backend connections X-Git-Tag: v2.1-dev3~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9364a5fda33a2f591d5e2640249a54af8955fb8b;p=thirdparty%2Fhaproxy.git BUG/MINOR: mux-h2: do not emit logs on backend connections The logs were added to the H2 mux so that we can report logs in case of errors that prevent a stream from being created, but as a side effect these logs are emitted twice for backend connections: once by the H2 mux itself and another time by the upper layer stream. It can even happen more with connection retries. This patch makes sure we do not emit logs for backend connections. It should be backported to 2.0 and 1.9. --- diff --git a/src/mux_h2.c b/src/mux_h2.c index e3e797f75c..aeb91668b9 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -2062,7 +2062,8 @@ static int h2c_handle_settings(struct h2c *h2c) TRACE_LEAVE(H2_EV_RX_FRAME|H2_EV_RX_SETTINGS, h2c->conn); return 1; fail: - sess_log(h2c->conn->owner); + if (!(h2c->flags & H2_CF_IS_BACK)) + sess_log(h2c->conn->owner); h2c_error(h2c, error); out0: TRACE_DEVEL("leaving with missing data or error", H2_EV_RX_FRAME|H2_EV_RX_SETTINGS, h2c->conn); @@ -2763,7 +2764,7 @@ static int h2_frame_check_vs_state(struct h2c *h2c, struct h2s *h2s) * this state MUST be treated as a connection error */ h2c_error(h2c, H2_ERR_PROTOCOL_ERROR); - if (!h2c->nb_streams) { + if (!h2c->nb_streams && !(h2c->flags & H2_CF_IS_BACK)) { /* only log if no other stream can report the error */ sess_log(h2c->conn->owner); } @@ -2914,7 +2915,8 @@ static void h2_process_demux(struct h2c *h2c) if (h2c->st0 == H2_CS_ERROR) { TRACE_PROTO("failed to receive settings", H2_EV_RX_FRAME|H2_EV_RX_FHDR|H2_EV_RX_SETTINGS|H2_EV_PROTO_ERR, h2c->conn); h2c->st0 = H2_CS_ERROR2; - sess_log(h2c->conn->owner); + if (!(h2c->flags & H2_CF_IS_BACK)) + sess_log(h2c->conn->owner); } goto fail; } @@ -2924,7 +2926,8 @@ static void h2_process_demux(struct h2c *h2c) TRACE_PROTO("unexpected frame type or flags", H2_EV_RX_FRAME|H2_EV_RX_FHDR|H2_EV_RX_SETTINGS|H2_EV_PROTO_ERR, h2c->conn); h2c_error(h2c, H2_ERR_PROTOCOL_ERROR); h2c->st0 = H2_CS_ERROR2; - sess_log(h2c->conn->owner); + if (!(h2c->flags & H2_CF_IS_BACK)) + sess_log(h2c->conn->owner); goto fail; } @@ -2933,7 +2936,8 @@ static void h2_process_demux(struct h2c *h2c) TRACE_PROTO("invalid settings frame length", H2_EV_RX_FRAME|H2_EV_RX_FHDR|H2_EV_RX_SETTINGS|H2_EV_PROTO_ERR, h2c->conn); h2c_error(h2c, H2_ERR_FRAME_SIZE_ERROR); h2c->st0 = H2_CS_ERROR2; - sess_log(h2c->conn->owner); + if (!(h2c->flags & H2_CF_IS_BACK)) + sess_log(h2c->conn->owner); goto fail; } @@ -2970,7 +2974,7 @@ static void h2_process_demux(struct h2c *h2c) if ((int)hdr.len < 0 || (int)hdr.len > global.tune.bufsize) { TRACE_PROTO("invalid H2 frame length", H2_EV_RX_FRAME|H2_EV_RX_FHDR|H2_EV_PROTO_ERR, h2c->conn); h2c_error(h2c, H2_ERR_FRAME_SIZE_ERROR); - if (!h2c->nb_streams) { + if (!h2c->nb_streams && !(h2c->flags & H2_CF_IS_BACK)) { /* only log if no other stream can report the error */ sess_log(h2c->conn->owner); } @@ -2989,7 +2993,8 @@ static void h2_process_demux(struct h2c *h2c) if (hdr.len < 1) { TRACE_PROTO("invalid H2 padded frame length", H2_EV_RX_FRAME|H2_EV_RX_FHDR|H2_EV_PROTO_ERR, h2c->conn); h2c_error(h2c, H2_ERR_FRAME_SIZE_ERROR); - sess_log(h2c->conn->owner); + if (!(h2c->flags & H2_CF_IS_BACK)) + sess_log(h2c->conn->owner); goto fail; } hdr.len--; @@ -3005,7 +3010,8 @@ static void h2_process_demux(struct h2c *h2c) * frame payload or greater => error. */ h2c_error(h2c, H2_ERR_PROTOCOL_ERROR); - sess_log(h2c->conn->owner); + if (!(h2c->flags & H2_CF_IS_BACK)) + sess_log(h2c->conn->owner); goto fail; } @@ -3031,7 +3037,8 @@ static void h2_process_demux(struct h2c *h2c) if (ret != H2_ERR_NO_ERROR) { TRACE_PROTO("received invalid H2 frame header", H2_EV_RX_FRAME|H2_EV_RX_FHDR|H2_EV_PROTO_ERR, h2c->conn); h2c_error(h2c, ret); - sess_log(h2c->conn->owner); + if (!(h2c->flags & H2_CF_IS_BACK)) + sess_log(h2c->conn->owner); goto fail; } } @@ -3104,7 +3111,8 @@ static void h2_process_demux(struct h2c *h2c) */ TRACE_PROTO("received unexpected H2 CONTINUATION frame", H2_EV_RX_FRAME|H2_EV_RX_CONT|H2_EV_H2C_ERR, h2c->conn, h2s); h2c_error(h2c, H2_ERR_PROTOCOL_ERROR); - sess_log(h2c->conn->owner); + if (!(h2c->flags & H2_CF_IS_BACK)) + sess_log(h2c->conn->owner); goto fail; case H2_FT_HEADERS: @@ -3241,10 +3249,8 @@ static int h2_process_mux(struct h2c *h2c) if (unlikely(h2c->st0 == H2_CS_PREFACE && (h2c->flags & H2_CF_IS_BACK))) { if (unlikely(h2c_bck_send_preface(h2c) <= 0)) { /* RFC7540#3.5: a GOAWAY frame MAY be omitted */ - if (h2c->st0 == H2_CS_ERROR) { + if (h2c->st0 == H2_CS_ERROR) h2c->st0 = H2_CS_ERROR2; - sess_log(h2c->conn->owner); - } goto fail; } h2c->st0 = H2_CS_SETTINGS1;