]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: htx: Remove the HTX extra field
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 18 Sep 2025 07:33:49 +0000 (09:33 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 8 Oct 2025 09:10:42 +0000 (11:10 +0200)
Thanks for previous changes, it is now possible to remove the <extra> field
from the HTX structure. HTX_FL_ALTERED_PAYLOAD flag is also removed because
it is now unsued.

include/haproxy/htx-t.h
include/haproxy/htx.h
src/applet.c
src/filters.c
src/h1_htx.c
src/mux_fcgi.c
src/mux_h2.c
src/qmux_http.c
src/stream.c

index a33da886e2efddde34a826055d12bb884ec3bafd..eecd0abadc703f1c8dec0057e88008ecd80347d8 100644 (file)
@@ -177,7 +177,7 @@ static forceinline char *hsl_show_flags(char *buf, size_t len, const char *delim
 #define HTX_FL_PARSING_ERROR     0x00000001 /* Set when a parsing error occurred */
 #define HTX_FL_PROCESSING_ERROR  0x00000002 /* Set when a processing error occurred */
 #define HTX_FL_FRAGMENTED        0x00000004 /* Set when the HTX buffer is fragmented */
-#define HTX_FL_ALTERED_PAYLOAD   0x00000008 /* The payload is altered, the extra value must not be trusted */
+/* 0x00000008 unused */
 #define HTX_FL_EOM               0x00000010 /* Set when end-of-message is reached from the HTTP point of view
                                             * (at worst, on the EOM block is missing)
                                             */
@@ -265,7 +265,6 @@ struct htx {
        uint32_t head_addr; /* start address of the free space at the beginning */
        uint32_t end_addr;  /* end address of the free space at the beginning */
 
-       uint64_t extra;  /* known bytes amount remaining to receive */
        uint32_t flags;  /* HTX_FL_* */
 
        /* XXX 4 bytes unused */
index 47893ef1d0a39ec1acd61c504e73ac526b143d2f..aa2aaf5e878b403205bb5de715879afc0bd23c4a 100644 (file)
 #include <haproxy/http-t.h>
 #include <haproxy/htx-t.h>
 
-/* ->extra field value when the payload length is unknown (non-chunked message
- * with no "Content-length" header)
- */
-#define HTX_UNKOWN_PAYLOAD_LENGTH ULLONG_MAX
-
 extern struct htx htx_empty;
 
 struct htx_blk *htx_defrag(struct htx *htx, struct htx_blk *blk, uint32_t info);
@@ -660,7 +655,6 @@ static inline void htx_reset(struct htx *htx)
        htx->tail = htx->head  = htx->first = -1;
        htx->data = 0;
        htx->tail_addr = htx->head_addr = htx->end_addr = 0;
-       htx->extra = 0;
        htx->flags = HTX_FL_NONE;
 }
 
@@ -700,8 +694,6 @@ static inline struct htx *htxbuf(const struct buffer *buf)
                htx->size = buf->size - sizeof(*htx);
                htx_reset(htx);
        }
-       if (htx->flags & HTX_FL_ALTERED_PAYLOAD)
-               htx->extra = 0;
        return htx;
 }
 
