]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: applet: Add callback function to deal with zero-copy forwarding
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 23 Jan 2024 06:51:24 +0000 (07:51 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 7 Feb 2024 14:03:57 +0000 (15:03 +0100)
This patch introduces the support for the callback function responsible to
produce data via the zero-copy forwarding mechanism. There is no
implementation for now. But <to_forward> field was added in the appctx
structure to let an applet inform how much data it want to forward. It is
not mandatory but it will be used during the zero-copy forwarding
negociation.

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

index f4e42410895b02e06ef7670ae8baf928abccb4ce..86e08c319554cf9086705f93685b2381a0fbd5de 100644 (file)
@@ -63,7 +63,7 @@ struct applet {
        void (*fct)(struct appctx *);      /* internal I/O handler, may never be NULL */
        size_t (*rcv_buf)(struct stconn *sc, struct buffer *buf, size_t count, unsigned int flags); /* called from the upper layer to get data */
        size_t (*snd_buf)(struct stconn *sc, struct buffer *buf, size_t count, unsigned int flags); /* Called from the upper layet to put data */
-       /* TODO: ADD fastfwd callback functions */
+       size_t (*fastfwd)(struct appctx *appctx, struct buffer *buf, size_t count, unsigned int flags); /* Callback to fast-forward data */
        void (*release)(struct appctx *);  /* callback to release resources, may be NULL */
        unsigned int timeout;              /* execution timeout. */
 };
@@ -78,6 +78,7 @@ struct appctx {
        unsigned int flags;        /* APPCTX_FL_* */
        struct buffer inbuf;
        struct buffer outbuf;
+       size_t to_forward;
 
        struct buffer *chunk;       /* used to store unfinished commands */
        struct applet *applet;     /* applet this context refers to */
index 2d88904f90c928eadf7267fb0a53278fa910bc38..4ddb0da3bfdc922f7fdf7795e79e47cad0e25db6 100644 (file)
@@ -138,9 +138,9 @@ static void applet_trace(enum trace_level level, uint64_t mask, const struct tra
        if (src->verbosity == STRM_VERB_CLEAN)
                return;
 
-       chunk_appendf(&trace_buf, " appctx=%p .t=%p .t.exp=%d .flags=0x%x .st0=%d .st1=%d",
+       chunk_appendf(&trace_buf, " appctx=%p .t=%p .t.exp=%d .flags=0x%x .st0=%d .st1=%d to_fwd=%lu",
                      appctx, appctx->t, tick_isset(appctx->t->expire) ? TICKS_TO_MS(appctx->t->expire - now_ms) : TICK_ETERNITY,
-                     appctx->flags, appctx->st0, appctx->st1);
+                     appctx->flags, appctx->st0, appctx->st1, appctx->to_forward);
 
        if (!sc || src->verbosity == STRM_VERB_MINIMAL)
                return;
@@ -267,6 +267,7 @@ struct appctx *appctx_new_on(struct applet *applet, struct sedesc *sedesc, int t
        appctx->flags = 0;
        appctx->inbuf = BUF_NULL;
        appctx->outbuf = BUF_NULL;
+       appctx->to_forward = 0;
 
        LIST_INIT(&appctx->buffer_wait.list);
        appctx->buffer_wait.target = appctx;