Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1 | #include <haproxy/mux_quic.h> |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 2 | |
Amaury Denoyelle | eb01f59 | 2021-10-07 16:44:05 +0200 | [diff] [blame] | 3 | #include <import/eb64tree.h> |
| 4 | |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 5 | #include <haproxy/api.h> |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 6 | #include <haproxy/connection.h> |
Christopher Faulet | 1329f2a | 2021-12-16 17:32:56 +0100 | [diff] [blame] | 7 | #include <haproxy/conn_stream.h> |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 8 | #include <haproxy/dynbuf.h> |
Amaury Denoyelle | 9a327a7 | 2022-02-14 17:11:09 +0100 | [diff] [blame] | 9 | #include <haproxy/htx.h> |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 10 | #include <haproxy/pool.h> |
Amaury Denoyelle | 0cc02a3 | 2022-04-19 17:21:11 +0200 | [diff] [blame] | 11 | #include <haproxy/quic_stream.h> |
Amaury Denoyelle | 251eadf | 2022-03-24 17:14:52 +0100 | [diff] [blame] | 12 | #include <haproxy/sink.h> |
Amaury Denoyelle | eb01f59 | 2021-10-07 16:44:05 +0200 | [diff] [blame] | 13 | #include <haproxy/ssl_sock-t.h> |
Amaury Denoyelle | dd4fbfb | 2022-03-24 16:09:16 +0100 | [diff] [blame] | 14 | #include <haproxy/trace.h> |
Amaury Denoyelle | 2c71fe5 | 2022-02-09 18:16:49 +0100 | [diff] [blame] | 15 | #include <haproxy/xprt_quic.h> |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 16 | |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 17 | DECLARE_POOL(pool_head_qcc, "qcc", sizeof(struct qcc)); |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 18 | DECLARE_POOL(pool_head_qcs, "qcs", sizeof(struct qcs)); |
| 19 | |
Amaury Denoyelle | dd4fbfb | 2022-03-24 16:09:16 +0100 | [diff] [blame] | 20 | /* trace source and events */ |
| 21 | static void qmux_trace(enum trace_level level, uint64_t mask, |
| 22 | const struct trace_source *src, |
| 23 | const struct ist where, const struct ist func, |
| 24 | const void *a1, const void *a2, const void *a3, const void *a4); |
| 25 | |
| 26 | static const struct trace_event qmux_trace_events[] = { |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 27 | #define QMUX_EV_QCC_RECV (1ULL << 1) |
| 28 | { .mask = QMUX_EV_QCC_RECV, .name = "qcc_recv", .desc = "Rx on QUIC connection" }, |
| 29 | #define QMUX_EV_QCC_SEND (1ULL << 2) |
| 30 | { .mask = QMUX_EV_QCC_SEND, .name = "qcc_send", .desc = "Tx on QUIC connection" }, |
| 31 | #define QMUX_EV_QCC_WAKE (1ULL << 3) |
| 32 | { .mask = QMUX_EV_QCC_WAKE, .name = "qcc_wake", .desc = "QUIC connection woken up" }, |
| 33 | #define QMUX_EV_QCC_END (1ULL << 4) |
| 34 | { .mask = QMUX_EV_QCC_END, .name = "qcc_end", .desc = "QUIC connection terminated" }, |
| 35 | #define QMUX_EV_QCC_NQCS (1ULL << 5) |
| 36 | { .mask = QMUX_EV_QCC_NQCS, .name = "qcc_no_qcs", .desc = "QUIC stream not found" }, |
| 37 | #define QMUX_EV_QCS_NEW (1ULL << 6) |
| 38 | { .mask = QMUX_EV_QCS_NEW, .name = "qcs_new", .desc = "new QUIC stream" }, |
| 39 | #define QMUX_EV_QCS_RECV (1ULL << 7) |
| 40 | { .mask = QMUX_EV_QCS_RECV, .name = "qcs_recv", .desc = "Rx on QUIC stream" }, |
| 41 | #define QMUX_EV_QCS_SEND (1ULL << 8) |
| 42 | { .mask = QMUX_EV_QCS_SEND, .name = "qcs_send", .desc = "Tx on QUIC stream" }, |
| 43 | #define QMUX_EV_QCS_END (1ULL << 9) |
| 44 | { .mask = QMUX_EV_QCS_END, .name = "qcs_end", .desc = "QUIC stream terminated" }, |
| 45 | #define QMUX_EV_STRM_RECV (1ULL << 10) |
| 46 | { .mask = QMUX_EV_STRM_RECV, .name = "strm_recv", .desc = "receiving data for stream" }, |
| 47 | #define QMUX_EV_STRM_SEND (1ULL << 11) |
| 48 | { .mask = QMUX_EV_STRM_SEND, .name = "strm_send", .desc = "sending data for stream" }, |
| 49 | #define QMUX_EV_STRM_END (1ULL << 12) |
| 50 | { .mask = QMUX_EV_STRM_END, .name = "strm_end", .desc = "detaching app-layer stream" }, |
Amaury Denoyelle | fa29f33 | 2022-03-25 09:09:40 +0100 | [diff] [blame] | 51 | #define QMUX_EV_SEND_FRM (1ULL << 13) |
| 52 | { .mask = QMUX_EV_SEND_FRM, .name = "send_frm", .desc = "sending QUIC frame" }, |
Amaury Denoyelle | da6ad20 | 2022-04-12 11:41:04 +0200 | [diff] [blame] | 53 | /* special event dedicated to qcs_xfer_data */ |
| 54 | #define QMUX_EV_QCS_XFER_DATA (1ULL << 14) |
| 55 | { .mask = QMUX_EV_QCS_XFER_DATA, .name = "qcs_xfer_data", .desc = "qcs_xfer_data" }, |
| 56 | /* special event dedicated to qcs_build_stream_frm */ |
| 57 | #define QMUX_EV_QCS_BUILD_STRM (1ULL << 15) |
| 58 | { .mask = QMUX_EV_QCS_BUILD_STRM, .name = "qcs_build_stream_frm", .desc = "qcs_build_stream_frm" }, |
Amaury Denoyelle | dd4fbfb | 2022-03-24 16:09:16 +0100 | [diff] [blame] | 59 | { } |
| 60 | }; |
| 61 | |
Amaury Denoyelle | da6ad20 | 2022-04-12 11:41:04 +0200 | [diff] [blame] | 62 | /* custom arg for QMUX_EV_QCS_XFER_DATA */ |
| 63 | struct qcs_xfer_data_trace_arg { |
| 64 | size_t prep; |
Amaury Denoyelle | fdcec36 | 2022-03-25 09:28:10 +0100 | [diff] [blame] | 65 | int xfer; |
Amaury Denoyelle | da6ad20 | 2022-04-12 11:41:04 +0200 | [diff] [blame] | 66 | }; |
| 67 | /* custom arg for QMUX_EV_QCS_BUILD_STRM */ |
| 68 | struct qcs_build_stream_trace_arg { |
| 69 | size_t len; |
Amaury Denoyelle | fdcec36 | 2022-03-25 09:28:10 +0100 | [diff] [blame] | 70 | char fin; |
| 71 | uint64_t offset; |
| 72 | }; |
| 73 | |
Amaury Denoyelle | dd4fbfb | 2022-03-24 16:09:16 +0100 | [diff] [blame] | 74 | static const struct name_desc qmux_trace_lockon_args[4] = { |
| 75 | /* arg1 */ { /* already used by the connection */ }, |
| 76 | /* arg2 */ { .name="qcs", .desc="QUIC stream" }, |
| 77 | /* arg3 */ { }, |
| 78 | /* arg4 */ { } |
| 79 | }; |
| 80 | |
| 81 | static const struct name_desc qmux_trace_decoding[] = { |
| 82 | #define QMUX_VERB_CLEAN 1 |
| 83 | { .name="clean", .desc="only user-friendly stuff, generally suitable for level \"user\"" }, |
| 84 | #define QMUX_VERB_MINIMAL 2 |
| 85 | { .name="minimal", .desc="report only qcc/qcs state and flags, no real decoding" }, |
| 86 | { /* end */ } |
| 87 | }; |
| 88 | |
| 89 | struct trace_source trace_qmux = { |
| 90 | .name = IST("qmux"), |
| 91 | .desc = "QUIC multiplexer", |
| 92 | .arg_def = TRC_ARG1_CONN, /* TRACE()'s first argument is always a connection */ |
| 93 | .default_cb = qmux_trace, |
| 94 | .known_events = qmux_trace_events, |
| 95 | .lockon_args = qmux_trace_lockon_args, |
| 96 | .decoding = qmux_trace_decoding, |
| 97 | .report_events = ~0, /* report everything by default */ |
| 98 | }; |
| 99 | |
| 100 | #define TRACE_SOURCE &trace_qmux |
| 101 | INITCALL1(STG_REGISTER, trace_register_source, TRACE_SOURCE); |
| 102 | |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 103 | /* Allocate a new QUIC streams with id <id> and type <type>. */ |
| 104 | struct qcs *qcs_new(struct qcc *qcc, uint64_t id, enum qcs_type type) |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 105 | { |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 106 | struct qcs *qcs; |
Amaury Denoyelle | 7272cd7 | 2022-03-29 15:15:54 +0200 | [diff] [blame] | 107 | struct qc_stream_desc *stream; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 108 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 109 | TRACE_ENTER(QMUX_EV_QCS_NEW, qcc->conn); |
| 110 | |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 111 | qcs = pool_alloc(pool_head_qcs); |
| 112 | if (!qcs) |
| 113 | goto out; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 114 | |
Amaury Denoyelle | e4301da | 2022-04-19 17:59:50 +0200 | [diff] [blame^] | 115 | /* allocate transport layer stream descriptor |
| 116 | * |
| 117 | * TODO qc_stream_desc is only useful for Tx buffering. It should not |
| 118 | * be required for unidirectional remote streams. |
| 119 | */ |
| 120 | stream = qc_stream_desc_new(id, qcs, qcc->conn->handle.qc); |
Amaury Denoyelle | 7272cd7 | 2022-03-29 15:15:54 +0200 | [diff] [blame] | 121 | if (!stream) { |
| 122 | pool_free(pool_head_qcs, qcs); |
| 123 | qcs = NULL; |
| 124 | goto out; |
| 125 | } |
| 126 | |
| 127 | qcs->stream = stream; |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 128 | qcs->qcc = qcc; |
| 129 | qcs->cs = NULL; |
| 130 | qcs->flags = QC_SF_NONE; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 131 | |
Christopher Faulet | 9ec2f4d | 2022-03-23 15:15:29 +0100 | [diff] [blame] | 132 | qcs->endp = cs_endpoint_new(); |
| 133 | if (!qcs->endp) { |
| 134 | pool_free(pool_head_qcs, qcs); |
| 135 | return NULL; |
| 136 | } |
| 137 | qcs->endp->target = qcs; |
| 138 | qcs->endp->ctx = qcc->conn; |
| 139 | qcs->endp->flags |= (CS_EP_T_MUX|CS_EP_ORPHAN|CS_EP_NOT_FIRST); |
| 140 | |
Amaury Denoyelle | e4301da | 2022-04-19 17:59:50 +0200 | [diff] [blame^] | 141 | qcs->id = qcs->by_id.key = id; |
Amaury Denoyelle | d8e680c | 2022-03-29 15:18:44 +0200 | [diff] [blame] | 142 | /* store transport layer stream descriptor in qcc tree */ |
Amaury Denoyelle | e4301da | 2022-04-19 17:59:50 +0200 | [diff] [blame^] | 143 | eb64_insert(&qcc->streams_by_id, &qcs->by_id); |
Christopher Faulet | 9ec2f4d | 2022-03-23 15:15:29 +0100 | [diff] [blame] | 144 | |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 145 | qcc->strms[type].nb_streams++; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 146 | |
Amaury Denoyelle | 6ea7819 | 2022-03-07 15:47:02 +0100 | [diff] [blame] | 147 | /* If stream is local, use peer remote-limit, or else the opposite. */ |
| 148 | /* TODO use uni limit for unidirectional streams */ |
| 149 | qcs->tx.msd = quic_stream_is_local(qcc, id) ? qcc->rfctl.msd_bidi_r : |
| 150 | qcc->rfctl.msd_bidi_l; |
| 151 | |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 152 | qcs->rx.buf = BUF_NULL; |
Amaury Denoyelle | 9a327a7 | 2022-02-14 17:11:09 +0100 | [diff] [blame] | 153 | qcs->rx.app_buf = BUF_NULL; |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 154 | qcs->rx.offset = 0; |
| 155 | qcs->rx.frms = EB_ROOT_UNIQUE; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 156 | |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 157 | qcs->tx.buf = BUF_NULL; |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 158 | qcs->tx.offset = 0; |
Amaury Denoyelle | 6ccfa3c | 2022-03-10 16:45:53 +0100 | [diff] [blame] | 159 | qcs->tx.sent_offset = 0; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 160 | |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 161 | qcs->wait_event.tasklet = NULL; |
| 162 | qcs->wait_event.events = 0; |
| 163 | qcs->subs = NULL; |
| 164 | |
| 165 | out: |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 166 | TRACE_LEAVE(QMUX_EV_QCS_NEW, qcc->conn, qcs); |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 167 | return qcs; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 168 | } |
| 169 | |
Amaury Denoyelle | dccbd73 | 2022-03-29 18:36:59 +0200 | [diff] [blame] | 170 | /* Free a qcs. This function must only be done to remove a stream on allocation |
| 171 | * error or connection shutdown. Else use qcs_destroy which handle all the |
| 172 | * QUIC connection mechanism. |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 173 | */ |
Amaury Denoyelle | dccbd73 | 2022-03-29 18:36:59 +0200 | [diff] [blame] | 174 | void qcs_free(struct qcs *qcs) |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 175 | { |
Amaury Denoyelle | dccbd73 | 2022-03-29 18:36:59 +0200 | [diff] [blame] | 176 | b_free(&qcs->rx.buf); |
| 177 | b_free(&qcs->tx.buf); |
Amaury Denoyelle | dccbd73 | 2022-03-29 18:36:59 +0200 | [diff] [blame] | 178 | |
Amaury Denoyelle | d8e680c | 2022-03-29 15:18:44 +0200 | [diff] [blame] | 179 | BUG_ON(!qcs->qcc->strms[qcs_id_type(qcs->id)].nb_streams); |
| 180 | --qcs->qcc->strms[qcs_id_type(qcs->id)].nb_streams; |
Amaury Denoyelle | dccbd73 | 2022-03-29 18:36:59 +0200 | [diff] [blame] | 181 | |
Amaury Denoyelle | e4301da | 2022-04-19 17:59:50 +0200 | [diff] [blame^] | 182 | qc_stream_desc_release(qcs->stream); |
| 183 | |
Christopher Faulet | 9ec2f4d | 2022-03-23 15:15:29 +0100 | [diff] [blame] | 184 | BUG_ON(qcs->endp && !(qcs->endp->flags & CS_EP_ORPHAN)); |
| 185 | cs_endpoint_free(qcs->endp); |
Amaury Denoyelle | e4301da | 2022-04-19 17:59:50 +0200 | [diff] [blame^] | 186 | |
| 187 | eb64_delete(&qcs->by_id); |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 188 | pool_free(pool_head_qcs, qcs); |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 189 | } |
| 190 | |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 191 | struct buffer *qc_get_buf(struct qcs *qcs, struct buffer *bptr) |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 192 | { |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 193 | struct buffer *buf = b_alloc(bptr); |
| 194 | BUG_ON(!buf); |
| 195 | return buf; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 196 | } |
| 197 | |
Amaury Denoyelle | a3f222d | 2021-12-06 11:24:00 +0100 | [diff] [blame] | 198 | int qcs_subscribe(struct qcs *qcs, int event_type, struct wait_event *es) |
| 199 | { |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 200 | struct qcc *qcc = qcs->qcc; |
| 201 | |
| 202 | TRACE_ENTER(QMUX_EV_STRM_SEND|QMUX_EV_STRM_RECV, qcc->conn, qcs); |
Amaury Denoyelle | a3f222d | 2021-12-06 11:24:00 +0100 | [diff] [blame] | 203 | |
| 204 | BUG_ON(event_type & ~(SUB_RETRY_SEND|SUB_RETRY_RECV)); |
| 205 | BUG_ON(qcs->subs && qcs->subs != es); |
| 206 | |
| 207 | es->events |= event_type; |
| 208 | qcs->subs = es; |
| 209 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 210 | if (event_type & SUB_RETRY_RECV) |
| 211 | TRACE_DEVEL("subscribe(recv)", QMUX_EV_STRM_RECV, qcc->conn, qcs); |
| 212 | |
| 213 | if (event_type & SUB_RETRY_SEND) |
| 214 | TRACE_DEVEL("subscribe(send)", QMUX_EV_STRM_SEND, qcc->conn, qcs); |
| 215 | |
| 216 | TRACE_LEAVE(QMUX_EV_STRM_SEND|QMUX_EV_STRM_RECV, qcc->conn, qcs); |
| 217 | |
Amaury Denoyelle | a3f222d | 2021-12-06 11:24:00 +0100 | [diff] [blame] | 218 | return 0; |
| 219 | } |
| 220 | |
| 221 | void qcs_notify_recv(struct qcs *qcs) |
| 222 | { |
| 223 | if (qcs->subs && qcs->subs->events & SUB_RETRY_RECV) { |
| 224 | tasklet_wakeup(qcs->subs->tasklet); |
| 225 | qcs->subs->events &= ~SUB_RETRY_RECV; |
| 226 | if (!qcs->subs->events) |
| 227 | qcs->subs = NULL; |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | void qcs_notify_send(struct qcs *qcs) |
| 232 | { |
| 233 | if (qcs->subs && qcs->subs->events & SUB_RETRY_SEND) { |
| 234 | tasklet_wakeup(qcs->subs->tasklet); |
| 235 | qcs->subs->events &= ~SUB_RETRY_SEND; |
| 236 | if (!qcs->subs->events) |
| 237 | qcs->subs = NULL; |
| 238 | } |
| 239 | } |
| 240 | |
Amaury Denoyelle | 8a5b27a | 2021-12-21 11:53:10 +0100 | [diff] [blame] | 241 | /* Retrieve as an ebtree node the stream with <id> as ID, possibly allocates |
| 242 | * several streams, depending on the already open ones. |
| 243 | * Return this node if succeeded, NULL if not. |
| 244 | */ |
Amaury Denoyelle | 5074229 | 2022-03-29 14:57:19 +0200 | [diff] [blame] | 245 | struct qcs *qcc_get_qcs(struct qcc *qcc, uint64_t id) |
Amaury Denoyelle | 8a5b27a | 2021-12-21 11:53:10 +0100 | [diff] [blame] | 246 | { |
| 247 | unsigned int strm_type; |
| 248 | int64_t sub_id; |
Amaury Denoyelle | e4301da | 2022-04-19 17:59:50 +0200 | [diff] [blame^] | 249 | struct eb64_node *node; |
Amaury Denoyelle | 5074229 | 2022-03-29 14:57:19 +0200 | [diff] [blame] | 250 | struct qcs *qcs = NULL; |
Amaury Denoyelle | 8a5b27a | 2021-12-21 11:53:10 +0100 | [diff] [blame] | 251 | |
| 252 | strm_type = id & QCS_ID_TYPE_MASK; |
| 253 | sub_id = id >> QCS_ID_TYPE_SHIFT; |
Amaury Denoyelle | e4301da | 2022-04-19 17:59:50 +0200 | [diff] [blame^] | 254 | node = NULL; |
Amaury Denoyelle | 0dc40f0 | 2022-02-07 11:44:17 +0100 | [diff] [blame] | 255 | if (quic_stream_is_local(qcc, id)) { |
Amaury Denoyelle | 8a5b27a | 2021-12-21 11:53:10 +0100 | [diff] [blame] | 256 | /* Local streams: this stream must be already opened. */ |
Amaury Denoyelle | e4301da | 2022-04-19 17:59:50 +0200 | [diff] [blame^] | 257 | node = eb64_lookup(&qcc->streams_by_id, id); |
| 258 | if (!node) { |
Amaury Denoyelle | 8a5b27a | 2021-12-21 11:53:10 +0100 | [diff] [blame] | 259 | /* unknown stream id */ |
| 260 | goto out; |
| 261 | } |
Amaury Denoyelle | e4301da | 2022-04-19 17:59:50 +0200 | [diff] [blame^] | 262 | qcs = eb64_entry(node, struct qcs, by_id); |
Amaury Denoyelle | 8a5b27a | 2021-12-21 11:53:10 +0100 | [diff] [blame] | 263 | } |
| 264 | else { |
| 265 | /* Remote streams. */ |
| 266 | struct eb_root *strms; |
| 267 | uint64_t largest_id; |
| 268 | enum qcs_type qcs_type; |
| 269 | |
| 270 | strms = &qcc->streams_by_id; |
| 271 | qcs_type = qcs_id_type(id); |
Amaury Denoyelle | c055e30 | 2022-02-07 16:09:06 +0100 | [diff] [blame] | 272 | |
| 273 | /* TODO also checks max-streams for uni streams */ |
| 274 | if (quic_stream_is_bidi(id)) { |
Amaury Denoyelle | 78396e5 | 2022-03-21 17:13:32 +0100 | [diff] [blame] | 275 | if (sub_id + 1 > qcc->lfctl.ms_bidi) { |
Amaury Denoyelle | c055e30 | 2022-02-07 16:09:06 +0100 | [diff] [blame] | 276 | /* streams limit reached */ |
| 277 | goto out; |
| 278 | } |
Amaury Denoyelle | 8a5b27a | 2021-12-21 11:53:10 +0100 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | /* Note: ->largest_id was initialized with (uint64_t)-1 as value, 0 being a |
| 282 | * correct value. |
| 283 | */ |
| 284 | largest_id = qcc->strms[qcs_type].largest_id; |
| 285 | if (sub_id > (int64_t)largest_id) { |
| 286 | /* RFC: "A stream ID that is used out of order results in all streams |
| 287 | * of that type with lower-numbered stream IDs also being opened". |
| 288 | * So, let's "open" these streams. |
| 289 | */ |
| 290 | int64_t i; |
Amaury Denoyelle | 5074229 | 2022-03-29 14:57:19 +0200 | [diff] [blame] | 291 | struct qcs *tmp_qcs; |
Amaury Denoyelle | 8a5b27a | 2021-12-21 11:53:10 +0100 | [diff] [blame] | 292 | |
Amaury Denoyelle | 5074229 | 2022-03-29 14:57:19 +0200 | [diff] [blame] | 293 | tmp_qcs = NULL; |
Amaury Denoyelle | 8a5b27a | 2021-12-21 11:53:10 +0100 | [diff] [blame] | 294 | for (i = largest_id + 1; i <= sub_id; i++) { |
| 295 | uint64_t id = (i << QCS_ID_TYPE_SHIFT) | strm_type; |
| 296 | enum qcs_type type = id & QCS_ID_DIR_BIT ? QCS_CLT_UNI : QCS_CLT_BIDI; |
Amaury Denoyelle | 7272cd7 | 2022-03-29 15:15:54 +0200 | [diff] [blame] | 297 | |
Amaury Denoyelle | 5074229 | 2022-03-29 14:57:19 +0200 | [diff] [blame] | 298 | tmp_qcs = qcs_new(qcc, id, type); |
| 299 | if (!tmp_qcs) { |
Amaury Denoyelle | 8a5b27a | 2021-12-21 11:53:10 +0100 | [diff] [blame] | 300 | /* allocation failure */ |
| 301 | goto out; |
| 302 | } |
| 303 | |
| 304 | qcc->strms[qcs_type].largest_id = i; |
| 305 | } |
Amaury Denoyelle | 5074229 | 2022-03-29 14:57:19 +0200 | [diff] [blame] | 306 | if (tmp_qcs) |
| 307 | qcs = tmp_qcs; |
Amaury Denoyelle | 8a5b27a | 2021-12-21 11:53:10 +0100 | [diff] [blame] | 308 | } |
| 309 | else { |
Amaury Denoyelle | e4301da | 2022-04-19 17:59:50 +0200 | [diff] [blame^] | 310 | node = eb64_lookup(strms, id); |
| 311 | if (node) |
| 312 | qcs = eb64_entry(node, struct qcs, by_id); |
Amaury Denoyelle | 8a5b27a | 2021-12-21 11:53:10 +0100 | [diff] [blame] | 313 | } |
| 314 | } |
| 315 | |
Amaury Denoyelle | 5074229 | 2022-03-29 14:57:19 +0200 | [diff] [blame] | 316 | return qcs; |
Amaury Denoyelle | 8a5b27a | 2021-12-21 11:53:10 +0100 | [diff] [blame] | 317 | |
| 318 | out: |
| 319 | return NULL; |
| 320 | } |
| 321 | |
Amaury Denoyelle | 0e3010b | 2022-02-28 11:37:48 +0100 | [diff] [blame] | 322 | /* Handle a new STREAM frame <strm_frm>. The frame content will be copied in |
| 323 | * the buffer of the stream instance. The stream instance will be stored in |
| 324 | * <out_qcs>. In case of success, the caller can immediatly call qcc_decode_qcs |
| 325 | * to process the frame content. |
| 326 | * |
| 327 | * Returns 0 on success. On errors, two codes are present. |
| 328 | * - 1 is returned if the frame cannot be decoded and must be discarded. |
| 329 | * - 2 is returned if the stream cannot decode at the moment the frame. The |
| 330 | * frame should be buffered to be handled later. |
| 331 | */ |
| 332 | int qcc_recv(struct qcc *qcc, uint64_t id, uint64_t len, uint64_t offset, |
| 333 | char fin, char *data, struct qcs **out_qcs) |
| 334 | { |
| 335 | struct qcs *qcs; |
Amaury Denoyelle | 0e3010b | 2022-02-28 11:37:48 +0100 | [diff] [blame] | 336 | size_t total, diff; |
| 337 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 338 | TRACE_ENTER(QMUX_EV_QCC_RECV, qcc->conn); |
| 339 | |
Amaury Denoyelle | 5074229 | 2022-03-29 14:57:19 +0200 | [diff] [blame] | 340 | qcs = qcc_get_qcs(qcc, id); |
| 341 | if (!qcs) { |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 342 | TRACE_DEVEL("leaving on stream not found", QMUX_EV_QCC_RECV|QMUX_EV_QCC_NQCS, qcc->conn, NULL, &id); |
Amaury Denoyelle | 0e3010b | 2022-02-28 11:37:48 +0100 | [diff] [blame] | 343 | return 1; |
| 344 | } |
| 345 | |
Amaury Denoyelle | 0e3010b | 2022-02-28 11:37:48 +0100 | [diff] [blame] | 346 | *out_qcs = qcs; |
| 347 | |
| 348 | if (offset > qcs->rx.offset) |
| 349 | return 2; |
| 350 | |
| 351 | if (offset + len <= qcs->rx.offset) { |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 352 | TRACE_DEVEL("leaving on already received offset", QMUX_EV_QCC_RECV|QMUX_EV_QCS_RECV, qcc->conn, qcs); |
Amaury Denoyelle | 0e3010b | 2022-02-28 11:37:48 +0100 | [diff] [blame] | 353 | return 1; |
| 354 | } |
| 355 | |
| 356 | /* Last frame already handled for this stream. */ |
| 357 | BUG_ON(qcs->flags & QC_SF_FIN_RECV); |
| 358 | |
| 359 | if (!qc_get_buf(qcs, &qcs->rx.buf)) { |
| 360 | /* TODO should mark qcs as full */ |
| 361 | return 2; |
| 362 | } |
| 363 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 364 | TRACE_DEVEL("newly received offset", QMUX_EV_QCC_RECV|QMUX_EV_QCS_RECV, qcc->conn, qcs); |
Amaury Denoyelle | 0e3010b | 2022-02-28 11:37:48 +0100 | [diff] [blame] | 365 | diff = qcs->rx.offset - offset; |
| 366 | |
| 367 | /* TODO do not partially copy a frame if not enough size left. Maybe |
| 368 | * this can be optimized. |
| 369 | */ |
| 370 | if (len > b_room(&qcs->rx.buf)) { |
| 371 | /* TODO handle STREAM frames larger than RX buffer. */ |
| 372 | BUG_ON(len > b_size(&qcs->rx.buf)); |
| 373 | return 2; |
| 374 | } |
| 375 | |
| 376 | len -= diff; |
| 377 | data += diff; |
| 378 | |
| 379 | total = b_putblk(&qcs->rx.buf, data, len); |
| 380 | /* TODO handle partial copy of a STREAM frame. */ |
| 381 | BUG_ON(len != total); |
| 382 | |
| 383 | qcs->rx.offset += total; |
| 384 | |
| 385 | if (fin) |
| 386 | qcs->flags |= QC_SF_FIN_RECV; |
| 387 | |
| 388 | out: |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 389 | TRACE_LEAVE(QMUX_EV_QCC_RECV, qcc->conn); |
Amaury Denoyelle | 0e3010b | 2022-02-28 11:37:48 +0100 | [diff] [blame] | 390 | return 0; |
| 391 | } |
| 392 | |
Amaury Denoyelle | 1e5e513 | 2022-03-08 16:23:03 +0100 | [diff] [blame] | 393 | /* Handle a new MAX_DATA frame. <max> must contains the maximum data field of |
| 394 | * the frame. |
| 395 | * |
| 396 | * Returns 0 on success else non-zero. |
| 397 | */ |
| 398 | int qcc_recv_max_data(struct qcc *qcc, uint64_t max) |
| 399 | { |
| 400 | if (qcc->rfctl.md < max) { |
| 401 | qcc->rfctl.md = max; |
| 402 | |
| 403 | if (qcc->flags & QC_CF_BLK_MFCTL) { |
| 404 | qcc->flags &= ~QC_CF_BLK_MFCTL; |
| 405 | tasklet_wakeup(qcc->wait_event.tasklet); |
| 406 | } |
| 407 | } |
| 408 | return 0; |
| 409 | } |
| 410 | |
Amaury Denoyelle | 8727ff4 | 2022-03-08 10:39:55 +0100 | [diff] [blame] | 411 | /* Handle a new MAX_STREAM_DATA frame. <max> must contains the maximum data |
| 412 | * field of the frame and <id> is the identifier of the QUIC stream. |
| 413 | * |
| 414 | * Returns 0 on success else non-zero. |
| 415 | */ |
| 416 | int qcc_recv_max_stream_data(struct qcc *qcc, uint64_t id, uint64_t max) |
| 417 | { |
| 418 | struct qcs *qcs; |
| 419 | struct eb64_node *node; |
| 420 | |
| 421 | node = eb64_lookup(&qcc->streams_by_id, id); |
| 422 | if (node) { |
Amaury Denoyelle | e4301da | 2022-04-19 17:59:50 +0200 | [diff] [blame^] | 423 | qcs = eb64_entry(node, struct qcs, by_id); |
Amaury Denoyelle | 8727ff4 | 2022-03-08 10:39:55 +0100 | [diff] [blame] | 424 | if (max > qcs->tx.msd) { |
| 425 | qcs->tx.msd = max; |
| 426 | |
| 427 | if (qcs->flags & QC_SF_BLK_SFCTL) { |
| 428 | qcs->flags &= ~QC_SF_BLK_SFCTL; |
| 429 | tasklet_wakeup(qcc->wait_event.tasklet); |
| 430 | } |
| 431 | } |
| 432 | } |
| 433 | |
| 434 | return 0; |
| 435 | } |
| 436 | |
Amaury Denoyelle | 0e3010b | 2022-02-28 11:37:48 +0100 | [diff] [blame] | 437 | /* Decode the content of STREAM frames already received on the stream instance |
| 438 | * <qcs>. |
| 439 | * |
| 440 | * Returns 0 on success else non-zero. |
| 441 | */ |
| 442 | int qcc_decode_qcs(struct qcc *qcc, struct qcs *qcs) |
| 443 | { |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 444 | TRACE_ENTER(QMUX_EV_QCS_RECV, qcc->conn, qcs); |
| 445 | |
Amaury Denoyelle | 0e3010b | 2022-02-28 11:37:48 +0100 | [diff] [blame] | 446 | if (qcc->app_ops->decode_qcs(qcs, qcs->flags & QC_SF_FIN_RECV, qcc->ctx) < 0) { |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 447 | TRACE_DEVEL("leaving on decoding error", QMUX_EV_QCS_RECV, qcc->conn, qcs); |
Amaury Denoyelle | 0e3010b | 2022-02-28 11:37:48 +0100 | [diff] [blame] | 448 | return 1; |
| 449 | } |
| 450 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 451 | TRACE_LEAVE(QMUX_EV_QCS_RECV, qcc->conn, qcs); |
| 452 | |
Amaury Denoyelle | 0e3010b | 2022-02-28 11:37:48 +0100 | [diff] [blame] | 453 | return 0; |
| 454 | } |
| 455 | |
Amaury Denoyelle | c055e30 | 2022-02-07 16:09:06 +0100 | [diff] [blame] | 456 | static int qc_is_max_streams_needed(struct qcc *qcc) |
| 457 | { |
Amaury Denoyelle | 78396e5 | 2022-03-21 17:13:32 +0100 | [diff] [blame] | 458 | return qcc->lfctl.cl_bidi_r > qcc->lfctl.ms_bidi_init / 2; |
Amaury Denoyelle | c055e30 | 2022-02-07 16:09:06 +0100 | [diff] [blame] | 459 | } |
| 460 | |
Ilya Shipitsin | 5e87bcf | 2021-12-25 11:45:52 +0500 | [diff] [blame] | 461 | /* detaches the QUIC stream from its QCC and releases it to the QCS pool. */ |
Amaury Denoyelle | 2873a31 | 2021-12-08 14:42:55 +0100 | [diff] [blame] | 462 | static void qcs_destroy(struct qcs *qcs) |
| 463 | { |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 464 | struct connection *conn = qcs->qcc->conn; |
Amaury Denoyelle | d8e680c | 2022-03-29 15:18:44 +0200 | [diff] [blame] | 465 | const uint64_t id = qcs->id; |
Amaury Denoyelle | c055e30 | 2022-02-07 16:09:06 +0100 | [diff] [blame] | 466 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 467 | TRACE_ENTER(QMUX_EV_QCS_END, conn, qcs); |
Amaury Denoyelle | 2873a31 | 2021-12-08 14:42:55 +0100 | [diff] [blame] | 468 | |
Amaury Denoyelle | c055e30 | 2022-02-07 16:09:06 +0100 | [diff] [blame] | 469 | if (quic_stream_is_remote(qcs->qcc, id)) { |
| 470 | if (quic_stream_is_bidi(id)) { |
Amaury Denoyelle | 78396e5 | 2022-03-21 17:13:32 +0100 | [diff] [blame] | 471 | ++qcs->qcc->lfctl.cl_bidi_r; |
Amaury Denoyelle | c055e30 | 2022-02-07 16:09:06 +0100 | [diff] [blame] | 472 | if (qc_is_max_streams_needed(qcs->qcc)) |
| 473 | tasklet_wakeup(qcs->qcc->wait_event.tasklet); |
| 474 | } |
| 475 | } |
| 476 | |
Amaury Denoyelle | dccbd73 | 2022-03-29 18:36:59 +0200 | [diff] [blame] | 477 | qcs_free(qcs); |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 478 | |
| 479 | TRACE_LEAVE(QMUX_EV_QCS_END, conn); |
Amaury Denoyelle | 2873a31 | 2021-12-08 14:42:55 +0100 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | static inline int qcc_is_dead(const struct qcc *qcc) |
| 483 | { |
Amaury Denoyelle | 198d35f | 2022-04-01 17:56:58 +0200 | [diff] [blame] | 484 | if (qcc->app_ops && qcc->app_ops->is_active && |
| 485 | qcc->app_ops->is_active(qcc, qcc->ctx)) |
| 486 | return 0; |
| 487 | |
Amaury Denoyelle | d97fc80 | 2022-04-06 16:13:09 +0200 | [diff] [blame] | 488 | if ((qcc->conn->flags & CO_FL_ERROR) || !qcc->task) |
Amaury Denoyelle | aebe26f | 2022-01-13 16:28:06 +0100 | [diff] [blame] | 489 | return 1; |
| 490 | |
| 491 | return 0; |
| 492 | } |
| 493 | |
| 494 | /* Return true if the mux timeout should be armed. */ |
| 495 | static inline int qcc_may_expire(struct qcc *qcc) |
| 496 | { |
Amaury Denoyelle | 06890aa | 2022-04-04 16:15:06 +0200 | [diff] [blame] | 497 | return !qcc->nb_cs; |
Amaury Denoyelle | 2873a31 | 2021-12-08 14:42:55 +0100 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | /* release function. This one should be called to free all resources allocated |
| 501 | * to the mux. |
| 502 | */ |
| 503 | static void qc_release(struct qcc *qcc) |
| 504 | { |
Christopher Faulet | 4de1bff | 2022-04-14 11:36:41 +0200 | [diff] [blame] | 505 | struct connection *conn = qcc->conn; |
| 506 | struct eb64_node *node; |
Amaury Denoyelle | 2873a31 | 2021-12-08 14:42:55 +0100 | [diff] [blame] | 507 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 508 | TRACE_ENTER(QMUX_EV_QCC_END); |
| 509 | |
Christopher Faulet | 4de1bff | 2022-04-14 11:36:41 +0200 | [diff] [blame] | 510 | if (qcc->app_ops && qcc->app_ops->release) |
| 511 | qcc->app_ops->release(qcc->ctx); |
Amaury Denoyelle | f890945 | 2022-03-30 11:51:56 +0200 | [diff] [blame] | 512 | |
Christopher Faulet | 4de1bff | 2022-04-14 11:36:41 +0200 | [diff] [blame] | 513 | if (qcc->task) { |
| 514 | task_destroy(qcc->task); |
| 515 | qcc->task = NULL; |
| 516 | } |
Amaury Denoyelle | 2873a31 | 2021-12-08 14:42:55 +0100 | [diff] [blame] | 517 | |
Christopher Faulet | 4de1bff | 2022-04-14 11:36:41 +0200 | [diff] [blame] | 518 | if (qcc->wait_event.tasklet) |
| 519 | tasklet_free(qcc->wait_event.tasklet); |
Amaury Denoyelle | f890945 | 2022-03-30 11:51:56 +0200 | [diff] [blame] | 520 | |
Christopher Faulet | 4de1bff | 2022-04-14 11:36:41 +0200 | [diff] [blame] | 521 | /* liberate remaining qcs instances */ |
| 522 | node = eb64_first(&qcc->streams_by_id); |
| 523 | while (node) { |
Amaury Denoyelle | e4301da | 2022-04-19 17:59:50 +0200 | [diff] [blame^] | 524 | struct qcs *qcs = eb64_entry(node, struct qcs, by_id); |
Christopher Faulet | 4de1bff | 2022-04-14 11:36:41 +0200 | [diff] [blame] | 525 | node = eb64_next(node); |
Amaury Denoyelle | e4301da | 2022-04-19 17:59:50 +0200 | [diff] [blame^] | 526 | qcs_free(qcs); |
Amaury Denoyelle | 2873a31 | 2021-12-08 14:42:55 +0100 | [diff] [blame] | 527 | } |
| 528 | |
Christopher Faulet | 4de1bff | 2022-04-14 11:36:41 +0200 | [diff] [blame] | 529 | pool_free(pool_head_qcc, qcc); |
| 530 | |
Amaury Denoyelle | 2873a31 | 2021-12-08 14:42:55 +0100 | [diff] [blame] | 531 | if (conn) { |
Amaury Denoyelle | 0e0969d | 2022-01-31 15:41:14 +0100 | [diff] [blame] | 532 | LIST_DEL_INIT(&conn->stopping_list); |
| 533 | |
Willy Tarreau | 784b868 | 2022-04-11 14:18:10 +0200 | [diff] [blame] | 534 | conn->handle.qc->conn = NULL; |
Amaury Denoyelle | 2873a31 | 2021-12-08 14:42:55 +0100 | [diff] [blame] | 535 | conn->mux = NULL; |
| 536 | conn->ctx = NULL; |
| 537 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 538 | TRACE_DEVEL("freeing conn", QMUX_EV_QCC_END, conn); |
| 539 | |
Amaury Denoyelle | 2873a31 | 2021-12-08 14:42:55 +0100 | [diff] [blame] | 540 | conn_stop_tracking(conn); |
| 541 | conn_full_close(conn); |
| 542 | if (conn->destroy_cb) |
| 543 | conn->destroy_cb(conn); |
| 544 | conn_free(conn); |
| 545 | } |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 546 | |
| 547 | TRACE_LEAVE(QMUX_EV_QCC_END); |
Amaury Denoyelle | 2873a31 | 2021-12-08 14:42:55 +0100 | [diff] [blame] | 548 | } |
| 549 | |
Amaury Denoyelle | 75d14ad | 2022-03-22 15:10:29 +0100 | [diff] [blame] | 550 | /* Prepare a STREAM frame for <qcs> instance. First, transfer data from |
| 551 | * <payload> to <out> buffer. The STREAM frame payload points to the <out> |
| 552 | * buffer. The frame is then pushed to <frm_list>. If <fin> is set, and the |
| 553 | * <payload> buf is emptied after transfer, FIN bit is set on the STREAM frame. |
Amaury Denoyelle | 6ea7819 | 2022-03-07 15:47:02 +0100 | [diff] [blame] | 554 | * Transfer is automatically adjusted to not exceed the stream flow-control |
Amaury Denoyelle | 05ce55e | 2022-03-08 10:35:42 +0100 | [diff] [blame] | 555 | * limit. <max_data> must contains the current sum offsets for the connection. |
| 556 | * This is useful to not exceed the connection flow-control limit when using |
| 557 | * repeatdly this function on multiple streams before passing the data to the |
| 558 | * lower layer. |
Amaury Denoyelle | 75d14ad | 2022-03-22 15:10:29 +0100 | [diff] [blame] | 559 | * |
| 560 | * Returns the total bytes of newly transferred data or a negative error code. |
| 561 | */ |
Amaury Denoyelle | da6ad20 | 2022-04-12 11:41:04 +0200 | [diff] [blame] | 562 | static int qcs_xfer_data(struct qcs *qcs, struct buffer *out, |
| 563 | struct buffer *payload, uint64_t max_data) |
Frédéric Lécaille | 578a789 | 2021-09-13 16:13:00 +0200 | [diff] [blame] | 564 | { |
Amaury Denoyelle | 05ce55e | 2022-03-08 10:35:42 +0100 | [diff] [blame] | 565 | struct qcc *qcc = qcs->qcc; |
Amaury Denoyelle | da6ad20 | 2022-04-12 11:41:04 +0200 | [diff] [blame] | 566 | int left, to_xfer; |
Amaury Denoyelle | 6ccfa3c | 2022-03-10 16:45:53 +0100 | [diff] [blame] | 567 | int total = 0; |
Frédéric Lécaille | 578a789 | 2021-09-13 16:13:00 +0200 | [diff] [blame] | 568 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 569 | TRACE_ENTER(QMUX_EV_QCS_SEND, qcc->conn, qcs); |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 570 | |
Amaury Denoyelle | 6ccfa3c | 2022-03-10 16:45:53 +0100 | [diff] [blame] | 571 | qc_get_buf(qcs, out); |
| 572 | |
| 573 | /* |
| 574 | * QCS out buffer diagram |
| 575 | * head left to_xfer |
| 576 | * -------------> ----------> -----> |
Amaury Denoyelle | e0320b8 | 2022-03-11 19:12:23 +0100 | [diff] [blame] | 577 | * -------------------------------------------------- |
Amaury Denoyelle | 6ccfa3c | 2022-03-10 16:45:53 +0100 | [diff] [blame] | 578 | * |...............|xxxxxxxxxxx|<<<<< |
Amaury Denoyelle | e0320b8 | 2022-03-11 19:12:23 +0100 | [diff] [blame] | 579 | * -------------------------------------------------- |
Amaury Denoyelle | 6ccfa3c | 2022-03-10 16:45:53 +0100 | [diff] [blame] | 580 | * ^ ack-off ^ sent-off ^ off |
| 581 | * |
| 582 | * STREAM frame |
| 583 | * ^ ^ |
| 584 | * |xxxxxxxxxxxxxxxxx| |
| 585 | */ |
| 586 | |
Amaury Denoyelle | 7272cd7 | 2022-03-29 15:15:54 +0200 | [diff] [blame] | 587 | BUG_ON_HOT(qcs->tx.sent_offset < qcs->stream->ack_offset); |
Amaury Denoyelle | 6ccfa3c | 2022-03-10 16:45:53 +0100 | [diff] [blame] | 588 | BUG_ON_HOT(qcs->tx.offset < qcs->tx.sent_offset); |
| 589 | |
Amaury Denoyelle | 6ccfa3c | 2022-03-10 16:45:53 +0100 | [diff] [blame] | 590 | left = qcs->tx.offset - qcs->tx.sent_offset; |
| 591 | to_xfer = QUIC_MIN(b_data(payload), b_room(out)); |
Amaury Denoyelle | 6ea7819 | 2022-03-07 15:47:02 +0100 | [diff] [blame] | 592 | |
| 593 | BUG_ON_HOT(qcs->tx.offset > qcs->tx.msd); |
| 594 | /* do not exceed flow control limit */ |
| 595 | if (qcs->tx.offset + to_xfer > qcs->tx.msd) |
| 596 | to_xfer = qcs->tx.msd - qcs->tx.offset; |
| 597 | |
Amaury Denoyelle | 05ce55e | 2022-03-08 10:35:42 +0100 | [diff] [blame] | 598 | BUG_ON_HOT(max_data > qcc->rfctl.md); |
| 599 | /* do not overcome flow control limit on connection */ |
| 600 | if (max_data + to_xfer > qcc->rfctl.md) |
| 601 | to_xfer = qcc->rfctl.md - max_data; |
| 602 | |
Amaury Denoyelle | 6ccfa3c | 2022-03-10 16:45:53 +0100 | [diff] [blame] | 603 | if (!left && !to_xfer) |
Frédéric Lécaille | d2ba096 | 2021-09-20 17:50:03 +0200 | [diff] [blame] | 604 | goto out; |
| 605 | |
Amaury Denoyelle | da6ad20 | 2022-04-12 11:41:04 +0200 | [diff] [blame] | 606 | total = b_force_xfer(out, payload, to_xfer); |
| 607 | |
| 608 | out: |
| 609 | { |
| 610 | struct qcs_xfer_data_trace_arg arg = { |
| 611 | .prep = b_data(out), .xfer = total, |
| 612 | }; |
| 613 | TRACE_LEAVE(QMUX_EV_QCS_SEND|QMUX_EV_QCS_XFER_DATA, |
| 614 | qcc->conn, qcs, &arg); |
| 615 | } |
| 616 | |
| 617 | return total; |
| 618 | |
| 619 | err: |
| 620 | TRACE_DEVEL("leaving in error", QMUX_EV_QCS_SEND, qcc->conn, qcs); |
| 621 | return -1; |
| 622 | } |
| 623 | |
| 624 | static int qcs_build_stream_frm(struct qcs *qcs, struct buffer *out, char fin, |
| 625 | struct list *frm_list) |
| 626 | { |
| 627 | struct qcc *qcc = qcs->qcc; |
| 628 | struct quic_frame *frm; |
| 629 | int head, total; |
| 630 | |
| 631 | TRACE_ENTER(QMUX_EV_QCS_SEND, qcc->conn, qcs); |
| 632 | |
| 633 | /* cf buffer schema in qcs_xfer_data */ |
| 634 | head = qcs->tx.sent_offset - qcs->stream->ack_offset; |
| 635 | total = b_data(out) - head; |
| 636 | if (!total) { |
| 637 | TRACE_LEAVE(QMUX_EV_QCS_SEND, qcc->conn, qcs); |
| 638 | return 0; |
| 639 | } |
| 640 | |
Frédéric Lécaille | 578a789 | 2021-09-13 16:13:00 +0200 | [diff] [blame] | 641 | frm = pool_zalloc(pool_head_quic_frame); |
| 642 | if (!frm) |
| 643 | goto err; |
| 644 | |
Amaury Denoyelle | 6ccfa3c | 2022-03-10 16:45:53 +0100 | [diff] [blame] | 645 | frm->type = QUIC_FT_STREAM_8; |
Amaury Denoyelle | 7272cd7 | 2022-03-29 15:15:54 +0200 | [diff] [blame] | 646 | frm->stream.stream = qcs->stream; |
Amaury Denoyelle | d8e680c | 2022-03-29 15:18:44 +0200 | [diff] [blame] | 647 | frm->stream.id = qcs->id; |
Amaury Denoyelle | 6ccfa3c | 2022-03-10 16:45:53 +0100 | [diff] [blame] | 648 | frm->stream.buf = out; |
| 649 | frm->stream.data = (unsigned char *)b_peek(out, head); |
| 650 | |
Amaury Denoyelle | fecfa0d | 2021-12-07 16:50:14 +0100 | [diff] [blame] | 651 | /* FIN is positioned only when the buffer has been totally emptied. */ |
Frédéric Lécaille | 578a789 | 2021-09-13 16:13:00 +0200 | [diff] [blame] | 652 | if (fin) |
| 653 | frm->type |= QUIC_STREAM_FRAME_TYPE_FIN_BIT; |
Amaury Denoyelle | 6ccfa3c | 2022-03-10 16:45:53 +0100 | [diff] [blame] | 654 | |
| 655 | if (qcs->tx.sent_offset) { |
Frédéric Lécaille | 578a789 | 2021-09-13 16:13:00 +0200 | [diff] [blame] | 656 | frm->type |= QUIC_STREAM_FRAME_TYPE_OFF_BIT; |
Amaury Denoyelle | 6ccfa3c | 2022-03-10 16:45:53 +0100 | [diff] [blame] | 657 | frm->stream.offset.key = qcs->tx.sent_offset; |
Frédéric Lécaille | 578a789 | 2021-09-13 16:13:00 +0200 | [diff] [blame] | 658 | } |
Amaury Denoyelle | 6ccfa3c | 2022-03-10 16:45:53 +0100 | [diff] [blame] | 659 | |
Amaury Denoyelle | da6ad20 | 2022-04-12 11:41:04 +0200 | [diff] [blame] | 660 | frm->type |= QUIC_STREAM_FRAME_TYPE_LEN_BIT; |
| 661 | frm->stream.len = total; |
Frédéric Lécaille | 578a789 | 2021-09-13 16:13:00 +0200 | [diff] [blame] | 662 | |
Amaury Denoyelle | 2c71fe5 | 2022-02-09 18:16:49 +0100 | [diff] [blame] | 663 | LIST_APPEND(frm_list, &frm->list); |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 664 | |
Frédéric Lécaille | d2ba096 | 2021-09-20 17:50:03 +0200 | [diff] [blame] | 665 | out: |
Amaury Denoyelle | fdcec36 | 2022-03-25 09:28:10 +0100 | [diff] [blame] | 666 | { |
Amaury Denoyelle | da6ad20 | 2022-04-12 11:41:04 +0200 | [diff] [blame] | 667 | struct qcs_build_stream_trace_arg arg = { |
| 668 | .len = frm->stream.len, .fin = fin, |
| 669 | .offset = frm->stream.offset.key, |
Amaury Denoyelle | fdcec36 | 2022-03-25 09:28:10 +0100 | [diff] [blame] | 670 | }; |
Amaury Denoyelle | da6ad20 | 2022-04-12 11:41:04 +0200 | [diff] [blame] | 671 | TRACE_LEAVE(QMUX_EV_QCS_SEND|QMUX_EV_QCS_BUILD_STRM, |
Amaury Denoyelle | fdcec36 | 2022-03-25 09:28:10 +0100 | [diff] [blame] | 672 | qcc->conn, qcs, &arg); |
| 673 | } |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 674 | |
Frédéric Lécaille | 578a789 | 2021-09-13 16:13:00 +0200 | [diff] [blame] | 675 | return total; |
| 676 | |
| 677 | err: |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 678 | TRACE_DEVEL("leaving in error", QMUX_EV_QCS_SEND, qcc->conn, qcs); |
Frédéric Lécaille | 578a789 | 2021-09-13 16:13:00 +0200 | [diff] [blame] | 679 | return -1; |
| 680 | } |
| 681 | |
Amaury Denoyelle | 54445d0 | 2022-03-10 16:44:14 +0100 | [diff] [blame] | 682 | /* This function must be called by the upper layer to inform about the sending |
| 683 | * of a STREAM frame for <qcs> instance. The frame is of <data> length and on |
| 684 | * <offset>. |
| 685 | */ |
| 686 | void qcc_streams_sent_done(struct qcs *qcs, uint64_t data, uint64_t offset) |
| 687 | { |
Amaury Denoyelle | 05ce55e | 2022-03-08 10:35:42 +0100 | [diff] [blame] | 688 | struct qcc *qcc = qcs->qcc; |
| 689 | uint64_t diff; |
Amaury Denoyelle | 6ccfa3c | 2022-03-10 16:45:53 +0100 | [diff] [blame] | 690 | |
| 691 | BUG_ON(offset > qcs->tx.sent_offset); |
| 692 | |
Amaury Denoyelle | 54445d0 | 2022-03-10 16:44:14 +0100 | [diff] [blame] | 693 | /* check if the STREAM frame has already been notified. It can happen |
| 694 | * for retransmission. |
| 695 | */ |
| 696 | if (offset + data <= qcs->tx.sent_offset) |
| 697 | return; |
Amaury Denoyelle | 6ccfa3c | 2022-03-10 16:45:53 +0100 | [diff] [blame] | 698 | |
| 699 | diff = offset + data - qcs->tx.sent_offset; |
| 700 | |
Amaury Denoyelle | 05ce55e | 2022-03-08 10:35:42 +0100 | [diff] [blame] | 701 | /* increase offset sum on connection */ |
| 702 | qcc->tx.sent_offsets += diff; |
| 703 | BUG_ON_HOT(qcc->tx.sent_offsets > qcc->rfctl.md); |
| 704 | if (qcc->tx.sent_offsets == qcc->rfctl.md) |
| 705 | qcc->flags |= QC_CF_BLK_MFCTL; |
| 706 | |
Amaury Denoyelle | 6ccfa3c | 2022-03-10 16:45:53 +0100 | [diff] [blame] | 707 | /* increase offset on stream */ |
| 708 | qcs->tx.sent_offset += diff; |
Amaury Denoyelle | 6ea7819 | 2022-03-07 15:47:02 +0100 | [diff] [blame] | 709 | BUG_ON_HOT(qcs->tx.sent_offset > qcs->tx.msd); |
| 710 | if (qcs->tx.sent_offset == qcs->tx.msd) |
| 711 | qcs->flags |= QC_SF_BLK_SFCTL; |
Amaury Denoyelle | 54445d0 | 2022-03-10 16:44:14 +0100 | [diff] [blame] | 712 | } |
| 713 | |
Amaury Denoyelle | 2c71fe5 | 2022-02-09 18:16:49 +0100 | [diff] [blame] | 714 | /* Wrapper for send on transport layer. Send a list of frames <frms> for the |
| 715 | * connection <qcc>. |
| 716 | * |
| 717 | * Returns 0 if all data sent with success else non-zero. |
| 718 | */ |
| 719 | static int qc_send_frames(struct qcc *qcc, struct list *frms) |
| 720 | { |
Amaury Denoyelle | db5d1a1 | 2022-03-10 16:42:23 +0100 | [diff] [blame] | 721 | /* TODO implement an opportunistic retry mechanism. This is needed |
| 722 | * because qc_send_app_pkts is not completed. It will only prepare data |
| 723 | * up to its Tx buffer. The frames left are not send even if the Tx |
| 724 | * buffer is emptied by the sendto call. |
| 725 | * |
| 726 | * To overcome this, we call repeatedly qc_send_app_pkts until we |
| 727 | * detect that the transport layer has send nothing. This could happen |
| 728 | * on congestion or sendto syscall error. |
| 729 | * |
| 730 | * When qc_send_app_pkts is improved to handle retry by itself, we can |
| 731 | * remove the looping from the MUX. |
| 732 | */ |
| 733 | struct quic_frame *first_frm; |
| 734 | uint64_t first_offset = 0; |
| 735 | char first_stream_frame_type; |
Amaury Denoyelle | e9c4cc1 | 2022-03-04 15:29:53 +0100 | [diff] [blame] | 736 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 737 | TRACE_ENTER(QMUX_EV_QCC_SEND, qcc->conn); |
| 738 | |
| 739 | if (LIST_ISEMPTY(frms)) { |
| 740 | TRACE_DEVEL("leaving with no frames to send", QMUX_EV_QCC_SEND, qcc->conn); |
Frédéric Lécaille | 4e22f28 | 2022-03-18 18:38:19 +0100 | [diff] [blame] | 741 | return 0; |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 742 | } |
Frédéric Lécaille | 4e22f28 | 2022-03-18 18:38:19 +0100 | [diff] [blame] | 743 | |
Amaury Denoyelle | e9c4cc1 | 2022-03-04 15:29:53 +0100 | [diff] [blame] | 744 | retry_send: |
Amaury Denoyelle | db5d1a1 | 2022-03-10 16:42:23 +0100 | [diff] [blame] | 745 | first_frm = LIST_ELEM(frms->n, struct quic_frame *, list); |
| 746 | if ((first_frm->type & QUIC_FT_STREAM_8) == QUIC_FT_STREAM_8) { |
| 747 | first_offset = first_frm->stream.offset.key; |
| 748 | first_stream_frame_type = 1; |
| 749 | } |
| 750 | else { |
| 751 | first_stream_frame_type = 0; |
| 752 | } |
| 753 | |
Amaury Denoyelle | 2c71fe5 | 2022-02-09 18:16:49 +0100 | [diff] [blame] | 754 | if (!LIST_ISEMPTY(frms)) |
Willy Tarreau | 784b868 | 2022-04-11 14:18:10 +0200 | [diff] [blame] | 755 | qc_send_app_pkts(qcc->conn->handle.qc, frms); |
Amaury Denoyelle | 2c71fe5 | 2022-02-09 18:16:49 +0100 | [diff] [blame] | 756 | |
Amaury Denoyelle | db5d1a1 | 2022-03-10 16:42:23 +0100 | [diff] [blame] | 757 | /* If there is frames left, check if the transport layer has send some |
| 758 | * data or is blocked. |
Amaury Denoyelle | 2c71fe5 | 2022-02-09 18:16:49 +0100 | [diff] [blame] | 759 | */ |
Amaury Denoyelle | db5d1a1 | 2022-03-10 16:42:23 +0100 | [diff] [blame] | 760 | if (!LIST_ISEMPTY(frms)) { |
| 761 | if (first_frm != LIST_ELEM(frms->n, struct quic_frame *, list)) |
| 762 | goto retry_send; |
| 763 | |
| 764 | /* If the first frame is STREAM, check if its offset has |
| 765 | * changed. |
| 766 | */ |
| 767 | if (first_stream_frame_type && |
| 768 | first_offset != LIST_ELEM(frms->n, struct quic_frame *, list)->stream.offset.key) { |
| 769 | goto retry_send; |
| 770 | } |
Amaury Denoyelle | e9c4cc1 | 2022-03-04 15:29:53 +0100 | [diff] [blame] | 771 | } |
| 772 | |
Amaury Denoyelle | db5d1a1 | 2022-03-10 16:42:23 +0100 | [diff] [blame] | 773 | /* If there is frames left at this stage, transport layer is blocked. |
| 774 | * Subscribe on it to retry later. |
| 775 | */ |
Amaury Denoyelle | 2c71fe5 | 2022-02-09 18:16:49 +0100 | [diff] [blame] | 776 | if (!LIST_ISEMPTY(frms)) { |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 777 | TRACE_DEVEL("leaving with remaining frames to send, subscribing", QMUX_EV_QCC_SEND, qcc->conn); |
Amaury Denoyelle | 2c71fe5 | 2022-02-09 18:16:49 +0100 | [diff] [blame] | 778 | qcc->conn->xprt->subscribe(qcc->conn, qcc->conn->xprt_ctx, |
| 779 | SUB_RETRY_SEND, &qcc->wait_event); |
| 780 | return 1; |
| 781 | } |
| 782 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 783 | TRACE_LEAVE(QMUX_EV_QCC_SEND); |
| 784 | |
Amaury Denoyelle | 2c71fe5 | 2022-02-09 18:16:49 +0100 | [diff] [blame] | 785 | return 0; |
| 786 | } |
| 787 | |
Amaury Denoyelle | c933780 | 2022-04-04 16:36:34 +0200 | [diff] [blame] | 788 | /* Send a MAX_STREAM_BIDI frame to update the limit of bidirectional streams |
| 789 | * allowed to be opened by the peer. The caller should have first checked if |
| 790 | * this is required with qc_is_max_streams_needed. |
| 791 | * |
| 792 | * Returns 0 on success else non-zero. |
| 793 | */ |
| 794 | static int qc_send_max_streams(struct qcc *qcc) |
| 795 | { |
| 796 | struct list frms = LIST_HEAD_INIT(frms); |
| 797 | struct quic_frame *frm; |
| 798 | |
| 799 | frm = pool_zalloc(pool_head_quic_frame); |
| 800 | BUG_ON(!frm); /* TODO handle this properly */ |
| 801 | |
| 802 | frm->type = QUIC_FT_MAX_STREAMS_BIDI; |
| 803 | frm->max_streams_bidi.max_streams = qcc->lfctl.ms_bidi + |
| 804 | qcc->lfctl.cl_bidi_r; |
| 805 | TRACE_DEVEL("sending MAX_STREAMS frame", QMUX_EV_SEND_FRM, qcc->conn, NULL, frm); |
| 806 | LIST_APPEND(&frms, &frm->list); |
| 807 | |
| 808 | if (qc_send_frames(qcc, &frms)) |
| 809 | return 1; |
| 810 | |
| 811 | /* save the new limit if the frame has been send. */ |
| 812 | qcc->lfctl.ms_bidi += qcc->lfctl.cl_bidi_r; |
| 813 | qcc->lfctl.cl_bidi_r = 0; |
| 814 | |
| 815 | return 0; |
| 816 | } |
| 817 | |
Amaury Denoyelle | 75d14ad | 2022-03-22 15:10:29 +0100 | [diff] [blame] | 818 | /* Proceed to sending. Loop through all available streams for the <qcc> |
| 819 | * instance and try to send as much as possible. |
| 820 | * |
| 821 | * Returns the total of bytes sent to the transport layer. |
| 822 | */ |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 823 | static int qc_send(struct qcc *qcc) |
| 824 | { |
Amaury Denoyelle | 6ccfa3c | 2022-03-10 16:45:53 +0100 | [diff] [blame] | 825 | struct list frms = LIST_HEAD_INIT(frms); |
Frédéric Lécaille | 578a789 | 2021-09-13 16:13:00 +0200 | [diff] [blame] | 826 | struct eb64_node *node; |
Amaury Denoyelle | 75d14ad | 2022-03-22 15:10:29 +0100 | [diff] [blame] | 827 | int total = 0; |
Frédéric Lécaille | 578a789 | 2021-09-13 16:13:00 +0200 | [diff] [blame] | 828 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 829 | TRACE_ENTER(QMUX_EV_QCC_SEND); |
Frédéric Lécaille | 8526f14 | 2021-09-20 17:58:22 +0200 | [diff] [blame] | 830 | |
Amaury Denoyelle | d97fc80 | 2022-04-06 16:13:09 +0200 | [diff] [blame] | 831 | if (qcc->conn->flags & CO_FL_SOCK_WR_SH) { |
| 832 | qcc->conn->flags |= CO_FL_ERROR; |
| 833 | TRACE_DEVEL("leaving on error", QMUX_EV_QCC_SEND, qcc->conn); |
| 834 | return 0; |
| 835 | } |
| 836 | |
Amaury Denoyelle | c933780 | 2022-04-04 16:36:34 +0200 | [diff] [blame] | 837 | if (qc_is_max_streams_needed(qcc)) |
| 838 | qc_send_max_streams(qcc); |
| 839 | |
Amaury Denoyelle | 05ce55e | 2022-03-08 10:35:42 +0100 | [diff] [blame] | 840 | if (qcc->flags & QC_CF_BLK_MFCTL) |
| 841 | return 0; |
| 842 | |
Amaury Denoyelle | 2c71fe5 | 2022-02-09 18:16:49 +0100 | [diff] [blame] | 843 | /* loop through all streams, construct STREAM frames if data available. |
| 844 | * TODO optimize the loop to favor streams which are not too heavy. |
Frédéric Lécaille | 578a789 | 2021-09-13 16:13:00 +0200 | [diff] [blame] | 845 | */ |
| 846 | node = eb64_first(&qcc->streams_by_id); |
| 847 | while (node) { |
Amaury Denoyelle | e4301da | 2022-04-19 17:59:50 +0200 | [diff] [blame^] | 848 | struct qcs *qcs = eb64_entry(node, struct qcs, by_id); |
Amaury Denoyelle | d3d97c6 | 2021-10-05 11:45:58 +0200 | [diff] [blame] | 849 | struct buffer *buf = &qcs->tx.buf; |
Amaury Denoyelle | 7272cd7 | 2022-03-29 15:15:54 +0200 | [diff] [blame] | 850 | struct buffer *out = &qcs->stream->buf; |
Amaury Denoyelle | 2c71fe5 | 2022-02-09 18:16:49 +0100 | [diff] [blame] | 851 | |
Amaury Denoyelle | e2ec942 | 2022-03-10 16:46:18 +0100 | [diff] [blame] | 852 | /* TODO |
| 853 | * for the moment, unidirectional streams have their own |
| 854 | * mechanism for sending. This should be unified in the future, |
| 855 | * in this case the next check will be removed. |
| 856 | */ |
Amaury Denoyelle | d8e680c | 2022-03-29 15:18:44 +0200 | [diff] [blame] | 857 | if (quic_stream_is_uni(qcs->id)) { |
Amaury Denoyelle | e2ec942 | 2022-03-10 16:46:18 +0100 | [diff] [blame] | 858 | node = eb64_next(node); |
| 859 | continue; |
| 860 | } |
| 861 | |
Amaury Denoyelle | 6ea7819 | 2022-03-07 15:47:02 +0100 | [diff] [blame] | 862 | if (qcs->flags & QC_SF_BLK_SFCTL) { |
| 863 | node = eb64_next(node); |
| 864 | continue; |
| 865 | } |
| 866 | |
Amaury Denoyelle | da6ad20 | 2022-04-12 11:41:04 +0200 | [diff] [blame] | 867 | /* Prepare <out> buffer with data from <buf>. */ |
| 868 | if (b_data(buf)) { |
| 869 | int ret = qcs_xfer_data(qcs, out, buf, |
| 870 | qcc->tx.sent_offsets + total); |
Amaury Denoyelle | 1455113 | 2022-03-04 16:51:20 +0100 | [diff] [blame] | 871 | BUG_ON(ret < 0); /* TODO handle this properly */ |
Frédéric Lécaille | 578a789 | 2021-09-13 16:13:00 +0200 | [diff] [blame] | 872 | |
Amaury Denoyelle | e257d9e | 2021-12-03 14:39:29 +0100 | [diff] [blame] | 873 | if (ret > 0) { |
Amaury Denoyelle | a3f222d | 2021-12-06 11:24:00 +0100 | [diff] [blame] | 874 | qcs_notify_send(qcs); |
Amaury Denoyelle | 84ea8dc | 2021-12-03 14:40:01 +0100 | [diff] [blame] | 875 | if (qcs->flags & QC_SF_BLK_MROOM) |
| 876 | qcs->flags &= ~QC_SF_BLK_MROOM; |
Amaury Denoyelle | e257d9e | 2021-12-03 14:39:29 +0100 | [diff] [blame] | 877 | } |
Amaury Denoyelle | a543eb1 | 2021-10-06 14:53:13 +0200 | [diff] [blame] | 878 | |
Amaury Denoyelle | d3d97c6 | 2021-10-05 11:45:58 +0200 | [diff] [blame] | 879 | qcs->tx.offset += ret; |
Amaury Denoyelle | 75d14ad | 2022-03-22 15:10:29 +0100 | [diff] [blame] | 880 | total += ret; |
Amaury Denoyelle | da6ad20 | 2022-04-12 11:41:04 +0200 | [diff] [blame] | 881 | } |
Amaury Denoyelle | a2c58a7 | 2021-12-03 14:38:31 +0100 | [diff] [blame] | 882 | |
Amaury Denoyelle | da6ad20 | 2022-04-12 11:41:04 +0200 | [diff] [blame] | 883 | /* Subscribe if not all data can be transfered. */ |
| 884 | if (b_data(buf)) { |
| 885 | qcc->conn->xprt->subscribe(qcc->conn, qcc->conn->xprt_ctx, |
| 886 | SUB_RETRY_SEND, &qcc->wait_event); |
Frédéric Lécaille | 578a789 | 2021-09-13 16:13:00 +0200 | [diff] [blame] | 887 | } |
Amaury Denoyelle | da6ad20 | 2022-04-12 11:41:04 +0200 | [diff] [blame] | 888 | |
| 889 | /* Build a new STREAM frame with <out> buffer. */ |
| 890 | if (b_data(out)) { |
| 891 | int ret; |
| 892 | char fin = !!(qcs->flags & QC_SF_FIN_STREAM); |
| 893 | |
| 894 | /* FIN is set if all incoming data were transfered. */ |
| 895 | fin = !!(fin && !b_data(buf)); |
| 896 | ret = qcs_build_stream_frm(qcs, out, fin, &frms); |
| 897 | BUG_ON(ret < 0); /* TODO handle this properly */ |
| 898 | } |
| 899 | |
Frédéric Lécaille | 578a789 | 2021-09-13 16:13:00 +0200 | [diff] [blame] | 900 | node = eb64_next(node); |
| 901 | } |
Frédéric Lécaille | 8526f14 | 2021-09-20 17:58:22 +0200 | [diff] [blame] | 902 | |
Amaury Denoyelle | 6ccfa3c | 2022-03-10 16:45:53 +0100 | [diff] [blame] | 903 | qc_send_frames(qcc, &frms); |
Amaury Denoyelle | e257d9e | 2021-12-03 14:39:29 +0100 | [diff] [blame] | 904 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 905 | TRACE_LEAVE(QMUX_EV_QCC_SEND); |
| 906 | |
Amaury Denoyelle | 75d14ad | 2022-03-22 15:10:29 +0100 | [diff] [blame] | 907 | return total; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 908 | } |
| 909 | |
Amaury Denoyelle | 6a4aebf | 2022-02-01 10:16:05 +0100 | [diff] [blame] | 910 | /* Release all streams that are already marked as detached. This is only done |
| 911 | * if their TX buffers are empty or if a CONNECTION_CLOSE has been received. |
| 912 | * |
| 913 | * Return the number of released stream. |
| 914 | */ |
Amaury Denoyelle | 2873a31 | 2021-12-08 14:42:55 +0100 | [diff] [blame] | 915 | static int qc_release_detached_streams(struct qcc *qcc) |
| 916 | { |
| 917 | struct eb64_node *node; |
| 918 | int release = 0; |
| 919 | |
| 920 | node = eb64_first(&qcc->streams_by_id); |
| 921 | while (node) { |
Amaury Denoyelle | e4301da | 2022-04-19 17:59:50 +0200 | [diff] [blame^] | 922 | struct qcs *qcs = eb64_entry(node, struct qcs, by_id); |
Amaury Denoyelle | 2873a31 | 2021-12-08 14:42:55 +0100 | [diff] [blame] | 923 | node = eb64_next(node); |
| 924 | |
| 925 | if (qcs->flags & QC_SF_DETACH) { |
Amaury Denoyelle | 7272cd7 | 2022-03-29 15:15:54 +0200 | [diff] [blame] | 926 | if (!b_data(&qcs->tx.buf) && |
| 927 | qcs->tx.offset == qcs->tx.sent_offset) { |
Amaury Denoyelle | 2873a31 | 2021-12-08 14:42:55 +0100 | [diff] [blame] | 928 | qcs_destroy(qcs); |
| 929 | release = 1; |
| 930 | } |
| 931 | else { |
| 932 | qcc->conn->xprt->subscribe(qcc->conn, qcc->conn->xprt_ctx, |
| 933 | SUB_RETRY_SEND, &qcc->wait_event); |
| 934 | } |
| 935 | } |
| 936 | } |
| 937 | |
| 938 | return release; |
| 939 | } |
| 940 | |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 941 | static struct task *qc_io_cb(struct task *t, void *ctx, unsigned int status) |
| 942 | { |
Amaury Denoyelle | 769e9ff | 2021-10-05 11:43:50 +0200 | [diff] [blame] | 943 | struct qcc *qcc = ctx; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 944 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 945 | TRACE_ENTER(QMUX_EV_QCC_WAKE); |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 946 | |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 947 | qc_send(qcc); |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 948 | |
Amaury Denoyelle | 2873a31 | 2021-12-08 14:42:55 +0100 | [diff] [blame] | 949 | if (qc_release_detached_streams(qcc)) { |
Amaury Denoyelle | 06890aa | 2022-04-04 16:15:06 +0200 | [diff] [blame] | 950 | if (qcc_is_dead(qcc)) { |
| 951 | qc_release(qcc); |
| 952 | } |
| 953 | else { |
| 954 | if (qcc_may_expire(qcc)) |
| 955 | qcc->task->expire = tick_add(now_ms, qcc->timeout); |
| 956 | else |
| 957 | qcc->task->expire = TICK_ETERNITY; |
Amaury Denoyelle | 1136e92 | 2022-02-01 10:33:09 +0100 | [diff] [blame] | 958 | task_queue(qcc->task); |
Amaury Denoyelle | 2873a31 | 2021-12-08 14:42:55 +0100 | [diff] [blame] | 959 | } |
| 960 | } |
| 961 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 962 | TRACE_LEAVE(QMUX_EV_QCC_WAKE); |
| 963 | |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 964 | return NULL; |
| 965 | } |
| 966 | |
Amaury Denoyelle | aebe26f | 2022-01-13 16:28:06 +0100 | [diff] [blame] | 967 | static struct task *qc_timeout_task(struct task *t, void *ctx, unsigned int state) |
| 968 | { |
| 969 | struct qcc *qcc = ctx; |
| 970 | int expired = tick_is_expired(t->expire, now_ms); |
| 971 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 972 | TRACE_ENTER(QMUX_EV_QCC_WAKE, qcc ? qcc->conn : NULL); |
Amaury Denoyelle | aebe26f | 2022-01-13 16:28:06 +0100 | [diff] [blame] | 973 | |
| 974 | if (qcc) { |
| 975 | if (!expired) { |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 976 | TRACE_DEVEL("leaving (not expired)", QMUX_EV_QCC_WAKE, qcc->conn); |
Amaury Denoyelle | aebe26f | 2022-01-13 16:28:06 +0100 | [diff] [blame] | 977 | return t; |
| 978 | } |
| 979 | |
| 980 | if (!qcc_may_expire(qcc)) { |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 981 | TRACE_DEVEL("leaving (cannot expired)", QMUX_EV_QCC_WAKE, qcc->conn); |
Amaury Denoyelle | aebe26f | 2022-01-13 16:28:06 +0100 | [diff] [blame] | 982 | t->expire = TICK_ETERNITY; |
| 983 | return t; |
| 984 | } |
| 985 | } |
| 986 | |
Amaury Denoyelle | aebe26f | 2022-01-13 16:28:06 +0100 | [diff] [blame] | 987 | task_destroy(t); |
Amaury Denoyelle | ea3e035 | 2022-02-21 10:05:16 +0100 | [diff] [blame] | 988 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 989 | if (!qcc) { |
| 990 | TRACE_DEVEL("leaving (not more qcc)", QMUX_EV_QCC_WAKE); |
Amaury Denoyelle | ea3e035 | 2022-02-21 10:05:16 +0100 | [diff] [blame] | 991 | return NULL; |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 992 | } |
Amaury Denoyelle | ea3e035 | 2022-02-21 10:05:16 +0100 | [diff] [blame] | 993 | |
Amaury Denoyelle | aebe26f | 2022-01-13 16:28:06 +0100 | [diff] [blame] | 994 | qcc->task = NULL; |
| 995 | |
| 996 | if (qcc_is_dead(qcc)) |
| 997 | qc_release(qcc); |
| 998 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 999 | TRACE_LEAVE(QMUX_EV_QCC_WAKE); |
| 1000 | |
Amaury Denoyelle | aebe26f | 2022-01-13 16:28:06 +0100 | [diff] [blame] | 1001 | return NULL; |
| 1002 | } |
| 1003 | |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1004 | static int qc_init(struct connection *conn, struct proxy *prx, |
| 1005 | struct session *sess, struct buffer *input) |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1006 | { |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1007 | struct qcc *qcc; |
Amaury Denoyelle | 6ea7819 | 2022-03-07 15:47:02 +0100 | [diff] [blame] | 1008 | struct quic_transport_params *lparams, *rparams; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1009 | |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1010 | qcc = pool_alloc(pool_head_qcc); |
| 1011 | if (!qcc) |
| 1012 | goto fail_no_qcc; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1013 | |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1014 | qcc->conn = conn; |
| 1015 | conn->ctx = qcc; |
Amaury Denoyelle | 06890aa | 2022-04-04 16:15:06 +0200 | [diff] [blame] | 1016 | qcc->nb_cs = 0; |
Amaury Denoyelle | ce1f30d | 2022-02-01 15:14:24 +0100 | [diff] [blame] | 1017 | qcc->flags = 0; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1018 | |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1019 | qcc->app_ops = NULL; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1020 | |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1021 | qcc->streams_by_id = EB_ROOT_UNIQUE; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1022 | |
Amaury Denoyelle | f3b0ba7 | 2021-12-08 15:12:01 +0100 | [diff] [blame] | 1023 | /* Server parameters, params used for RX flow control. */ |
Willy Tarreau | 784b868 | 2022-04-11 14:18:10 +0200 | [diff] [blame] | 1024 | lparams = &conn->handle.qc->rx.params; |
Amaury Denoyelle | f3b0ba7 | 2021-12-08 15:12:01 +0100 | [diff] [blame] | 1025 | |
Amaury Denoyelle | 749cb64 | 2022-02-09 10:25:29 +0100 | [diff] [blame] | 1026 | qcc->rx.max_data = lparams->initial_max_data; |
Amaury Denoyelle | 05ce55e | 2022-03-08 10:35:42 +0100 | [diff] [blame] | 1027 | qcc->tx.sent_offsets = 0; |
Amaury Denoyelle | f3b0ba7 | 2021-12-08 15:12:01 +0100 | [diff] [blame] | 1028 | |
| 1029 | /* Client initiated streams must respect the server flow control. */ |
Amaury Denoyelle | 749cb64 | 2022-02-09 10:25:29 +0100 | [diff] [blame] | 1030 | qcc->strms[QCS_CLT_BIDI].max_streams = lparams->initial_max_streams_bidi; |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1031 | qcc->strms[QCS_CLT_BIDI].nb_streams = 0; |
| 1032 | qcc->strms[QCS_CLT_BIDI].largest_id = -1; |
Amaury Denoyelle | f3b0ba7 | 2021-12-08 15:12:01 +0100 | [diff] [blame] | 1033 | qcc->strms[QCS_CLT_BIDI].rx.max_data = 0; |
Amaury Denoyelle | 749cb64 | 2022-02-09 10:25:29 +0100 | [diff] [blame] | 1034 | qcc->strms[QCS_CLT_BIDI].tx.max_data = lparams->initial_max_stream_data_bidi_remote; |
Amaury Denoyelle | f3b0ba7 | 2021-12-08 15:12:01 +0100 | [diff] [blame] | 1035 | |
Amaury Denoyelle | 749cb64 | 2022-02-09 10:25:29 +0100 | [diff] [blame] | 1036 | qcc->strms[QCS_CLT_UNI].max_streams = lparams->initial_max_streams_uni; |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1037 | qcc->strms[QCS_CLT_UNI].nb_streams = 0; |
| 1038 | qcc->strms[QCS_CLT_UNI].largest_id = -1; |
Amaury Denoyelle | f3b0ba7 | 2021-12-08 15:12:01 +0100 | [diff] [blame] | 1039 | qcc->strms[QCS_CLT_UNI].rx.max_data = 0; |
Amaury Denoyelle | 749cb64 | 2022-02-09 10:25:29 +0100 | [diff] [blame] | 1040 | qcc->strms[QCS_CLT_UNI].tx.max_data = lparams->initial_max_stream_data_uni; |
Amaury Denoyelle | f3b0ba7 | 2021-12-08 15:12:01 +0100 | [diff] [blame] | 1041 | |
| 1042 | /* Server initiated streams must respect the server flow control. */ |
| 1043 | qcc->strms[QCS_SRV_BIDI].max_streams = 0; |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1044 | qcc->strms[QCS_SRV_BIDI].nb_streams = 0; |
| 1045 | qcc->strms[QCS_SRV_BIDI].largest_id = -1; |
Amaury Denoyelle | 749cb64 | 2022-02-09 10:25:29 +0100 | [diff] [blame] | 1046 | qcc->strms[QCS_SRV_BIDI].rx.max_data = lparams->initial_max_stream_data_bidi_local; |
Amaury Denoyelle | f3b0ba7 | 2021-12-08 15:12:01 +0100 | [diff] [blame] | 1047 | qcc->strms[QCS_SRV_BIDI].tx.max_data = 0; |
| 1048 | |
| 1049 | qcc->strms[QCS_SRV_UNI].max_streams = 0; |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1050 | qcc->strms[QCS_SRV_UNI].nb_streams = 0; |
| 1051 | qcc->strms[QCS_SRV_UNI].largest_id = -1; |
Amaury Denoyelle | 749cb64 | 2022-02-09 10:25:29 +0100 | [diff] [blame] | 1052 | qcc->strms[QCS_SRV_UNI].rx.max_data = lparams->initial_max_stream_data_uni; |
Amaury Denoyelle | f3b0ba7 | 2021-12-08 15:12:01 +0100 | [diff] [blame] | 1053 | qcc->strms[QCS_SRV_UNI].tx.max_data = 0; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1054 | |
Amaury Denoyelle | 78396e5 | 2022-03-21 17:13:32 +0100 | [diff] [blame] | 1055 | qcc->lfctl.ms_bidi = qcc->lfctl.ms_bidi_init = lparams->initial_max_streams_bidi; |
| 1056 | qcc->lfctl.cl_bidi_r = 0; |
Amaury Denoyelle | c055e30 | 2022-02-07 16:09:06 +0100 | [diff] [blame] | 1057 | |
Willy Tarreau | 784b868 | 2022-04-11 14:18:10 +0200 | [diff] [blame] | 1058 | rparams = &conn->handle.qc->tx.params; |
Amaury Denoyelle | 05ce55e | 2022-03-08 10:35:42 +0100 | [diff] [blame] | 1059 | qcc->rfctl.md = rparams->initial_max_data; |
Amaury Denoyelle | 6ea7819 | 2022-03-07 15:47:02 +0100 | [diff] [blame] | 1060 | qcc->rfctl.msd_bidi_l = rparams->initial_max_stream_data_bidi_local; |
| 1061 | qcc->rfctl.msd_bidi_r = rparams->initial_max_stream_data_bidi_remote; |
| 1062 | |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1063 | qcc->wait_event.tasklet = tasklet_new(); |
| 1064 | if (!qcc->wait_event.tasklet) |
| 1065 | goto fail_no_tasklet; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1066 | |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1067 | qcc->subs = NULL; |
| 1068 | qcc->wait_event.tasklet->process = qc_io_cb; |
| 1069 | qcc->wait_event.tasklet->context = qcc; |
Frédéric Lécaille | f27b66f | 2022-03-18 22:49:22 +0100 | [diff] [blame] | 1070 | qcc->wait_event.events = 0; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1071 | |
Amaury Denoyelle | aebe26f | 2022-01-13 16:28:06 +0100 | [diff] [blame] | 1072 | /* haproxy timeouts */ |
| 1073 | qcc->timeout = prx->timeout.client; |
| 1074 | qcc->task = task_new_here(); |
| 1075 | if (!qcc->task) |
| 1076 | goto fail_no_timeout_task; |
| 1077 | qcc->task->process = qc_timeout_task; |
| 1078 | qcc->task->context = qcc; |
| 1079 | qcc->task->expire = tick_add(now_ms, qcc->timeout); |
| 1080 | |
Amaury Denoyelle | 0e0969d | 2022-01-31 15:41:14 +0100 | [diff] [blame] | 1081 | if (!conn_is_back(conn)) { |
| 1082 | if (!LIST_INLIST(&conn->stopping_list)) { |
| 1083 | LIST_APPEND(&mux_stopping_data[tid].list, |
| 1084 | &conn->stopping_list); |
| 1085 | } |
| 1086 | } |
| 1087 | |
Willy Tarreau | 784b868 | 2022-04-11 14:18:10 +0200 | [diff] [blame] | 1088 | HA_ATOMIC_STORE(&conn->handle.qc->qcc, qcc); |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1089 | /* init read cycle */ |
| 1090 | tasklet_wakeup(qcc->wait_event.tasklet); |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1091 | |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1092 | return 0; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1093 | |
Amaury Denoyelle | aebe26f | 2022-01-13 16:28:06 +0100 | [diff] [blame] | 1094 | fail_no_timeout_task: |
| 1095 | tasklet_free(qcc->wait_event.tasklet); |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1096 | fail_no_tasklet: |
| 1097 | pool_free(pool_head_qcc, qcc); |
| 1098 | fail_no_qcc: |
| 1099 | return -1; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1100 | } |
| 1101 | |
Amaury Denoyelle | 2461bd5 | 2022-04-13 16:54:52 +0200 | [diff] [blame] | 1102 | static void qc_destroy(void *ctx) |
| 1103 | { |
| 1104 | struct qcc *qcc = ctx; |
| 1105 | |
| 1106 | TRACE_ENTER(QMUX_EV_QCC_END, qcc->conn); |
| 1107 | qc_release(qcc); |
| 1108 | TRACE_LEAVE(QMUX_EV_QCC_END); |
| 1109 | } |
| 1110 | |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1111 | static void qc_detach(struct conn_stream *cs) |
| 1112 | { |
Christopher Faulet | db90f2a | 2022-03-22 16:06:25 +0100 | [diff] [blame] | 1113 | struct qcs *qcs = __cs_mux(cs); |
Amaury Denoyelle | 916f0ac | 2021-12-06 16:03:47 +0100 | [diff] [blame] | 1114 | struct qcc *qcc = qcs->qcc; |
| 1115 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 1116 | TRACE_ENTER(QMUX_EV_STRM_END, qcc->conn, qcs); |
Amaury Denoyelle | 916f0ac | 2021-12-06 16:03:47 +0100 | [diff] [blame] | 1117 | |
Amaury Denoyelle | 8038821 | 2022-04-08 12:00:12 +0200 | [diff] [blame] | 1118 | qcs->cs = NULL; |
Amaury Denoyelle | 06890aa | 2022-04-04 16:15:06 +0200 | [diff] [blame] | 1119 | --qcc->nb_cs; |
| 1120 | |
Amaury Denoyelle | fe035ec | 2022-04-06 15:46:30 +0200 | [diff] [blame] | 1121 | if ((b_data(&qcs->tx.buf) || qcs->tx.offset > qcs->tx.sent_offset) && |
| 1122 | !(qcc->conn->flags & CO_FL_ERROR)) { |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 1123 | TRACE_DEVEL("leaving with remaining data, detaching qcs", QMUX_EV_STRM_END, qcc->conn, qcs); |
Amaury Denoyelle | 2873a31 | 2021-12-08 14:42:55 +0100 | [diff] [blame] | 1124 | qcs->flags |= QC_SF_DETACH; |
| 1125 | return; |
| 1126 | } |
| 1127 | |
Amaury Denoyelle | 916f0ac | 2021-12-06 16:03:47 +0100 | [diff] [blame] | 1128 | qcs_destroy(qcs); |
Amaury Denoyelle | 1136e92 | 2022-02-01 10:33:09 +0100 | [diff] [blame] | 1129 | |
Amaury Denoyelle | 06890aa | 2022-04-04 16:15:06 +0200 | [diff] [blame] | 1130 | if (qcc_is_dead(qcc)) { |
| 1131 | qc_release(qcc); |
| 1132 | } |
| 1133 | else { |
| 1134 | if (qcc_may_expire(qcc)) |
| 1135 | qcc->task->expire = tick_add(now_ms, qcc->timeout); |
| 1136 | else |
| 1137 | qcc->task->expire = TICK_ETERNITY; |
Amaury Denoyelle | 1136e92 | 2022-02-01 10:33:09 +0100 | [diff] [blame] | 1138 | task_queue(qcc->task); |
Amaury Denoyelle | 916f0ac | 2021-12-06 16:03:47 +0100 | [diff] [blame] | 1139 | } |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 1140 | |
| 1141 | TRACE_LEAVE(QMUX_EV_STRM_END); |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1142 | } |
| 1143 | |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1144 | /* Called from the upper layer, to receive data */ |
| 1145 | static size_t qc_rcv_buf(struct conn_stream *cs, struct buffer *buf, |
| 1146 | size_t count, int flags) |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1147 | { |
Christopher Faulet | db90f2a | 2022-03-22 16:06:25 +0100 | [diff] [blame] | 1148 | struct qcs *qcs = __cs_mux(cs); |
Amaury Denoyelle | 9a327a7 | 2022-02-14 17:11:09 +0100 | [diff] [blame] | 1149 | struct htx *qcs_htx = NULL; |
| 1150 | struct htx *cs_htx = NULL; |
| 1151 | size_t ret = 0; |
Amaury Denoyelle | eb53e5b | 2022-02-14 17:11:32 +0100 | [diff] [blame] | 1152 | char fin = 0; |
Amaury Denoyelle | 9a327a7 | 2022-02-14 17:11:09 +0100 | [diff] [blame] | 1153 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 1154 | TRACE_ENTER(QMUX_EV_STRM_RECV, qcs->qcc->conn, qcs); |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1155 | |
Amaury Denoyelle | 9a327a7 | 2022-02-14 17:11:09 +0100 | [diff] [blame] | 1156 | qcs_htx = htx_from_buf(&qcs->rx.app_buf); |
| 1157 | if (htx_is_empty(qcs_htx)) { |
| 1158 | /* Set buffer data to 0 as HTX is empty. */ |
| 1159 | htx_to_buf(qcs_htx, &qcs->rx.app_buf); |
| 1160 | goto end; |
| 1161 | } |
| 1162 | |
| 1163 | ret = qcs_htx->data; |
| 1164 | |
| 1165 | cs_htx = htx_from_buf(buf); |
| 1166 | if (htx_is_empty(cs_htx) && htx_used_space(qcs_htx) <= count) { |
| 1167 | htx_to_buf(cs_htx, buf); |
| 1168 | htx_to_buf(qcs_htx, &qcs->rx.app_buf); |
| 1169 | b_xfer(buf, &qcs->rx.app_buf, b_data(&qcs->rx.app_buf)); |
| 1170 | goto end; |
| 1171 | } |
| 1172 | |
| 1173 | htx_xfer_blks(cs_htx, qcs_htx, count, HTX_BLK_UNUSED); |
| 1174 | BUG_ON(qcs_htx->flags & HTX_FL_PARSING_ERROR); |
| 1175 | |
| 1176 | /* Copy EOM from src to dst buffer if all data copied. */ |
Amaury Denoyelle | eb53e5b | 2022-02-14 17:11:32 +0100 | [diff] [blame] | 1177 | if (htx_is_empty(qcs_htx) && (qcs_htx->flags & HTX_FL_EOM)) { |
| 1178 | cs_htx->flags |= HTX_FL_EOM; |
| 1179 | fin = 1; |
| 1180 | } |
Amaury Denoyelle | 9a327a7 | 2022-02-14 17:11:09 +0100 | [diff] [blame] | 1181 | |
| 1182 | cs_htx->extra = qcs_htx->extra ? (qcs_htx->data + qcs_htx->extra) : 0; |
| 1183 | htx_to_buf(cs_htx, buf); |
| 1184 | htx_to_buf(qcs_htx, &qcs->rx.app_buf); |
| 1185 | ret -= qcs_htx->data; |
| 1186 | |
| 1187 | end: |
| 1188 | if (b_data(&qcs->rx.app_buf)) { |
Christopher Faulet | b041b23 | 2022-03-24 10:27:02 +0100 | [diff] [blame] | 1189 | cs->endp->flags |= (CS_EP_RCV_MORE | CS_EP_WANT_ROOM); |
Amaury Denoyelle | 9a327a7 | 2022-02-14 17:11:09 +0100 | [diff] [blame] | 1190 | } |
| 1191 | else { |
Christopher Faulet | b041b23 | 2022-03-24 10:27:02 +0100 | [diff] [blame] | 1192 | cs->endp->flags &= ~(CS_EP_RCV_MORE | CS_EP_WANT_ROOM); |
| 1193 | if (cs->endp->flags & CS_EP_ERR_PENDING) |
| 1194 | cs->endp->flags |= CS_EP_ERROR; |
Amaury Denoyelle | 9a327a7 | 2022-02-14 17:11:09 +0100 | [diff] [blame] | 1195 | |
Amaury Denoyelle | eb53e5b | 2022-02-14 17:11:32 +0100 | [diff] [blame] | 1196 | if (fin) |
Christopher Faulet | b041b23 | 2022-03-24 10:27:02 +0100 | [diff] [blame] | 1197 | cs->endp->flags |= (CS_EP_EOI|CS_EP_EOS); |
Amaury Denoyelle | 9a327a7 | 2022-02-14 17:11:09 +0100 | [diff] [blame] | 1198 | |
| 1199 | if (b_size(&qcs->rx.app_buf)) { |
| 1200 | b_free(&qcs->rx.app_buf); |
| 1201 | offer_buffers(NULL, 1); |
| 1202 | } |
| 1203 | } |
| 1204 | |
| 1205 | if (ret) |
| 1206 | tasklet_wakeup(qcs->qcc->wait_event.tasklet); |
| 1207 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 1208 | TRACE_LEAVE(QMUX_EV_STRM_RECV, qcs->qcc->conn, qcs); |
| 1209 | |
Amaury Denoyelle | 9a327a7 | 2022-02-14 17:11:09 +0100 | [diff] [blame] | 1210 | return ret; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1211 | } |
| 1212 | |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1213 | static size_t qc_snd_buf(struct conn_stream *cs, struct buffer *buf, |
| 1214 | size_t count, int flags) |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1215 | { |
Christopher Faulet | db90f2a | 2022-03-22 16:06:25 +0100 | [diff] [blame] | 1216 | struct qcs *qcs = __cs_mux(cs); |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 1217 | size_t ret; |
| 1218 | |
| 1219 | TRACE_ENTER(QMUX_EV_STRM_SEND, qcs->qcc->conn, qcs); |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1220 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 1221 | ret = qcs->qcc->app_ops->snd_buf(cs, buf, count, flags); |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1222 | |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 1223 | TRACE_LEAVE(QMUX_EV_STRM_SEND, qcs->qcc->conn, qcs); |
| 1224 | |
| 1225 | return ret; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1226 | } |
| 1227 | |
| 1228 | /* Called from the upper layer, to subscribe <es> to events <event_type>. The |
| 1229 | * event subscriber <es> is not allowed to change from a previous call as long |
| 1230 | * as at least one event is still subscribed. The <event_type> must only be a |
| 1231 | * combination of SUB_RETRY_RECV and SUB_RETRY_SEND. It always returns 0. |
| 1232 | */ |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1233 | static int qc_subscribe(struct conn_stream *cs, int event_type, |
| 1234 | struct wait_event *es) |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1235 | { |
Christopher Faulet | db90f2a | 2022-03-22 16:06:25 +0100 | [diff] [blame] | 1236 | return qcs_subscribe(__cs_mux(cs), event_type, es); |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1237 | } |
| 1238 | |
| 1239 | /* Called from the upper layer, to unsubscribe <es> from events <event_type>. |
| 1240 | * The <es> pointer is not allowed to differ from the one passed to the |
| 1241 | * subscribe() call. It always returns zero. |
| 1242 | */ |
| 1243 | static int qc_unsubscribe(struct conn_stream *cs, int event_type, struct wait_event *es) |
| 1244 | { |
Christopher Faulet | db90f2a | 2022-03-22 16:06:25 +0100 | [diff] [blame] | 1245 | struct qcs *qcs = __cs_mux(cs); |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1246 | |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1247 | BUG_ON(event_type & ~(SUB_RETRY_SEND|SUB_RETRY_RECV)); |
| 1248 | BUG_ON(qcs->subs && qcs->subs != es); |
| 1249 | |
| 1250 | es->events &= ~event_type; |
| 1251 | if (!es->events) |
| 1252 | qcs->subs = NULL; |
| 1253 | |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1254 | return 0; |
| 1255 | } |
| 1256 | |
Amaury Denoyelle | fe035ec | 2022-04-06 15:46:30 +0200 | [diff] [blame] | 1257 | /* Loop through all qcs from <qcc>. If CO_FL_ERROR is set on the connection, |
Christopher Faulet | b041b23 | 2022-03-24 10:27:02 +0100 | [diff] [blame] | 1258 | * report CS_EP_ERR_PENDING|CS_EP_ERROR on the attached conn-streams and wake |
Amaury Denoyelle | fe035ec | 2022-04-06 15:46:30 +0200 | [diff] [blame] | 1259 | * them. |
| 1260 | */ |
| 1261 | static int qc_wake_some_streams(struct qcc *qcc) |
| 1262 | { |
Amaury Denoyelle | fe035ec | 2022-04-06 15:46:30 +0200 | [diff] [blame] | 1263 | struct qcs *qcs; |
| 1264 | struct eb64_node *node; |
| 1265 | |
| 1266 | for (node = eb64_first(&qcc->streams_by_id); node; |
| 1267 | node = eb64_next(node)) { |
Amaury Denoyelle | e4301da | 2022-04-19 17:59:50 +0200 | [diff] [blame^] | 1268 | qcs = eb64_entry(node, struct qcs, by_id); |
Amaury Denoyelle | fe035ec | 2022-04-06 15:46:30 +0200 | [diff] [blame] | 1269 | |
| 1270 | if (!qcs->cs) |
| 1271 | continue; |
| 1272 | |
| 1273 | if (qcc->conn->flags & CO_FL_ERROR) { |
Christopher Faulet | b041b23 | 2022-03-24 10:27:02 +0100 | [diff] [blame] | 1274 | qcs->endp->flags |= CS_EP_ERR_PENDING; |
| 1275 | if (qcs->endp->flags & CS_EP_EOS) |
| 1276 | qcs->endp->flags |= CS_EP_ERROR; |
Amaury Denoyelle | fe035ec | 2022-04-06 15:46:30 +0200 | [diff] [blame] | 1277 | |
| 1278 | if (qcs->subs) { |
| 1279 | qcs_notify_recv(qcs); |
| 1280 | qcs_notify_send(qcs); |
| 1281 | } |
| 1282 | else if (qcs->cs->data_cb->wake) { |
| 1283 | qcs->cs->data_cb->wake(qcs->cs); |
| 1284 | } |
| 1285 | } |
| 1286 | } |
| 1287 | |
| 1288 | return 0; |
| 1289 | } |
| 1290 | |
Amaury Denoyelle | 0e0969d | 2022-01-31 15:41:14 +0100 | [diff] [blame] | 1291 | static int qc_wake(struct connection *conn) |
| 1292 | { |
| 1293 | struct qcc *qcc = conn->ctx; |
Willy Tarreau | 784b868 | 2022-04-11 14:18:10 +0200 | [diff] [blame] | 1294 | struct proxy *prx = conn->handle.qc->li->bind_conf->frontend; |
Amaury Denoyelle | d97fc80 | 2022-04-06 16:13:09 +0200 | [diff] [blame] | 1295 | |
| 1296 | TRACE_ENTER(QMUX_EV_QCC_WAKE, conn); |
Amaury Denoyelle | 0e0969d | 2022-01-31 15:41:14 +0100 | [diff] [blame] | 1297 | |
| 1298 | /* Check if a soft-stop is in progress. |
| 1299 | * Release idling front connection if this is the case. |
Amaury Denoyelle | d97fc80 | 2022-04-06 16:13:09 +0200 | [diff] [blame] | 1300 | * |
| 1301 | * TODO this is revelant for frontend connections only. |
Amaury Denoyelle | 0e0969d | 2022-01-31 15:41:14 +0100 | [diff] [blame] | 1302 | */ |
Amaury Denoyelle | d97fc80 | 2022-04-06 16:13:09 +0200 | [diff] [blame] | 1303 | if (unlikely(prx->flags & (PR_FL_DISABLED|PR_FL_STOPPED))) |
| 1304 | goto release; |
| 1305 | |
Willy Tarreau | 784b868 | 2022-04-11 14:18:10 +0200 | [diff] [blame] | 1306 | if (conn->handle.qc->flags & QUIC_FL_CONN_NOTIFY_CLOSE) |
Amaury Denoyelle | b515b0a | 2022-04-06 10:28:43 +0200 | [diff] [blame] | 1307 | qcc->conn->flags |= (CO_FL_SOCK_RD_SH|CO_FL_SOCK_WR_SH); |
| 1308 | |
Amaury Denoyelle | d97fc80 | 2022-04-06 16:13:09 +0200 | [diff] [blame] | 1309 | qc_send(qcc); |
| 1310 | |
Amaury Denoyelle | fe035ec | 2022-04-06 15:46:30 +0200 | [diff] [blame] | 1311 | qc_wake_some_streams(qcc); |
| 1312 | |
Amaury Denoyelle | d97fc80 | 2022-04-06 16:13:09 +0200 | [diff] [blame] | 1313 | if (qcc_is_dead(qcc)) |
| 1314 | goto release; |
| 1315 | |
| 1316 | TRACE_LEAVE(QMUX_EV_QCC_WAKE, conn); |
| 1317 | |
| 1318 | return 0; |
Amaury Denoyelle | 0e0969d | 2022-01-31 15:41:14 +0100 | [diff] [blame] | 1319 | |
Amaury Denoyelle | d97fc80 | 2022-04-06 16:13:09 +0200 | [diff] [blame] | 1320 | release: |
| 1321 | qc_release(qcc); |
| 1322 | TRACE_DEVEL("leaving after releasing the connection", QMUX_EV_QCC_WAKE); |
Amaury Denoyelle | 0e0969d | 2022-01-31 15:41:14 +0100 | [diff] [blame] | 1323 | return 1; |
| 1324 | } |
| 1325 | |
Amaury Denoyelle | dd4fbfb | 2022-03-24 16:09:16 +0100 | [diff] [blame] | 1326 | |
Amaury Denoyelle | fa29f33 | 2022-03-25 09:09:40 +0100 | [diff] [blame] | 1327 | static void qmux_trace_frm(const struct quic_frame *frm) |
| 1328 | { |
| 1329 | switch (frm->type) { |
| 1330 | case QUIC_FT_MAX_STREAMS_BIDI: |
| 1331 | chunk_appendf(&trace_buf, " max_streams=%lu", |
| 1332 | frm->max_streams_bidi.max_streams); |
| 1333 | break; |
| 1334 | |
| 1335 | case QUIC_FT_MAX_STREAMS_UNI: |
| 1336 | chunk_appendf(&trace_buf, " max_streams=%lu", |
| 1337 | frm->max_streams_uni.max_streams); |
| 1338 | break; |
| 1339 | |
| 1340 | default: |
| 1341 | break; |
| 1342 | } |
| 1343 | } |
| 1344 | |
Amaury Denoyelle | dd4fbfb | 2022-03-24 16:09:16 +0100 | [diff] [blame] | 1345 | /* quic-mux trace handler */ |
| 1346 | static void qmux_trace(enum trace_level level, uint64_t mask, |
| 1347 | const struct trace_source *src, |
| 1348 | const struct ist where, const struct ist func, |
| 1349 | const void *a1, const void *a2, const void *a3, const void *a4) |
| 1350 | { |
| 1351 | const struct connection *conn = a1; |
| 1352 | const struct qcc *qcc = conn ? conn->ctx : NULL; |
| 1353 | const struct qcs *qcs = a2; |
| 1354 | |
| 1355 | if (!qcc) |
| 1356 | return; |
| 1357 | |
| 1358 | if (src->verbosity > QMUX_VERB_CLEAN) { |
| 1359 | chunk_appendf(&trace_buf, " : qcc=%p(F)", qcc); |
| 1360 | |
| 1361 | if (qcs) |
Amaury Denoyelle | d8e680c | 2022-03-29 15:18:44 +0200 | [diff] [blame] | 1362 | chunk_appendf(&trace_buf, " qcs=%p(%lu)", qcs, qcs->id); |
Amaury Denoyelle | 4f13757 | 2022-03-24 17:10:00 +0100 | [diff] [blame] | 1363 | |
| 1364 | if (mask & QMUX_EV_QCC_NQCS) { |
| 1365 | const uint64_t *id = a3; |
| 1366 | chunk_appendf(&trace_buf, " id=%lu", *id); |
| 1367 | } |
Amaury Denoyelle | fa29f33 | 2022-03-25 09:09:40 +0100 | [diff] [blame] | 1368 | |
| 1369 | if (mask & QMUX_EV_SEND_FRM) |
| 1370 | qmux_trace_frm(a3); |
Amaury Denoyelle | fdcec36 | 2022-03-25 09:28:10 +0100 | [diff] [blame] | 1371 | |
Amaury Denoyelle | da6ad20 | 2022-04-12 11:41:04 +0200 | [diff] [blame] | 1372 | if (mask & QMUX_EV_QCS_XFER_DATA) { |
| 1373 | const struct qcs_xfer_data_trace_arg *arg = a3; |
| 1374 | chunk_appendf(&trace_buf, " prep=%lu xfer=%d", |
| 1375 | arg->prep, arg->xfer); |
| 1376 | } |
| 1377 | |
| 1378 | if (mask & QMUX_EV_QCS_BUILD_STRM) { |
| 1379 | const struct qcs_build_stream_trace_arg *arg = a3; |
| 1380 | chunk_appendf(&trace_buf, " len=%lu fin=%d offset=%lu", |
| 1381 | arg->len, arg->fin, arg->offset); |
Amaury Denoyelle | fdcec36 | 2022-03-25 09:28:10 +0100 | [diff] [blame] | 1382 | } |
Amaury Denoyelle | dd4fbfb | 2022-03-24 16:09:16 +0100 | [diff] [blame] | 1383 | } |
| 1384 | } |
| 1385 | |
Amaury Denoyelle | 251eadf | 2022-03-24 17:14:52 +0100 | [diff] [blame] | 1386 | /* Function to automatically activate QUIC MUX traces on stdout. |
| 1387 | * Activated via the compilation flag -DENABLE_QUIC_STDOUT_TRACES. |
| 1388 | * Main use for now is in the docker image for QUIC interop testing. |
| 1389 | */ |
| 1390 | static void qmux_init_stdout_traces(void) |
| 1391 | { |
| 1392 | #ifdef ENABLE_QUIC_STDOUT_TRACES |
| 1393 | trace_qmux.sink = sink_find("stdout"); |
| 1394 | trace_qmux.level = TRACE_LEVEL_DEVELOPER; |
| 1395 | trace_qmux.state = TRACE_STATE_RUNNING; |
| 1396 | trace_qmux.verbosity = QMUX_VERB_MINIMAL; |
| 1397 | #endif |
| 1398 | } |
| 1399 | INITCALL0(STG_INIT, qmux_init_stdout_traces); |
| 1400 | |
Amaury Denoyelle | dd4fbfb | 2022-03-24 16:09:16 +0100 | [diff] [blame] | 1401 | |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1402 | static const struct mux_ops qc_ops = { |
| 1403 | .init = qc_init, |
Amaury Denoyelle | 2461bd5 | 2022-04-13 16:54:52 +0200 | [diff] [blame] | 1404 | .destroy = qc_destroy, |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1405 | .detach = qc_detach, |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1406 | .rcv_buf = qc_rcv_buf, |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1407 | .snd_buf = qc_snd_buf, |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1408 | .subscribe = qc_subscribe, |
| 1409 | .unsubscribe = qc_unsubscribe, |
Amaury Denoyelle | 0e0969d | 2022-01-31 15:41:14 +0100 | [diff] [blame] | 1410 | .wake = qc_wake, |
Christopher Faulet | a97cced | 2022-04-12 18:04:10 +0200 | [diff] [blame] | 1411 | .flags = MX_FL_HTX|MX_FL_NO_UPG, |
Willy Tarreau | 671bd5a | 2022-04-11 09:29:21 +0200 | [diff] [blame] | 1412 | .name = "QUIC", |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1413 | }; |
| 1414 | |
| 1415 | static struct mux_proto_list mux_proto_quic = |
Amaury Denoyelle | deed777 | 2021-12-03 11:36:46 +0100 | [diff] [blame] | 1416 | { .token = IST("quic"), .mode = PROTO_MODE_HTTP, .side = PROTO_SIDE_FE, .mux = &qc_ops }; |
Frédéric Lécaille | dfbae76 | 2021-02-18 09:59:01 +0100 | [diff] [blame] | 1417 | |
| 1418 | INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_quic); |