]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux-h1: Add flag on H1 stream to deal with internal errors
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 5 Oct 2022 05:50:19 +0000 (07:50 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 17 Nov 2022 13:33:14 +0000 (14:33 +0100)
A new error is added on H1 stream to deal with internal errors. For now,
this error is only reported when we fail to create a stream-connector. This
way, the error is reported at the H1 stream level and not the H1 connection
level.

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

index 63508170aa4795ac2e22fcbc0a418e34b25c281a..24579e677152ebcdfc9ec39ebc24178a9bd54a99 100644 (file)
@@ -92,11 +92,11 @@ static forceinline char *h1c_show_flags(char *buf, size_t len, const char *delim
 #define H1S_F_NOT_FIRST      0x00000080 /* The H1 stream is not the first one */
 #define H1S_F_BODYLESS_RESP  0x00000100 /* Bodyless response message */
 
-/* 0x00000200 unused */
+#define H1S_F_INTERNAL_ERROR 0x00000200 /* Set when an internal error occurred during the message parsing */
 #define H1S_F_NOT_IMPL_ERROR 0x00000400 /* Set when a feature is not implemented during the message parsing */
 #define H1S_F_PARSING_ERROR  0x00000800 /* Set when an error occurred during the message parsing */
 #define H1S_F_PROCESSING_ERROR 0x00001000 /* Set when an error occurred during the message xfer */
-#define H1S_F_ERROR_MASK     0x00001800 /* stream error mask */
+#define H1S_F_ERROR_MASK     0x00003800 /* stream error mask */
 
 #define H1S_F_HAVE_SRV_NAME  0x00002000 /* Set during output process if the server name header was added to the request */
 #define H1S_F_HAVE_O_CONN    0x00004000 /* Set during output process to know connection mode was processed */
@@ -114,8 +114,8 @@ static forceinline char *h1s_show_flags(char *buf, size_t len, const char *delim
        _(H1S_F_RX_BLK, _(H1S_F_TX_BLK, _(H1S_F_RX_CONGESTED,
        _(H1S_F_REOS, _(H1S_F_WANT_KAL, _(H1S_F_WANT_TUN, _(H1S_F_WANT_CLO,
        _(H1S_F_NOT_FIRST, _(H1S_F_BODYLESS_RESP,
-       _(H1S_F_NOT_IMPL_ERROR, _(H1S_F_PARSING_ERROR, _(H1S_F_PROCESSING_ERROR,
-       _(H1S_F_HAVE_SRV_NAME, _(H1S_F_HAVE_O_CONN))))))))))))));
+       _(H1S_F_INTERNAL_ERROR, _(H1S_F_NOT_IMPL_ERROR, _(H1S_F_PARSING_ERROR, _(H1S_F_PROCESSING_ERROR,
+       _(H1S_F_HAVE_SRV_NAME, _(H1S_F_HAVE_O_CONN)))))))))))))));
        /* epilogue */
        _(~0U);
        return buf;
index bf4798576e352861ca0077ba644a70eedf3ead3a..3f7e102ca187650a83c7d69b5db305340d4b7f98 100644 (file)
@@ -1732,7 +1732,7 @@ static size_t h1_process_demux(struct h1c *h1c, struct buffer *buf, size_t count
        h1m = (!(h1c->flags & H1C_F_IS_BACK) ? &h1s->req : &h1s->res);
        data = htx->data;
 
-       if (h1s->flags & (H1S_F_PARSING_ERROR|H1S_F_NOT_IMPL_ERROR))
+       if (h1s->flags & (H1S_F_INTERNAL_ERROR|H1S_F_PARSING_ERROR|H1S_F_NOT_IMPL_ERROR))
                goto end;
 
        if (h1s->flags & H1S_F_RX_BLK)
@@ -1850,7 +1850,7 @@ static size_t h1_process_demux(struct h1c *h1c, struct buffer *buf, size_t count
                        TRACE_DEVEL("request headers fully parsed, create and attach the SC", H1_EV_RX_DATA, h1c->conn, h1s);
                        BUG_ON(h1s_sc(h1s));
                        if (!h1s_new_sc(h1s, buf)) {
-                               h1c->flags |= H1C_F_ERROR;
+                               h1s->flags |= H1S_F_INTERNAL_ERROR;
                                goto err;
                        }
                }
@@ -1858,7 +1858,7 @@ static size_t h1_process_demux(struct h1c *h1c, struct buffer *buf, size_t count
                        TRACE_DEVEL("request headers fully parsed, upgrade the inherited SC", H1_EV_RX_DATA, h1c->conn, h1s);
                        BUG_ON(h1s_sc(h1s) == NULL);
                        if (!h1s_upgrade_sc(h1s, buf)) {
-                               h1c->flags |= H1C_F_ERROR;
+                               h1s->flags |= H1S_F_INTERNAL_ERROR;
                                TRACE_ERROR("H1S upgrade failure", H1_EV_RX_DATA|H1_EV_H1S_ERR, h1c->conn, h1s);
                                goto err;
                        }
@@ -1953,7 +1953,7 @@ static size_t h1_process_mux(struct h1c *h1c, struct buffer *buf, size_t count)
        if (htx_is_empty(chn_htx))
                goto end;
 
-       if (h1s->flags & (H1S_F_PROCESSING_ERROR|H1S_F_TX_BLK))
+       if (h1s->flags & (H1S_F_INTERNAL_ERROR|H1S_F_PROCESSING_ERROR|H1S_F_TX_BLK))
                goto end;
 
        if (!h1_get_buf(h1c, &h1c->obuf)) {
@@ -2970,9 +2970,9 @@ static int h1_process(struct h1c * h1c)
                h1_set_idle_expiration(h1c);
 
          no_parsing:
-               if (h1c->flags & H1C_F_ERROR) {
+               if (h1s->flags & H1S_F_INTERNAL_ERROR) {
                        h1_handle_internal_err(h1c);
-                       h1c->flags &= ~H1C_F_WAIT_NEXT_REQ;
+                       h1c->flags = (h1c->flags & ~H1C_F_WAIT_NEXT_REQ) | H1C_F_ERROR;
                        TRACE_ERROR("internal error detected", H1_EV_H1C_WAKE|H1_EV_H1C_ERR);
                }
                else if (h1s->flags & H1S_F_NOT_IMPL_ERROR) {