@@ -837,10 +829,10 @@ static inline void htx_dump(struct buffer *chunk, const struct htx *htx, int ful
 {
        int32_t pos;
 
-       chunk_appendf(chunk, " htx=%p(size=%u,data=%u,used=%u,wrap=%s,flags=0x%08x,extra=%llu,"
+       chunk_appendf(chunk, " htx=%p(size=%u,data=%u,used=%u,wrap=%s,flags=0x%08x,"
                      "first=%d,head=%d,tail=%d,tail_addr=%d,head_addr=%d,end_addr=%d)",
                      htx, htx->size, htx->data, htx_nbblks(htx), (!htx->head_addr) ? "NO" : "YES",
-                     htx->flags, (unsigned long long)htx->extra, htx->first, htx->head, htx->tail,
+                     htx->flags, htx->first, htx->head, htx->tail,
                      htx->tail_addr, htx->head_addr, htx->end_addr);
 
        if (!full || !htx_nbblks(htx))
index edea102901c8750c098f22ce7084d4684ac1505a..c7d5b4b410845debc4bd1bd96b1c6b9f2c5501e3 100644 (file)
@@ -517,7 +517,6 @@ size_t appctx_htx_rcv_buf(struct appctx *appctx, struct buffer *buf, size_t coun
        if (htx_is_empty(appctx_htx)) {
                buf_htx->flags |= (appctx_htx->flags & HTX_FL_EOM);
        }
-       buf_htx->extra = (appctx_htx->extra ? (appctx_htx->data + appctx_htx->extra) : 0);
        htx_to_buf(buf_htx, buf);
        htx_to_buf(appctx_htx, &appctx->outbuf);
        ret -= appctx_htx->data;
@@ -605,7 +604,6 @@ size_t appctx_htx_snd_buf(struct appctx *appctx, struct buffer *buf, size_t coun
                appctx_htx->flags |= (buf_htx->flags & HTX_FL_EOM);
        }
 
-       appctx_htx->extra = (buf_htx->extra ? (buf_htx->data + buf_htx->extra) : 0);
        htx_to_buf(appctx_htx, &appctx->outbuf);
        htx_to_buf(buf_htx, buf);
        ret -= buf_htx->data;
index d786292d367a75736670b9955b7afedd200257ba..3288e9afb1af23089cf8ce2b83a0408dc6cf3d0a 100644 (file)
@@ -684,7 +684,6 @@ int
 flt_http_payload(struct stream *s, struct http_msg *msg, unsigned int len)
 {
        struct filter *filter;
-       struct htx *htx;
        unsigned long long *strm_off = &FLT_STRM_OFF(s, msg->chn);
        unsigned int out = co_data(msg->chn);
        int ret, data;
@@ -734,10 +733,6 @@ flt_http_payload(struct stream *s, struct http_msg *msg, unsigned int len)
        ret = data;
        *strm_off += ret;
  end:
-       htx = htxbuf(&msg->chn->buf);
-       htx->flags |= HTX_FL_ALTERED_PAYLOAD;
-       if (msg->flags & HTTP_MSGF_XFER_LEN)
-               htx->extra = 0;
        chn_prod(msg->chn)->sedesc->kip = 0;
        DBG_TRACE_LEAVE(STRM_EV_STRM_ANA|STRM_EV_HTTP_ANA|STRM_EV_FLT_ANA, s);
        return ret;
index 4da1896c38ed12d8e19fb9170706bf83152f7871..8c8723dad5a83777aa23c78af529fc962fa636b5 100644 (file)
@@ -226,11 +226,6 @@ static int h1_postparse_req_hdrs(struct h1m *h1m, union h1_sl *h1sl, struct htx
                http_scheme_based_normalize(htx);
        }
 
-       /* If body length cannot be determined, set htx->extra to
-        * HTX_UNKOWN_PAYLOAD_LENGTH. This value is impossible in other cases.
-        */
-       htx->extra = ((h1m->flags & H1_MF_XFER_LEN) ? h1m->curr_len : HTX_UNKOWN_PAYLOAD_LENGTH);
-
   end:
        return 1;
   output_full:
@@ -351,11 +346,6 @@ static int h1_postparse_res_hdrs(struct h1m *h1m, union h1_sl *h1sl, struct htx
                goto error;
        sl->info.res.status = code;
 
-       /* If body length cannot be determined, set htx->extra to
-        * HTX_UNKOWN_PAYLOAD_LENGTH. This value is impossible in other cases.
-        */
-       htx->extra = ((h1m->flags & H1_MF_XFER_LEN) ? h1m->curr_len : HTX_UNKOWN_PAYLOAD_LENGTH);
-
   end:
        return 1;
   output_full:
@@ -611,8 +601,6 @@ static size_t h1_parse_chunk(struct h1m *h1m, struct htx **dsthtx,
                total = 0;
        }
 
-       /* Don't forget to update htx->extra */
-       (*dsthtx)->extra = h1m->curr_len;
        *max = lmax;
        return total;
 }
@@ -765,7 +753,6 @@ static size_t h1_parse_full_contig_chunks(struct h1m *h1m, struct htx **dsthtx,
                        h1m->curr_len = chksz;
                        h1m->body_len += chksz;
                        h1m->state = H1_MSG_DATA;
-                       (*dsthtx)->extra = h1m->curr_len;
                        save = ridx;
                        goto end_parsing;
                }
@@ -885,7 +872,6 @@ size_t h1_parse_msg_data(struct h1m *h1m, struct htx **dsthtx,
                        sz = h1m->curr_len;
                sz = h1_copy_msg_data(dsthtx, srcbuf, ofs, sz, max, htxbuf);
                h1m->curr_len -= sz;
-               (*dsthtx)->extra = h1m->curr_len;
                total += sz;
                if (!h1m->curr_len) {
                        h1m->state = H1_MSG_DONE;
index bbec51f3a7f21f44b77138ca99585b0d6ef003f9..f287f6a7e27cdb2cd72428cc3cee0de1e3c3b860 100644 (file)
@@ -3571,7 +3571,6 @@ static size_t fcgi_strm_parse_response(struct fcgi_strm *fstrm, struct buffer *b
                                        break;
                                sl = htx_get_blk_ptr(htx, blk);
                                sl->flags |= HTX_SL_F_XFER_LEN;
-                               htx->extra = 0;
                        }
                }
                else if (h1m->state < H1_MSG_TRAILERS) {
index f6196db55a7f5e37ba3d156a3c06185a3cc1698e..406a953bdfd6e07e8a0fa9ee422edaeb2fcd3381 100644 (file)
@@ -6146,7 +6146,6 @@ next_frame:
                /* a payload is present */
                if (msgf & H2_MSGF_BODY_CL) {
                        *flags |= H2_SF_DATA_CLEN;
-                       htx->extra = *body_len;
                }
        }
        if (msgf & H2_MSGF_BODYLESS_RSP)
@@ -6327,11 +6326,7 @@ try_again:
        h2c->dfl    -= sent;
        h2c->rcvd_c += sent;
        h2c->rcvd_s += sent;  // warning, this can also affect the closed streams!
-
        h2s->body_len -= sent;
-       if (h2s->flags & H2_SF_DATA_CLEN)
-               htx->extra = h2s->body_len;
-
 
        if (sent < flen) {
                if (h2s_get_rxbuf(h2s))
@@ -7760,7 +7755,6 @@ static size_t h2_rcv_buf(struct stconn *sc, struct buffer *buf, size_t count, in
                buf_htx->flags |= (h2s_htx->flags & HTX_FL_EOM);
        }
 
-       buf_htx->extra = (h2s_htx->extra ? (h2s_htx->data + h2s_htx->extra) : 0);
        htx_to_buf(buf_htx, buf);
        htx_to_buf(h2s_htx, rxbuf);
        ret -= h2s_htx->data;
index 552e16821d4ee0e01b6f74fc8cfccef912758b32..b5494ad2970dfd2a553a48e05cd2acc24eeba55a 100644 (file)
@@ -54,7 +54,6 @@ size_t qcs_http_rcv_buf(struct qcs *qcs, struct buffer *buf, size_t count,
                        *fin = 1;
        }
 
-       cs_htx->extra = qcs_htx->extra ? (qcs_htx->data + qcs_htx->extra) : 0;
        htx_to_buf(cs_htx, buf);
        htx_to_buf(qcs_htx, &qcs->rx.app_buf);
        ret -= qcs_htx->data;
index 852d042e7567c9b2c046ffbb194505a6e35588ca..ccb3ecd4eecaf410418cdd7129e70aae9e460de7 100644 (file)
@@ -3690,10 +3690,9 @@ static void __strm_dump_to_buffer(struct buffer *buf, const struct show_sess_ctx
                struct htx *htx = htxbuf(&strm->req.buf);
 
                chunk_appendf(buf,
-                             "%s      htx=%p flags=0x%x size=%u data=%u used=%u wrap=%s extra=%llu\n", pfx,
+                             "%s      htx=%p flags=0x%x size=%u data=%u used=%u wrap=%s\n", pfx,
                              htx, htx->flags, htx->size, htx->data, htx_nbblks(htx),
-                             (htx->tail >= htx->head) ? "NO" : "YES",
-                             (unsigned long long)htx->extra);
+                             (htx->tail >= htx->head) ? "NO" : "YES");
        }
        if (HAS_FILTERS(strm) && strm->strm_flt.current[0]) {
                const struct filter *flt = strm->strm_flt.current[0];
@@ -3723,10 +3722,9 @@ static void __strm_dump_to_buffer(struct buffer *buf, const struct show_sess_ctx
                struct htx *htx = htxbuf(&strm->res.buf);
 
                chunk_appendf(buf,
-                             "%s      htx=%p flags=0x%x size=%u data=%u used=%u wrap=%s extra=%llu\n", pfx,
+                             "%s      htx=%p flags=0x%x size=%u data=%u used=%u wrap=%s\n", pfx,
                              htx, htx->flags, htx->size, htx->data, htx_nbblks(htx),
-                             (htx->tail >= htx->head) ? "NO" : "YES",
-                             (unsigned long long)htx->extra);
+                             (htx->tail >= htx->head) ? "NO" : "YES");
        }
 
        if (HAS_FILTERS(strm) && strm->strm_flt.current[1]) {