Skip to content

Commit f45a632

Browse files
committed
BUG/MEDIUM: stconn: Disable 0-copy forwarding for filters altering the payload
It is especially a problem with Lua filters, but it is important to disable the 0-copy forwarding if a filter alters the payload, or at least to be able to disable it. While the filter is registered on the data filtering, it is not an issue (and it is the common case) because, there is now way to fast-forward data at all. But it may be an issue if a filter decides to alter the payload and to unregister from data filtering. In that case, the 0-copy forwarding can be re-enabled in a hardly precdictable state. To fix the issue, a SC flags was added to do so. The HTTP compression filter set it and lua filters too if the body length is changed (via HTTPMessage.set_body_len()). Note that it is an issue because of a bad design about the HTX. Many info about the message are stored in the HTX structure itself. It must be refactored to move several info to the stream-endpoint descriptor. This should ease modifications at the stream level, from filter or a TCP/HTTP rules. This should be backported as far as 3.0. If necessary, it may be backported on lower versions, as far as 2.6. In that case, it must be reviewed and adapted.
1 parent 94055a5 commit f45a632

File tree

4 files changed

+4
-0
lines changed

4 files changed

+4
-0
lines changed

include/haproxy/stconn-t.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ enum sc_flags {
206206

207207
SC_FL_EOS = 0x00040000, /* End of stream was reached (from down side to up side) */
208208
SC_FL_HAVE_BUFF = 0x00080000, /* A buffer is ready, flag will be cleared once allocated */
209+
SC_FL_NO_FASTFWD = 0x00100000, /* disable data fast-forwarding */
209210
};
210211

211212
/* This function is used to report flags in debugging tools. Please reflect

src/flt_http_comp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ set_compression_header(struct comp_state *st, struct stream *s, struct http_msg
515515
goto error;
516516
}
517517

518+
chn_prod(msg->chn)->flags |= SC_FL_NO_FASTFWD;
518519
return 1;
519520

520521
error:

src/hlua.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7262,6 +7262,7 @@ __LJMP static int hlua_http_msg_set_body_len(lua_State *L)
72627262
}
72637263

72647264
success:
7265+
chn_prod(msg->chn)->flags |= SC_FL_NO_FASTFWD;
72657266
lua_pushboolean(L, 1);
72667267
return 1;
72677268

src/stconn.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ static inline int sc_cond_forward_shut(struct stconn *sc)
604604
static inline int sc_is_fastfwd_supported(struct stconn *sc)
605605
{
606606
return (!(global.tune.no_zero_copy_fwd & NO_ZERO_COPY_FWD) &&
607+
!(sc->flags & SC_FL_NO_FASTFWD) &&
607608
sc_ep_test(sc, SE_FL_MAY_FASTFWD_PROD) &&
608609
sc_ep_test(sc_opposite(sc), SE_FL_MAY_FASTFWD_CONS) &&
609610
sc_ic(sc)->to_forward);

0 commit comments

Comments
 (0)