]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux-h2: do not emit logs on backend connections
authorWilly Tarreau <w@1wt.eu>
Wed, 23 Oct 2019 09:06:35 +0000 (11:06 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 23 Oct 2019 09:12:22 +0000 (11:12 +0200)
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.

src/mux_h2.c

index e3e797f75c1c8064d765368dad7706f075dada08..aeb91668b987b424213ede6730cec423049a72e1 100644 (file)
@@ -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;