Willy Tarreau | 53a4766 | 2017-08-28 10:53:00 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Pass-through mux-demux for connections |
| 3 | * |
| 4 | * Copyright 2017 Willy Tarreau <w@1wt.eu> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | */ |
| 12 | |
| 13 | #include <common/config.h> |
Willy Tarreau | 0108d90 | 2018-11-25 19:14:37 +0100 | [diff] [blame] | 14 | #include <common/initcall.h> |
Willy Tarreau | 53a4766 | 2017-08-28 10:53:00 +0200 | [diff] [blame] | 15 | #include <proto/connection.h> |
| 16 | #include <proto/stream.h> |
Olivier Houchard | b6c32ee | 2018-11-05 18:28:43 +0100 | [diff] [blame] | 17 | #include <proto/task.h> |
| 18 | |
Olivier Houchard | b6c32ee | 2018-11-05 18:28:43 +0100 | [diff] [blame] | 19 | struct mux_pt_ctx { |
| 20 | struct conn_stream *cs; |
| 21 | struct connection *conn; |
| 22 | struct wait_event wait_event; |
| 23 | }; |
| 24 | |
Willy Tarreau | 8ceae72 | 2018-11-26 11:58:30 +0100 | [diff] [blame] | 25 | DECLARE_STATIC_POOL(pool_head_pt_ctx, "mux_pt", sizeof(struct mux_pt_ctx)); |
| 26 | |
Olivier Houchard | b6c32ee | 2018-11-05 18:28:43 +0100 | [diff] [blame] | 27 | static void mux_pt_destroy(struct mux_pt_ctx *ctx) |
| 28 | { |
| 29 | struct connection *conn = ctx->conn; |
| 30 | |
| 31 | LIST_DEL(&conn->list); |
| 32 | conn_stop_tracking(conn); |
| 33 | conn_full_close(conn); |
Olivier Houchard | 7c6f8b1 | 2018-11-13 16:48:36 +0100 | [diff] [blame] | 34 | tasklet_free(ctx->wait_event.task); |
| 35 | conn->mux = NULL; |
| 36 | conn->mux_ctx = NULL; |
Olivier Houchard | b6c32ee | 2018-11-05 18:28:43 +0100 | [diff] [blame] | 37 | if (conn->destroy_cb) |
| 38 | conn->destroy_cb(conn); |
| 39 | /* We don't bother unsubscribing here, as we're about to destroy |
| 40 | * both the connection and the mux_pt_ctx |
| 41 | */ |
| 42 | conn_free(conn); |
| 43 | pool_free(pool_head_pt_ctx, ctx); |
| 44 | } |
| 45 | |
| 46 | /* Callback, used when we get I/Os while in idle mode */ |
| 47 | static struct task *mux_pt_io_cb(struct task *t, void *tctx, unsigned short status) |
| 48 | { |
| 49 | struct mux_pt_ctx *ctx = tctx; |
| 50 | |
| 51 | conn_sock_drain(ctx->conn); |
Olivier Houchard | 7c6f8b1 | 2018-11-13 16:48:36 +0100 | [diff] [blame] | 52 | if (ctx->conn->flags & (CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH)) |
Olivier Houchard | b6c32ee | 2018-11-05 18:28:43 +0100 | [diff] [blame] | 53 | mux_pt_destroy(ctx); |
| 54 | else |
| 55 | ctx->conn->xprt->subscribe(ctx->conn, SUB_CAN_RECV, |
| 56 | &ctx->wait_event); |
| 57 | |
| 58 | return NULL; |
| 59 | } |
Willy Tarreau | 53a4766 | 2017-08-28 10:53:00 +0200 | [diff] [blame] | 60 | |
Olivier Houchard | 9aaf778 | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 61 | /* Initialize the mux once it's attached. It is expected that conn->mux_ctx |
| 62 | * points to the existing conn_stream (for outgoing connections) or NULL (for |
| 63 | * incoming ones, in which case one will be allocated and a new stream will be |
| 64 | * instanciated). Returns < 0 on error. |
Willy Tarreau | 53a4766 | 2017-08-28 10:53:00 +0200 | [diff] [blame] | 65 | */ |
Willy Tarreau | 175a2bb | 2018-09-12 12:02:05 +0200 | [diff] [blame] | 66 | static int mux_pt_init(struct connection *conn, struct proxy *prx) |
Willy Tarreau | 53a4766 | 2017-08-28 10:53:00 +0200 | [diff] [blame] | 67 | { |
Olivier Houchard | 9aaf778 | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 68 | struct conn_stream *cs = conn->mux_ctx; |
Olivier Houchard | b6c32ee | 2018-11-05 18:28:43 +0100 | [diff] [blame] | 69 | struct mux_pt_ctx *ctx = pool_alloc(pool_head_pt_ctx); |
| 70 | |
| 71 | if (!ctx) |
| 72 | goto fail; |
| 73 | |
| 74 | ctx->wait_event.task = tasklet_new(); |
| 75 | if (!ctx->wait_event.task) |
| 76 | goto fail_free_ctx; |
| 77 | ctx->wait_event.task->context = ctx; |
| 78 | ctx->wait_event.task->process = mux_pt_io_cb; |
| 79 | ctx->wait_event.wait_reason = 0; |
| 80 | ctx->conn = conn; |
Olivier Houchard | 9aaf778 | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 81 | |
| 82 | if (!cs) { |
| 83 | cs = cs_new(conn); |
| 84 | if (!cs) |
Olivier Houchard | b6c32ee | 2018-11-05 18:28:43 +0100 | [diff] [blame] | 85 | goto fail_free_ctx; |
Olivier Houchard | 9aaf778 | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 86 | |
| 87 | if (stream_create_from_cs(cs) < 0) |
| 88 | goto fail_free; |
| 89 | |
Olivier Houchard | 9aaf778 | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 90 | } |
Olivier Houchard | b6c32ee | 2018-11-05 18:28:43 +0100 | [diff] [blame] | 91 | conn->mux_ctx = ctx; |
| 92 | ctx->cs = cs; |
Olivier Houchard | 8706c81 | 2018-12-04 19:17:25 +0100 | [diff] [blame] | 93 | cs->flags |= CS_FL_RCV_MORE; |
Willy Tarreau | 53a4766 | 2017-08-28 10:53:00 +0200 | [diff] [blame] | 94 | return 0; |
Olivier Houchard | 9aaf778 | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 95 | |
| 96 | fail_free: |
| 97 | cs_free(cs); |
Olivier Houchard | b6c32ee | 2018-11-05 18:28:43 +0100 | [diff] [blame] | 98 | fail_free_ctx: |
| 99 | if (ctx->wait_event.task) |
| 100 | tasklet_free(ctx->wait_event.task); |
| 101 | pool_free(pool_head_pt_ctx, ctx); |
Olivier Houchard | 9aaf778 | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 102 | fail: |
| 103 | return -1; |
Willy Tarreau | 53a4766 | 2017-08-28 10:53:00 +0200 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | /* callback to be used by default for the pass-through mux. It calls the data |
| 107 | * layer wake() callback if it is set otherwise returns 0. |
| 108 | */ |
| 109 | static int mux_pt_wake(struct connection *conn) |
| 110 | { |
Olivier Houchard | b6c32ee | 2018-11-05 18:28:43 +0100 | [diff] [blame] | 111 | struct mux_pt_ctx *ctx = conn->mux_ctx; |
| 112 | struct conn_stream *cs = ctx->cs; |
| 113 | int ret = 0; |
Olivier Houchard | 9aaf778 | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 114 | |
Olivier Houchard | b6c32ee | 2018-11-05 18:28:43 +0100 | [diff] [blame] | 115 | if (cs) { |
| 116 | ret = cs->data_cb->wake ? cs->data_cb->wake(cs) : 0; |
Olivier Houchard | 9aaf778 | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 117 | |
Olivier Houchard | b6c32ee | 2018-11-05 18:28:43 +0100 | [diff] [blame] | 118 | if (ret < 0) |
| 119 | return ret; |
| 120 | } else { |
| 121 | conn_sock_drain(conn); |
| 122 | if (conn->flags & (CO_FL_ERROR | CO_FL_SOCK_RD_SH)) { |
| 123 | mux_pt_destroy(ctx); |
| 124 | return -1; |
| 125 | } |
| 126 | } |
Willy Tarreau | ad7f0ad | 2018-08-24 15:48:59 +0200 | [diff] [blame] | 127 | |
Olivier Houchard | 7fc96d5 | 2017-11-23 18:25:47 +0100 | [diff] [blame] | 128 | /* If we had early data, and we're done with the handshake |
| 129 | * then whe know the data are safe, and we can remove the flag. |
| 130 | */ |
| 131 | if ((conn->flags & (CO_FL_EARLY_DATA | CO_FL_EARLY_SSL_HS | CO_FL_HANDSHAKE)) == |
| 132 | CO_FL_EARLY_DATA) |
| 133 | conn->flags &= ~CO_FL_EARLY_DATA; |
Willy Tarreau | ed339a3 | 2017-11-03 15:55:24 +0100 | [diff] [blame] | 134 | return ret; |
Willy Tarreau | 53a4766 | 2017-08-28 10:53:00 +0200 | [diff] [blame] | 135 | } |
| 136 | |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 137 | /* |
| 138 | * Attach a new stream to a connection |
| 139 | * (Used for outgoing connections) |
| 140 | */ |
| 141 | static struct conn_stream *mux_pt_attach(struct connection *conn) |
| 142 | { |
Olivier Houchard | 7c6f8b1 | 2018-11-13 16:48:36 +0100 | [diff] [blame] | 143 | struct conn_stream *cs; |
| 144 | struct mux_pt_ctx *ctx = conn->mux_ctx; |
| 145 | |
Olivier Houchard | 1ced485 | 2018-11-29 13:49:59 +0100 | [diff] [blame] | 146 | conn->xprt->unsubscribe(conn, SUB_CAN_RECV, &ctx->wait_event); |
Olivier Houchard | 7c6f8b1 | 2018-11-13 16:48:36 +0100 | [diff] [blame] | 147 | cs = cs_new(conn); |
| 148 | if (!cs) |
| 149 | goto fail; |
| 150 | |
| 151 | ctx->cs = cs; |
Olivier Houchard | 8706c81 | 2018-12-04 19:17:25 +0100 | [diff] [blame] | 152 | cs->flags |= CS_FL_RCV_MORE; |
Olivier Houchard | 7c6f8b1 | 2018-11-13 16:48:36 +0100 | [diff] [blame] | 153 | return (cs); |
| 154 | fail: |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 155 | return NULL; |
| 156 | } |
| 157 | |
Willy Tarreau | fafd398 | 2018-11-18 21:29:20 +0100 | [diff] [blame] | 158 | /* Retrieves a valid conn_stream from this connection, or returns NULL. For |
| 159 | * this mux, it's easy as we can only store a single conn_stream. |
| 160 | */ |
| 161 | static const struct conn_stream *mux_pt_get_first_cs(const struct connection *conn) |
| 162 | { |
Olivier Houchard | b6c32ee | 2018-11-05 18:28:43 +0100 | [diff] [blame] | 163 | struct mux_pt_ctx *ctx = conn->mux_ctx; |
| 164 | struct conn_stream *cs = ctx->cs; |
Willy Tarreau | fafd398 | 2018-11-18 21:29:20 +0100 | [diff] [blame] | 165 | |
| 166 | return cs; |
| 167 | } |
| 168 | |
Olivier Houchard | 7c6f8b1 | 2018-11-13 16:48:36 +0100 | [diff] [blame] | 169 | /* Destroy the mux and the associated connection, if no longer used */ |
Olivier Houchard | 060ed43 | 2018-11-06 16:32:42 +0100 | [diff] [blame] | 170 | static void mux_pt_destroy_meth(struct connection *conn) |
| 171 | { |
Olivier Houchard | 7c6f8b1 | 2018-11-13 16:48:36 +0100 | [diff] [blame] | 172 | struct mux_pt_ctx *ctx = conn->mux_ctx; |
| 173 | |
| 174 | if (!(ctx->cs)) |
| 175 | mux_pt_destroy(ctx); |
Olivier Houchard | 060ed43 | 2018-11-06 16:32:42 +0100 | [diff] [blame] | 176 | } |
| 177 | |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 178 | /* |
Willy Tarreau | 2c52a2b | 2017-10-08 11:00:17 +0200 | [diff] [blame] | 179 | * Detach the stream from the connection and possibly release the connection. |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 180 | */ |
| 181 | static void mux_pt_detach(struct conn_stream *cs) |
| 182 | { |
Willy Tarreau | 2c52a2b | 2017-10-08 11:00:17 +0200 | [diff] [blame] | 183 | struct connection *conn = cs->conn; |
Olivier Houchard | b6c32ee | 2018-11-05 18:28:43 +0100 | [diff] [blame] | 184 | struct mux_pt_ctx *ctx = cs->conn->mux_ctx; |
Willy Tarreau | 2c52a2b | 2017-10-08 11:00:17 +0200 | [diff] [blame] | 185 | |
Olivier Houchard | b6c32ee | 2018-11-05 18:28:43 +0100 | [diff] [blame] | 186 | /* Subscribe, to know if we got disconnected */ |
Olivier Houchard | 7c6f8b1 | 2018-11-13 16:48:36 +0100 | [diff] [blame] | 187 | if (conn->owner != NULL && |
| 188 | !(conn->flags & (CO_FL_ERROR | CO_FL_SOCK_RD_SH | CO_FL_SOCK_WR_SH))) { |
| 189 | ctx->cs = NULL; |
| 190 | conn->xprt->subscribe(conn, SUB_CAN_RECV, &ctx->wait_event); |
| 191 | } else |
| 192 | /* There's no session attached to that connection, destroy it */ |
| 193 | mux_pt_destroy(ctx); |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 194 | } |
| 195 | |
Olivier Houchard | d540b36 | 2018-11-05 18:37:53 +0100 | [diff] [blame] | 196 | static int mux_pt_avail_streams(struct connection *conn) |
| 197 | { |
| 198 | struct mux_pt_ctx *ctx = conn->mux_ctx; |
| 199 | |
| 200 | return (ctx->cs == NULL ? 1 : 0); |
| 201 | } |
| 202 | |
Olivier Houchard | 8defe4b | 2018-12-02 01:31:17 +0100 | [diff] [blame] | 203 | static int mux_pt_max_streams(struct connection *conn) |
| 204 | { |
| 205 | return 1; |
| 206 | } |
| 207 | |
Willy Tarreau | ecdb3fe | 2017-10-05 15:25:48 +0200 | [diff] [blame] | 208 | static void mux_pt_shutr(struct conn_stream *cs, enum cs_shr_mode mode) |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 209 | { |
Willy Tarreau | 4b79524 | 2017-10-05 18:47:38 +0200 | [diff] [blame] | 210 | if (cs->flags & CS_FL_SHR) |
| 211 | return; |
Olivier Houchard | 8706c81 | 2018-12-04 19:17:25 +0100 | [diff] [blame] | 212 | cs->flags &= ~CS_FL_RCV_MORE; |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 213 | if (conn_xprt_ready(cs->conn) && cs->conn->xprt->shutr) |
Willy Tarreau | ecdb3fe | 2017-10-05 15:25:48 +0200 | [diff] [blame] | 214 | cs->conn->xprt->shutr(cs->conn, (mode == CS_SHR_DRAIN)); |
Willy Tarreau | 4b79524 | 2017-10-05 18:47:38 +0200 | [diff] [blame] | 215 | if (cs->flags & CS_FL_SHW) |
| 216 | conn_full_close(cs->conn); |
Olivier Houchard | 7c6f8b1 | 2018-11-13 16:48:36 +0100 | [diff] [blame] | 217 | /* Maybe we've been put in the list of available idle connections, |
| 218 | * get ouf of here |
| 219 | */ |
| 220 | LIST_DEL(&cs->conn->list); |
| 221 | LIST_INIT(&cs->conn->list); |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 222 | } |
| 223 | |
Willy Tarreau | ecdb3fe | 2017-10-05 15:25:48 +0200 | [diff] [blame] | 224 | static void mux_pt_shutw(struct conn_stream *cs, enum cs_shw_mode mode) |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 225 | { |
Willy Tarreau | 4b79524 | 2017-10-05 18:47:38 +0200 | [diff] [blame] | 226 | if (cs->flags & CS_FL_SHW) |
| 227 | return; |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 228 | if (conn_xprt_ready(cs->conn) && cs->conn->xprt->shutw) |
Willy Tarreau | ecdb3fe | 2017-10-05 15:25:48 +0200 | [diff] [blame] | 229 | cs->conn->xprt->shutw(cs->conn, (mode == CS_SHW_NORMAL)); |
Willy Tarreau | 4b79524 | 2017-10-05 18:47:38 +0200 | [diff] [blame] | 230 | if (!(cs->flags & CS_FL_SHR)) |
Willy Tarreau | a48c141 | 2017-12-22 18:46:33 +0100 | [diff] [blame] | 231 | conn_sock_shutw(cs->conn, (mode == CS_SHW_NORMAL)); |
Willy Tarreau | 4b79524 | 2017-10-05 18:47:38 +0200 | [diff] [blame] | 232 | else |
| 233 | conn_full_close(cs->conn); |
Olivier Houchard | 7c6f8b1 | 2018-11-13 16:48:36 +0100 | [diff] [blame] | 234 | /* Maybe we've been put in the list of available idle connections, |
| 235 | * get ouf of here |
| 236 | */ |
| 237 | LIST_DEL(&cs->conn->list); |
| 238 | LIST_INIT(&cs->conn->list); |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | /* |
| 242 | * Called from the upper layer, to get more data |
| 243 | */ |
Willy Tarreau | 7f3225f | 2018-06-19 06:15:17 +0200 | [diff] [blame] | 244 | static size_t mux_pt_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags) |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 245 | { |
Willy Tarreau | d9cf540 | 2018-07-18 11:29:06 +0200 | [diff] [blame] | 246 | size_t ret; |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 247 | |
Christopher Faulet | 4eb7d74 | 2018-10-11 15:29:21 +0200 | [diff] [blame] | 248 | if (!count) { |
| 249 | cs->flags |= CS_FL_RCV_MORE; |
| 250 | return 0; |
| 251 | } |
Willy Tarreau | 7f3225f | 2018-06-19 06:15:17 +0200 | [diff] [blame] | 252 | ret = cs->conn->xprt->rcv_buf(cs->conn, buf, count, flags); |
Olivier Houchard | 8706c81 | 2018-12-04 19:17:25 +0100 | [diff] [blame] | 253 | if (conn_xprt_read0_pending(cs->conn)) { |
| 254 | if (ret == 0) |
| 255 | cs->flags &= ~CS_FL_RCV_MORE; |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 256 | cs->flags |= CS_FL_EOS; |
Olivier Houchard | 8706c81 | 2018-12-04 19:17:25 +0100 | [diff] [blame] | 257 | } |
| 258 | if (cs->conn->flags & CO_FL_ERROR) { |
| 259 | if (ret == 0) |
| 260 | cs->flags &= ~CS_FL_RCV_MORE; |
Willy Tarreau | 4ff3b89 | 2017-10-16 15:17:17 +0200 | [diff] [blame] | 261 | cs->flags |= CS_FL_ERROR; |
Olivier Houchard | 8706c81 | 2018-12-04 19:17:25 +0100 | [diff] [blame] | 262 | } |
Willy Tarreau | d9cf540 | 2018-07-18 11:29:06 +0200 | [diff] [blame] | 263 | return ret; |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | /* Called from the upper layer, to send data */ |
Christopher Faulet | d44a9b3 | 2018-07-27 11:59:41 +0200 | [diff] [blame] | 267 | static size_t mux_pt_snd_buf(struct conn_stream *cs, struct buffer *buf, size_t count, int flags) |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 268 | { |
Olivier Houchard | b72d98a | 2018-11-30 13:17:48 +0100 | [diff] [blame] | 269 | size_t ret; |
| 270 | |
| 271 | if (cs->conn->flags & CO_FL_HANDSHAKE) |
| 272 | return 0; |
| 273 | ret = cs->conn->xprt->snd_buf(cs->conn, buf, count, flags); |
Christopher Faulet | d44a9b3 | 2018-07-27 11:59:41 +0200 | [diff] [blame] | 274 | |
| 275 | if (ret > 0) |
| 276 | b_del(buf, ret); |
| 277 | return ret; |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 278 | } |
| 279 | |
Olivier Houchard | 6ff2039 | 2018-07-17 18:46:31 +0200 | [diff] [blame] | 280 | /* Called from the upper layer, to subscribe to events */ |
| 281 | static int mux_pt_subscribe(struct conn_stream *cs, int event_type, void *param) |
| 282 | { |
| 283 | return (cs->conn->xprt->subscribe(cs->conn, event_type, param)); |
| 284 | } |
| 285 | |
Olivier Houchard | 83a0cd8 | 2018-09-28 17:57:58 +0200 | [diff] [blame] | 286 | static int mux_pt_unsubscribe(struct conn_stream *cs, int event_type, void *param) |
| 287 | { |
| 288 | return (cs->conn->xprt->unsubscribe(cs->conn, event_type, param)); |
| 289 | } |
| 290 | |
Olivier Houchard | 7da120b | 2017-11-01 13:55:10 +0100 | [diff] [blame] | 291 | #if defined(CONFIG_HAP_LINUX_SPLICE) |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 292 | /* Send and get, using splicing */ |
| 293 | static int mux_pt_rcv_pipe(struct conn_stream *cs, struct pipe *pipe, unsigned int count) |
| 294 | { |
| 295 | int ret; |
| 296 | |
| 297 | ret = cs->conn->xprt->rcv_pipe(cs->conn, pipe, count); |
| 298 | if (conn_xprt_read0_pending(cs->conn)) |
| 299 | cs->flags |= CS_FL_EOS; |
Willy Tarreau | 4ff3b89 | 2017-10-16 15:17:17 +0200 | [diff] [blame] | 300 | if (cs->conn->flags & CO_FL_ERROR) |
| 301 | cs->flags |= CS_FL_ERROR; |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 302 | return (ret); |
| 303 | } |
| 304 | |
| 305 | static int mux_pt_snd_pipe(struct conn_stream *cs, struct pipe *pipe) |
| 306 | { |
| 307 | return (cs->conn->xprt->snd_pipe(cs->conn, pipe)); |
| 308 | } |
Olivier Houchard | 7da120b | 2017-11-01 13:55:10 +0100 | [diff] [blame] | 309 | #endif |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 310 | |
Willy Tarreau | 53a4766 | 2017-08-28 10:53:00 +0200 | [diff] [blame] | 311 | /* The mux operations */ |
| 312 | const struct mux_ops mux_pt_ops = { |
| 313 | .init = mux_pt_init, |
Willy Tarreau | 53a4766 | 2017-08-28 10:53:00 +0200 | [diff] [blame] | 314 | .wake = mux_pt_wake, |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 315 | .rcv_buf = mux_pt_rcv_buf, |
| 316 | .snd_buf = mux_pt_snd_buf, |
Olivier Houchard | 6ff2039 | 2018-07-17 18:46:31 +0200 | [diff] [blame] | 317 | .subscribe = mux_pt_subscribe, |
Olivier Houchard | 83a0cd8 | 2018-09-28 17:57:58 +0200 | [diff] [blame] | 318 | .unsubscribe = mux_pt_unsubscribe, |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 319 | #if defined(CONFIG_HAP_LINUX_SPLICE) |
| 320 | .rcv_pipe = mux_pt_rcv_pipe, |
| 321 | .snd_pipe = mux_pt_snd_pipe, |
| 322 | #endif |
| 323 | .attach = mux_pt_attach, |
Willy Tarreau | fafd398 | 2018-11-18 21:29:20 +0100 | [diff] [blame] | 324 | .get_first_cs = mux_pt_get_first_cs, |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 325 | .detach = mux_pt_detach, |
Olivier Houchard | d540b36 | 2018-11-05 18:37:53 +0100 | [diff] [blame] | 326 | .avail_streams = mux_pt_avail_streams, |
Olivier Houchard | 8defe4b | 2018-12-02 01:31:17 +0100 | [diff] [blame] | 327 | .max_streams = mux_pt_max_streams, |
Olivier Houchard | 060ed43 | 2018-11-06 16:32:42 +0100 | [diff] [blame] | 328 | .destroy = mux_pt_destroy_meth, |
Olivier Houchard | 7a3f0df | 2017-09-13 18:30:23 +0200 | [diff] [blame] | 329 | .shutr = mux_pt_shutr, |
| 330 | .shutw = mux_pt_shutw, |
Willy Tarreau | 28f1cb9 | 2017-12-20 16:14:44 +0100 | [diff] [blame] | 331 | .flags = MX_FL_NONE, |
Willy Tarreau | 53a4766 | 2017-08-28 10:53:00 +0200 | [diff] [blame] | 332 | .name = "PASS", |
| 333 | }; |
Willy Tarreau | f649082 | 2017-09-21 19:43:21 +0200 | [diff] [blame] | 334 | |
Christopher Faulet | 32f61c0 | 2018-04-10 14:33:41 +0200 | [diff] [blame] | 335 | /* PROT selection : default mux has empty name */ |
| 336 | static struct mux_proto_list mux_proto_pt = |
| 337 | { .token = IST(""), .mode = PROTO_MODE_ANY, .side = PROTO_SIDE_BOTH, .mux = &mux_pt_ops }; |
Willy Tarreau | f649082 | 2017-09-21 19:43:21 +0200 | [diff] [blame] | 338 | |
Willy Tarreau | 0108d90 | 2018-11-25 19:14:37 +0100 | [diff] [blame] | 339 | INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_pt); |