mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
CLEANUP: mux-quic: clean up app ops callback definitions
qcc_app_ops is a set of callbacks used to unify application protocol running over QUIC. This commit introduces some changes to clarify its API : * write simple comment to reflect each callback purpose * rename decode_qcs to rcv_buf as this name is more common and is similar to already existing snd_buf * finalize is moved up as it is used during connection init stage All these changes are ported to HTTP/3 layer. Also function comments have been extended to highlight HTTP/3 special characteristics.
This commit is contained in:
parent
f496c7469b
commit
e772d3f40f
@ -185,17 +185,35 @@ enum qcc_app_ops_close_side {
|
|||||||
|
|
||||||
/* QUIC application layer operations */
|
/* QUIC application layer operations */
|
||||||
struct qcc_app_ops {
|
struct qcc_app_ops {
|
||||||
|
/* Initialize <qcc> connection app context. */
|
||||||
int (*init)(struct qcc *qcc);
|
int (*init)(struct qcc *qcc);
|
||||||
|
/* Finish connection initialization if prelude required. */
|
||||||
|
int (*finalize)(void *ctx);
|
||||||
|
|
||||||
|
/* Initialize <qcs> stream app context or leave it to NULL if rejected. */
|
||||||
int (*attach)(struct qcs *qcs, void *conn_ctx);
|
int (*attach)(struct qcs *qcs, void *conn_ctx);
|
||||||
ssize_t (*decode_qcs)(struct qcs *qcs, struct buffer *b, int fin);
|
|
||||||
size_t (*snd_buf)(struct qcs *qcs, struct buffer *buf, size_t count);
|
/* Convert received HTTP payload to HTX. */
|
||||||
|
ssize_t (*rcv_buf)(struct qcs *qcs, struct buffer *b, int fin);
|
||||||
|
|
||||||
|
/* Convert HTX to HTTP payload for sending. */
|
||||||
|
size_t (*snd_buf)(struct qcs *qcs, struct buffer *b, size_t count);
|
||||||
|
|
||||||
|
/* Negotiate and commit fast-forward data from opposite MUX. */
|
||||||
size_t (*nego_ff)(struct qcs *qcs, size_t count);
|
size_t (*nego_ff)(struct qcs *qcs, size_t count);
|
||||||
size_t (*done_ff)(struct qcs *qcs);
|
size_t (*done_ff)(struct qcs *qcs);
|
||||||
|
|
||||||
|
/* Notify about <qcs> stream closure. */
|
||||||
int (*close)(struct qcs *qcs, enum qcc_app_ops_close_side side);
|
int (*close)(struct qcs *qcs, enum qcc_app_ops_close_side side);
|
||||||
|
/* Free <qcs> stream app context. */
|
||||||
void (*detach)(struct qcs *qcs);
|
void (*detach)(struct qcs *qcs);
|
||||||
int (*finalize)(void *ctx);
|
|
||||||
void (*shutdown)(void *ctx); /* Close a connection. */
|
/* Perform graceful shutdown. */
|
||||||
|
void (*shutdown)(void *ctx);
|
||||||
|
/* Free connection app context. */
|
||||||
void (*release)(void *ctx);
|
void (*release)(void *ctx);
|
||||||
|
|
||||||
|
/* Increment app counters on CONNECTION_CLOSE_APP reception. */
|
||||||
void (*inc_err_cnt)(void *ctx, int err_code);
|
void (*inc_err_cnt)(void *ctx, int err_code);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
48
src/h3.c
48
src/h3.c
@ -1205,12 +1205,12 @@ static ssize_t h3_parse_settings_frm(struct h3c *h3c, const struct buffer *buf,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Decode <qcs> remotely initiated bidi-stream. <fin> must be set to indicate
|
/* Transcode HTTP/3 payload received in buffer <b> to HTX data for stream
|
||||||
* that we received the last data of the stream.
|
* <qcs>. If <fin> is set, it indicates that no more data will arrive after.
|
||||||
*
|
*
|
||||||
* Returns 0 on success else non-zero.
|
* Returns 0 on success else non-zero.
|
||||||
*/
|
*/
|
||||||
static ssize_t h3_decode_qcs(struct qcs *qcs, struct buffer *b, int fin)
|
static ssize_t h3_rcv_buf(struct qcs *qcs, struct buffer *b, int fin)
|
||||||
{
|
{
|
||||||
struct h3s *h3s = qcs->ctx;
|
struct h3s *h3s = qcs->ctx;
|
||||||
struct h3c *h3c = h3s->h3c;
|
struct h3c *h3c = h3s->h3c;
|
||||||
@ -2105,25 +2105,6 @@ static void h3_detach(struct qcs *qcs)
|
|||||||
TRACE_LEAVE(H3_EV_H3S_END, qcs->qcc->conn, qcs);
|
TRACE_LEAVE(H3_EV_H3S_END, qcs->qcc->conn, qcs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize H3 control stream and prepare SETTINGS emission.
|
|
||||||
*
|
|
||||||
* Returns 0 on success else non-zero.
|
|
||||||
*/
|
|
||||||
static int h3_finalize(void *ctx)
|
|
||||||
{
|
|
||||||
struct h3c *h3c = ctx;
|
|
||||||
struct qcs *qcs;
|
|
||||||
|
|
||||||
qcs = qcc_init_stream_local(h3c->qcc, 0);
|
|
||||||
if (!qcs)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
h3_control_send(qcs, h3c);
|
|
||||||
h3c->ctrl_strm = qcs;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Generate a GOAWAY frame for <h3c> connection on the control stream.
|
/* Generate a GOAWAY frame for <h3c> connection on the control stream.
|
||||||
*
|
*
|
||||||
* Returns 0 on success else non-zero.
|
* Returns 0 on success else non-zero.
|
||||||
@ -2202,6 +2183,25 @@ static int h3_init(struct qcc *qcc)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Initialize H3 control stream and prepare SETTINGS emission.
|
||||||
|
*
|
||||||
|
* Returns 0 on success else non-zero.
|
||||||
|
*/
|
||||||
|
static int h3_finalize(void *ctx)
|
||||||
|
{
|
||||||
|
struct h3c *h3c = ctx;
|
||||||
|
struct qcs *qcs;
|
||||||
|
|
||||||
|
qcs = qcc_init_stream_local(h3c->qcc, 0);
|
||||||
|
if (!qcs)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
h3_control_send(qcs, h3c);
|
||||||
|
h3c->ctrl_strm = qcs;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Send a HTTP/3 GOAWAY followed by a CONNECTION_CLOSE_APP. */
|
/* Send a HTTP/3 GOAWAY followed by a CONNECTION_CLOSE_APP. */
|
||||||
static void h3_shutdown(void *ctx)
|
static void h3_shutdown(void *ctx)
|
||||||
{
|
{
|
||||||
@ -2289,14 +2289,14 @@ static void h3_trace(enum trace_level level, uint64_t mask,
|
|||||||
/* HTTP/3 application layer operations */
|
/* HTTP/3 application layer operations */
|
||||||
const struct qcc_app_ops h3_ops = {
|
const struct qcc_app_ops h3_ops = {
|
||||||
.init = h3_init,
|
.init = h3_init,
|
||||||
|
.finalize = h3_finalize,
|
||||||
.attach = h3_attach,
|
.attach = h3_attach,
|
||||||
.decode_qcs = h3_decode_qcs,
|
.rcv_buf = h3_rcv_buf,
|
||||||
.snd_buf = h3_snd_buf,
|
.snd_buf = h3_snd_buf,
|
||||||
.nego_ff = h3_nego_ff,
|
.nego_ff = h3_nego_ff,
|
||||||
.done_ff = h3_done_ff,
|
.done_ff = h3_done_ff,
|
||||||
.close = h3_close,
|
.close = h3_close,
|
||||||
.detach = h3_detach,
|
.detach = h3_detach,
|
||||||
.finalize = h3_finalize,
|
|
||||||
.shutdown = h3_shutdown,
|
.shutdown = h3_shutdown,
|
||||||
.inc_err_cnt = h3_stats_inc_err_cnt,
|
.inc_err_cnt = h3_stats_inc_err_cnt,
|
||||||
.release = h3_release,
|
.release = h3_release,
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <haproxy/mux_quic.h>
|
#include <haproxy/mux_quic.h>
|
||||||
#include <haproxy/qmux_http.h>
|
#include <haproxy/qmux_http.h>
|
||||||
|
|
||||||
static ssize_t hq_interop_decode_qcs(struct qcs *qcs, struct buffer *b, int fin)
|
static ssize_t hq_interop_rcv_buf(struct qcs *qcs, struct buffer *b, int fin)
|
||||||
{
|
{
|
||||||
struct htx *htx;
|
struct htx *htx;
|
||||||
struct htx_sl *sl;
|
struct htx_sl *sl;
|
||||||
@ -191,7 +191,7 @@ static int hq_interop_attach(struct qcs *qcs, void *conn_ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const struct qcc_app_ops hq_interop_ops = {
|
const struct qcc_app_ops hq_interop_ops = {
|
||||||
.decode_qcs = hq_interop_decode_qcs,
|
.rcv_buf = hq_interop_rcv_buf,
|
||||||
.snd_buf = hq_interop_snd_buf,
|
.snd_buf = hq_interop_snd_buf,
|
||||||
.nego_ff = hq_interop_nego_ff,
|
.nego_ff = hq_interop_nego_ff,
|
||||||
.done_ff = hq_interop_done_ff,
|
.done_ff = hq_interop_done_ff,
|
||||||
|
@ -874,7 +874,7 @@ static int qcc_decode_qcs(struct qcc *qcc, struct qcs *qcs)
|
|||||||
fin = 1;
|
fin = 1;
|
||||||
|
|
||||||
if (!(qcs->flags & QC_SF_READ_ABORTED)) {
|
if (!(qcs->flags & QC_SF_READ_ABORTED)) {
|
||||||
ret = qcc->app_ops->decode_qcs(qcs, &b, fin);
|
ret = qcc->app_ops->rcv_buf(qcs, &b, fin);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
TRACE_ERROR("decoding error", QMUX_EV_QCS_RECV, qcc->conn, qcs);
|
TRACE_ERROR("decoding error", QMUX_EV_QCS_RECV, qcc->conn, qcs);
|
||||||
goto err;
|
goto err;
|
||||||
|
Loading…
Reference in New Issue
Block a user