Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 1 | /* |
| 2 | * AF_INET/AF_INET6 QUIC protocol layer. |
| 3 | * |
Willy Tarreau | 3dfb7da | 2022-03-02 22:33:39 +0100 | [diff] [blame] | 4 | * Copyright 2020 Frederic Lecaille <flecaille@haproxy.com> |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 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 <ctype.h> |
| 14 | #include <errno.h> |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 15 | #include <stdio.h> |
| 16 | #include <stdlib.h> |
| 17 | #include <string.h> |
| 18 | #include <time.h> |
| 19 | |
| 20 | #include <sys/param.h> |
| 21 | #include <sys/socket.h> |
| 22 | #include <sys/types.h> |
| 23 | |
| 24 | #include <netinet/udp.h> |
| 25 | #include <netinet/in.h> |
| 26 | |
Amaury Denoyelle | 5c25dc5 | 2022-09-30 17:44:15 +0200 | [diff] [blame] | 27 | #include <import/ebtree-t.h> |
| 28 | |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 29 | #include <haproxy/api.h> |
| 30 | #include <haproxy/arg.h> |
Frédéric Lécaille | 48f8e19 | 2021-07-06 15:39:26 +0200 | [diff] [blame] | 31 | #include <haproxy/cbuf.h> |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 32 | #include <haproxy/connection.h> |
| 33 | #include <haproxy/errors.h> |
| 34 | #include <haproxy/fd.h> |
| 35 | #include <haproxy/global.h> |
| 36 | #include <haproxy/list.h> |
| 37 | #include <haproxy/listener.h> |
| 38 | #include <haproxy/log.h> |
| 39 | #include <haproxy/namespace.h> |
| 40 | #include <haproxy/port_range.h> |
| 41 | #include <haproxy/protocol.h> |
| 42 | #include <haproxy/proto_quic.h> |
| 43 | #include <haproxy/proto_udp.h> |
| 44 | #include <haproxy/proxy-t.h> |
Amaury Denoyelle | 92fa63f | 2022-09-30 18:11:13 +0200 | [diff] [blame] | 45 | #include <haproxy/quic_conn.h> |
Frédéric Lécaille | 70da889 | 2020-11-06 15:49:49 +0100 | [diff] [blame] | 46 | #include <haproxy/quic_sock.h> |
Amaury Denoyelle | 5c25dc5 | 2022-09-30 17:44:15 +0200 | [diff] [blame] | 47 | #include <haproxy/sock.h> |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 48 | #include <haproxy/sock_inet.h> |
Amaury Denoyelle | 5c25dc5 | 2022-09-30 17:44:15 +0200 | [diff] [blame] | 49 | #include <haproxy/task.h> |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 50 | #include <haproxy/tools.h> |
| 51 | |
Amaury Denoyelle | 8524f0f | 2022-02-08 15:03:40 +0100 | [diff] [blame] | 52 | /* per-thread quic datagram handlers */ |
| 53 | struct quic_dghdlr *quic_dghdlrs; |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 54 | |
Frédéric Lécaille | 71f3abb | 2022-02-15 16:59:48 +0100 | [diff] [blame] | 55 | /* Size of the internal buffer of QUIC RX buffer at the fd level */ |
| 56 | #define QUIC_RX_BUFSZ (1UL << 18) |
| 57 | |
Willy Tarreau | b8dec4a | 2022-06-23 11:02:08 +0200 | [diff] [blame] | 58 | DECLARE_STATIC_POOL(pool_head_quic_rxbuf, "quic_rxbuf", QUIC_RX_BUFSZ); |
Frédéric Lécaille | 71f3abb | 2022-02-15 16:59:48 +0100 | [diff] [blame] | 59 | |
Frédéric Lécaille | 884f2e9 | 2020-11-23 14:23:21 +0100 | [diff] [blame] | 60 | static void quic_add_listener(struct protocol *proto, struct listener *listener); |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 61 | static int quic_bind_listener(struct listener *listener, char *errmsg, int errlen); |
| 62 | static int quic_connect_server(struct connection *conn, int flags); |
| 63 | static void quic_enable_listener(struct listener *listener); |
| 64 | static void quic_disable_listener(struct listener *listener); |
| 65 | |
| 66 | /* Note: must not be declared <const> as its list will be overwritten */ |
| 67 | struct protocol proto_quic4 = { |
| 68 | .name = "quic4", |
| 69 | |
| 70 | /* connection layer */ |
Willy Tarreau | 91b4726 | 2022-05-20 16:36:46 +0200 | [diff] [blame] | 71 | .xprt_type = PROTO_TYPE_STREAM, |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 72 | .listen = quic_bind_listener, |
| 73 | .enable = quic_enable_listener, |
| 74 | .disable = quic_disable_listener, |
Frédéric Lécaille | 884f2e9 | 2020-11-23 14:23:21 +0100 | [diff] [blame] | 75 | .add = quic_add_listener, |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 76 | .unbind = default_unbind_listener, |
| 77 | .suspend = default_suspend_listener, |
| 78 | .resume = default_resume_listener, |
Frédéric Lécaille | 70da889 | 2020-11-06 15:49:49 +0100 | [diff] [blame] | 79 | .accept_conn = quic_sock_accept_conn, |
Willy Tarreau | cdf7c8e | 2022-04-11 16:20:00 +0200 | [diff] [blame] | 80 | .get_src = quic_sock_get_src, |
| 81 | .get_dst = quic_sock_get_dst, |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 82 | .connect = quic_connect_server, |
| 83 | |
| 84 | /* binding layer */ |
| 85 | .rx_suspend = udp_suspend_receiver, |
| 86 | .rx_resume = udp_resume_receiver, |
| 87 | |
| 88 | /* address family */ |
| 89 | .fam = &proto_fam_inet4, |
| 90 | |
| 91 | /* socket layer */ |
Willy Tarreau | 337edfd | 2021-10-27 17:05:36 +0200 | [diff] [blame] | 92 | .proto_type = PROTO_TYPE_DGRAM, |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 93 | .sock_type = SOCK_DGRAM, |
| 94 | .sock_prot = IPPROTO_UDP, |
| 95 | .rx_enable = sock_enable, |
| 96 | .rx_disable = sock_disable, |
| 97 | .rx_unbind = sock_unbind, |
Frédéric Lécaille | 70da889 | 2020-11-06 15:49:49 +0100 | [diff] [blame] | 98 | .rx_listening = quic_sock_accepting_conn, |
Amaury Denoyelle | 5b41486 | 2022-10-24 17:40:37 +0200 | [diff] [blame] | 99 | .default_iocb = quic_lstnr_sock_fd_iocb, |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 100 | .receivers = LIST_HEAD_INIT(proto_quic4.receivers), |
| 101 | .nb_receivers = 0, |
| 102 | }; |
| 103 | |
| 104 | INITCALL1(STG_REGISTER, protocol_register, &proto_quic4); |
| 105 | |
| 106 | /* Note: must not be declared <const> as its list will be overwritten */ |
| 107 | struct protocol proto_quic6 = { |
| 108 | .name = "quic6", |
| 109 | |
| 110 | /* connection layer */ |
Willy Tarreau | 91b4726 | 2022-05-20 16:36:46 +0200 | [diff] [blame] | 111 | .xprt_type = PROTO_TYPE_STREAM, |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 112 | .listen = quic_bind_listener, |
| 113 | .enable = quic_enable_listener, |
| 114 | .disable = quic_disable_listener, |
Frédéric Lécaille | 884f2e9 | 2020-11-23 14:23:21 +0100 | [diff] [blame] | 115 | .add = quic_add_listener, |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 116 | .unbind = default_unbind_listener, |
| 117 | .suspend = default_suspend_listener, |
| 118 | .resume = default_resume_listener, |
Frédéric Lécaille | 70da889 | 2020-11-06 15:49:49 +0100 | [diff] [blame] | 119 | .accept_conn = quic_sock_accept_conn, |
Willy Tarreau | cdf7c8e | 2022-04-11 16:20:00 +0200 | [diff] [blame] | 120 | .get_src = quic_sock_get_src, |
| 121 | .get_dst = quic_sock_get_dst, |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 122 | .connect = quic_connect_server, |
| 123 | |
| 124 | /* binding layer */ |
| 125 | .rx_suspend = udp_suspend_receiver, |
| 126 | .rx_resume = udp_resume_receiver, |
| 127 | |
| 128 | /* address family */ |
| 129 | .fam = &proto_fam_inet6, |
| 130 | |
| 131 | /* socket layer */ |
Willy Tarreau | 337edfd | 2021-10-27 17:05:36 +0200 | [diff] [blame] | 132 | .proto_type = PROTO_TYPE_DGRAM, |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 133 | .sock_type = SOCK_DGRAM, |
| 134 | .sock_prot = IPPROTO_UDP, |
| 135 | .rx_enable = sock_enable, |
| 136 | .rx_disable = sock_disable, |
| 137 | .rx_unbind = sock_unbind, |
Frédéric Lécaille | 70da889 | 2020-11-06 15:49:49 +0100 | [diff] [blame] | 138 | .rx_listening = quic_sock_accepting_conn, |
Amaury Denoyelle | 5b41486 | 2022-10-24 17:40:37 +0200 | [diff] [blame] | 139 | .default_iocb = quic_lstnr_sock_fd_iocb, |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 140 | .receivers = LIST_HEAD_INIT(proto_quic6.receivers), |
| 141 | .nb_receivers = 0, |
| 142 | }; |
| 143 | |
| 144 | INITCALL1(STG_REGISTER, protocol_register, &proto_quic6); |
| 145 | |
| 146 | /* Binds ipv4/ipv6 address <local> to socket <fd>, unless <flags> is set, in which |
| 147 | * case we try to bind <remote>. <flags> is a 2-bit field consisting of : |
| 148 | * - 0 : ignore remote address (may even be a NULL pointer) |
| 149 | * - 1 : use provided address |
| 150 | * - 2 : use provided port |
| 151 | * - 3 : use both |
| 152 | * |
| 153 | * The function supports multiple foreign binding methods : |
| 154 | * - linux_tproxy: we directly bind to the foreign address |
| 155 | * The second one can be used as a fallback for the first one. |
| 156 | * This function returns 0 when everything's OK, 1 if it could not bind, to the |
| 157 | * local address, 2 if it could not bind to the foreign address. |
| 158 | */ |
| 159 | int quic_bind_socket(int fd, int flags, struct sockaddr_storage *local, struct sockaddr_storage *remote) |
| 160 | { |
| 161 | struct sockaddr_storage bind_addr; |
| 162 | int foreign_ok = 0; |
| 163 | int ret; |
| 164 | static THREAD_LOCAL int ip_transp_working = 1; |
| 165 | static THREAD_LOCAL int ip6_transp_working = 1; |
| 166 | |
| 167 | switch (local->ss_family) { |
| 168 | case AF_INET: |
| 169 | if (flags && ip_transp_working) { |
| 170 | /* This deserves some explanation. Some platforms will support |
| 171 | * multiple combinations of certain methods, so we try the |
| 172 | * supported ones until one succeeds. |
| 173 | */ |
| 174 | if (sock_inet4_make_foreign(fd)) |
| 175 | foreign_ok = 1; |
| 176 | else |
| 177 | ip_transp_working = 0; |
| 178 | } |
| 179 | break; |
| 180 | case AF_INET6: |
| 181 | if (flags && ip6_transp_working) { |
| 182 | if (sock_inet6_make_foreign(fd)) |
| 183 | foreign_ok = 1; |
| 184 | else |
| 185 | ip6_transp_working = 0; |
| 186 | } |
| 187 | break; |
| 188 | } |
| 189 | |
| 190 | if (flags) { |
| 191 | memset(&bind_addr, 0, sizeof(bind_addr)); |
| 192 | bind_addr.ss_family = remote->ss_family; |
| 193 | switch (remote->ss_family) { |
| 194 | case AF_INET: |
| 195 | if (flags & 1) |
| 196 | ((struct sockaddr_in *)&bind_addr)->sin_addr = ((struct sockaddr_in *)remote)->sin_addr; |
| 197 | if (flags & 2) |
| 198 | ((struct sockaddr_in *)&bind_addr)->sin_port = ((struct sockaddr_in *)remote)->sin_port; |
| 199 | break; |
| 200 | case AF_INET6: |
| 201 | if (flags & 1) |
| 202 | ((struct sockaddr_in6 *)&bind_addr)->sin6_addr = ((struct sockaddr_in6 *)remote)->sin6_addr; |
| 203 | if (flags & 2) |
| 204 | ((struct sockaddr_in6 *)&bind_addr)->sin6_port = ((struct sockaddr_in6 *)remote)->sin6_port; |
| 205 | break; |
| 206 | default: |
| 207 | /* we don't want to try to bind to an unknown address family */ |
| 208 | foreign_ok = 0; |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)); |
| 213 | if (foreign_ok) { |
| 214 | if (is_inet_addr(&bind_addr)) { |
| 215 | ret = bind(fd, (struct sockaddr *)&bind_addr, get_addr_len(&bind_addr)); |
| 216 | if (ret < 0) |
| 217 | return 2; |
| 218 | } |
| 219 | } |
| 220 | else { |
| 221 | if (is_inet_addr(local)) { |
| 222 | ret = bind(fd, (struct sockaddr *)local, get_addr_len(local)); |
| 223 | if (ret < 0) |
| 224 | return 1; |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | if (!flags) |
| 229 | return 0; |
| 230 | |
| 231 | if (!foreign_ok) |
| 232 | /* we could not bind to a foreign address */ |
| 233 | return 2; |
| 234 | |
| 235 | return 0; |
| 236 | } |
| 237 | |
| 238 | /* |
| 239 | * This function initiates a QUIC connection establishment to the target assigned |
| 240 | * to connection <conn> using (si->{target,dst}). A source address may be |
| 241 | * pointed to by conn->src in case of transparent proxying. Normal source |
| 242 | * bind addresses are still determined locally (due to the possible need of a |
| 243 | * source port). conn->target may point either to a valid server or to a backend, |
| 244 | * depending on conn->target. Only OBJ_TYPE_PROXY and OBJ_TYPE_SERVER are |
| 245 | * supported. The <data> parameter is a boolean indicating whether there are data |
| 246 | * waiting for being sent or not, in order to adjust data write polling and on |
| 247 | * some platforms, the ability to avoid an empty initial ACK. The <flags> argument |
| 248 | * is not used. |
| 249 | * |
| 250 | * Note that a pending send_proxy message accounts for data. |
| 251 | * |
| 252 | * It can return one of : |
| 253 | * - SF_ERR_NONE if everything's OK |
| 254 | * - SF_ERR_SRVTO if there are no more servers |
| 255 | * - SF_ERR_SRVCL if the connection was refused by the server |
| 256 | * - SF_ERR_PRXCOND if the connection has been limited by the proxy (maxconn) |
| 257 | * - SF_ERR_RESOURCE if a system resource is lacking (eg: fd limits, ports, ...) |
| 258 | * - SF_ERR_INTERNAL for any other purely internal errors |
| 259 | * Additionally, in the case of SF_ERR_RESOURCE, an emergency log will be emitted. |
| 260 | * |
| 261 | * The connection's fd is inserted only when SF_ERR_NONE is returned, otherwise |
| 262 | * it's invalid and the caller has nothing to do. |
| 263 | */ |
| 264 | |
| 265 | int quic_connect_server(struct connection *conn, int flags) |
| 266 | { |
| 267 | int fd; |
| 268 | struct server *srv; |
| 269 | struct proxy *be; |
| 270 | struct conn_src *src; |
| 271 | struct sockaddr_storage *addr; |
| 272 | |
Willy Tarreau | 158b6cf | 2022-05-02 17:45:12 +0200 | [diff] [blame] | 273 | BUG_ON(!conn->dst); |
| 274 | |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 275 | conn->flags |= CO_FL_WAIT_L4_CONN; /* connection in progress */ |
| 276 | |
| 277 | switch (obj_type(conn->target)) { |
| 278 | case OBJ_TYPE_PROXY: |
Frédéric Lécaille | e1c3546 | 2022-02-14 19:01:21 +0100 | [diff] [blame] | 279 | be = __objt_proxy(conn->target); |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 280 | srv = NULL; |
| 281 | break; |
| 282 | case OBJ_TYPE_SERVER: |
Frédéric Lécaille | e1c3546 | 2022-02-14 19:01:21 +0100 | [diff] [blame] | 283 | srv = __objt_server(conn->target); |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 284 | be = srv->proxy; |
| 285 | break; |
| 286 | default: |
| 287 | conn->flags |= CO_FL_ERROR; |
| 288 | return SF_ERR_INTERNAL; |
| 289 | } |
| 290 | |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 291 | fd = conn->handle.fd = sock_create_server_socket(conn); |
| 292 | |
| 293 | if (fd == -1) { |
| 294 | qfprintf(stderr, "Cannot get a server socket.\n"); |
| 295 | |
| 296 | if (errno == ENFILE) { |
| 297 | conn->err_code = CO_ER_SYS_FDLIM; |
| 298 | send_log(be, LOG_EMERG, |
| 299 | "Proxy %s reached system FD limit (maxsock=%d). Please check system tunables.\n", |
| 300 | be->id, global.maxsock); |
| 301 | } |
| 302 | else if (errno == EMFILE) { |
| 303 | conn->err_code = CO_ER_PROC_FDLIM; |
| 304 | send_log(be, LOG_EMERG, |
| 305 | "Proxy %s reached process FD limit (maxsock=%d). Please check 'ulimit-n' and restart.\n", |
| 306 | be->id, global.maxsock); |
| 307 | } |
| 308 | else if (errno == ENOBUFS || errno == ENOMEM) { |
| 309 | conn->err_code = CO_ER_SYS_MEMLIM; |
| 310 | send_log(be, LOG_EMERG, |
| 311 | "Proxy %s reached system memory limit (maxsock=%d). Please check system tunables.\n", |
| 312 | be->id, global.maxsock); |
| 313 | } |
| 314 | else if (errno == EAFNOSUPPORT || errno == EPROTONOSUPPORT) { |
| 315 | conn->err_code = CO_ER_NOPROTO; |
| 316 | } |
| 317 | else |
| 318 | conn->err_code = CO_ER_SOCK_ERR; |
| 319 | |
| 320 | /* this is a resource error */ |
| 321 | conn->flags |= CO_FL_ERROR; |
| 322 | return SF_ERR_RESOURCE; |
| 323 | } |
| 324 | |
| 325 | if (fd >= global.maxsock) { |
| 326 | /* do not log anything there, it's a normal condition when this option |
| 327 | * is used to serialize connections to a server ! |
| 328 | */ |
| 329 | ha_alert("socket(): not enough free sockets. Raise -n argument. Giving up.\n"); |
| 330 | close(fd); |
| 331 | conn->err_code = CO_ER_CONF_FDLIM; |
| 332 | conn->flags |= CO_FL_ERROR; |
| 333 | return SF_ERR_PRXCOND; /* it is a configuration limit */ |
| 334 | } |
| 335 | |
Willy Tarreau | 3824743 | 2022-04-26 10:24:14 +0200 | [diff] [blame] | 336 | if (fd_set_nonblock(fd) == -1) { |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 337 | qfprintf(stderr,"Cannot set client socket to non blocking mode.\n"); |
| 338 | close(fd); |
| 339 | conn->err_code = CO_ER_SOCK_ERR; |
| 340 | conn->flags |= CO_FL_ERROR; |
| 341 | return SF_ERR_INTERNAL; |
| 342 | } |
| 343 | |
Willy Tarreau | 3824743 | 2022-04-26 10:24:14 +0200 | [diff] [blame] | 344 | if (master == 1 && fd_set_cloexec(fd) == -1) { |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 345 | ha_alert("Cannot set CLOEXEC on client socket.\n"); |
| 346 | close(fd); |
| 347 | conn->err_code = CO_ER_SOCK_ERR; |
| 348 | conn->flags |= CO_FL_ERROR; |
| 349 | return SF_ERR_INTERNAL; |
| 350 | } |
| 351 | |
| 352 | /* allow specific binding : |
| 353 | * - server-specific at first |
| 354 | * - proxy-specific next |
| 355 | */ |
| 356 | if (srv && srv->conn_src.opts & CO_SRC_BIND) |
| 357 | src = &srv->conn_src; |
| 358 | else if (be->conn_src.opts & CO_SRC_BIND) |
| 359 | src = &be->conn_src; |
| 360 | else |
| 361 | src = NULL; |
| 362 | |
| 363 | if (src) { |
| 364 | int ret, flags = 0; |
| 365 | |
| 366 | if (conn->src && is_inet_addr(conn->src)) { |
| 367 | switch (src->opts & CO_SRC_TPROXY_MASK) { |
| 368 | case CO_SRC_TPROXY_CLI: |
| 369 | conn_set_private(conn); |
Willy Tarreau | 5c8b52f | 2022-11-14 07:02:00 +0100 | [diff] [blame] | 370 | __fallthrough; |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 371 | case CO_SRC_TPROXY_ADDR: |
| 372 | flags = 3; |
| 373 | break; |
| 374 | case CO_SRC_TPROXY_CIP: |
| 375 | case CO_SRC_TPROXY_DYN: |
| 376 | conn_set_private(conn); |
| 377 | flags = 1; |
| 378 | break; |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | #ifdef SO_BINDTODEVICE |
| 383 | /* Note: this might fail if not CAP_NET_RAW */ |
| 384 | if (src->iface_name) |
| 385 | setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, src->iface_name, src->iface_len + 1); |
| 386 | #endif |
| 387 | |
| 388 | if (src->sport_range) { |
| 389 | int attempts = 10; /* should be more than enough to find a spare port */ |
| 390 | struct sockaddr_storage sa; |
| 391 | |
| 392 | ret = 1; |
| 393 | memcpy(&sa, &src->source_addr, sizeof(sa)); |
| 394 | |
| 395 | do { |
| 396 | /* note: in case of retry, we may have to release a previously |
| 397 | * allocated port, hence this loop's construct. |
| 398 | */ |
| 399 | port_range_release_port(fdinfo[fd].port_range, fdinfo[fd].local_port); |
| 400 | fdinfo[fd].port_range = NULL; |
| 401 | |
| 402 | if (!attempts) |
| 403 | break; |
| 404 | attempts--; |
| 405 | |
| 406 | fdinfo[fd].local_port = port_range_alloc_port(src->sport_range); |
| 407 | if (!fdinfo[fd].local_port) { |
| 408 | conn->err_code = CO_ER_PORT_RANGE; |
| 409 | break; |
| 410 | } |
| 411 | |
| 412 | fdinfo[fd].port_range = src->sport_range; |
| 413 | set_host_port(&sa, fdinfo[fd].local_port); |
| 414 | |
| 415 | ret = quic_bind_socket(fd, flags, &sa, conn->src); |
| 416 | if (ret != 0) |
| 417 | conn->err_code = CO_ER_CANT_BIND; |
| 418 | } while (ret != 0); /* binding NOK */ |
| 419 | } |
| 420 | else { |
| 421 | #ifdef IP_BIND_ADDRESS_NO_PORT |
| 422 | static THREAD_LOCAL int bind_address_no_port = 1; |
Willy Tarreau | 4bfc663 | 2021-03-31 08:45:47 +0200 | [diff] [blame] | 423 | setsockopt(fd, IPPROTO_IP, IP_BIND_ADDRESS_NO_PORT, (const void *) &bind_address_no_port, sizeof(int)); |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 424 | #endif |
| 425 | ret = quic_bind_socket(fd, flags, &src->source_addr, conn->src); |
| 426 | if (ret != 0) |
| 427 | conn->err_code = CO_ER_CANT_BIND; |
| 428 | } |
| 429 | |
| 430 | if (unlikely(ret != 0)) { |
| 431 | port_range_release_port(fdinfo[fd].port_range, fdinfo[fd].local_port); |
| 432 | fdinfo[fd].port_range = NULL; |
| 433 | close(fd); |
| 434 | |
| 435 | if (ret == 1) { |
| 436 | ha_alert("Cannot bind to source address before connect() for backend %s. Aborting.\n", |
| 437 | be->id); |
| 438 | send_log(be, LOG_EMERG, |
| 439 | "Cannot bind to source address before connect() for backend %s.\n", |
| 440 | be->id); |
| 441 | } else { |
| 442 | ha_alert("Cannot bind to tproxy source address before connect() for backend %s. Aborting.\n", |
| 443 | be->id); |
| 444 | send_log(be, LOG_EMERG, |
| 445 | "Cannot bind to tproxy source address before connect() for backend %s.\n", |
| 446 | be->id); |
| 447 | } |
| 448 | conn->flags |= CO_FL_ERROR; |
| 449 | return SF_ERR_RESOURCE; |
| 450 | } |
| 451 | } |
| 452 | |
| 453 | if (global.tune.server_sndbuf) |
| 454 | setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &global.tune.server_sndbuf, sizeof(global.tune.server_sndbuf)); |
| 455 | |
| 456 | if (global.tune.server_rcvbuf) |
| 457 | setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &global.tune.server_rcvbuf, sizeof(global.tune.server_rcvbuf)); |
| 458 | |
| 459 | addr = (conn->flags & CO_FL_SOCKS4) ? &srv->socks4_addr : conn->dst; |
| 460 | if (connect(fd, (const struct sockaddr *)addr, get_addr_len(addr)) == -1) { |
| 461 | if (errno == EINPROGRESS || errno == EALREADY) { |
| 462 | /* common case, let's wait for connect status */ |
| 463 | conn->flags |= CO_FL_WAIT_L4_CONN; |
| 464 | } |
| 465 | else if (errno == EISCONN) { |
| 466 | /* should normally not happen but if so, indicates that it's OK */ |
| 467 | conn->flags &= ~CO_FL_WAIT_L4_CONN; |
| 468 | } |
Willy Tarreau | acef5e2 | 2022-04-25 20:32:15 +0200 | [diff] [blame] | 469 | else if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EADDRINUSE || errno == EADDRNOTAVAIL) { |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 470 | char *msg; |
Willy Tarreau | acef5e2 | 2022-04-25 20:32:15 +0200 | [diff] [blame] | 471 | if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EADDRNOTAVAIL) { |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 472 | msg = "no free ports"; |
| 473 | conn->err_code = CO_ER_FREE_PORTS; |
| 474 | } |
| 475 | else { |
| 476 | msg = "local address already in use"; |
| 477 | conn->err_code = CO_ER_ADDR_INUSE; |
| 478 | } |
| 479 | |
| 480 | qfprintf(stderr,"Connect() failed for backend %s: %s.\n", be->id, msg); |
| 481 | port_range_release_port(fdinfo[fd].port_range, fdinfo[fd].local_port); |
| 482 | fdinfo[fd].port_range = NULL; |
| 483 | close(fd); |
| 484 | send_log(be, LOG_ERR, "Connect() failed for backend %s: %s.\n", be->id, msg); |
| 485 | conn->flags |= CO_FL_ERROR; |
| 486 | return SF_ERR_RESOURCE; |
| 487 | } else if (errno == ETIMEDOUT) { |
| 488 | //qfprintf(stderr,"Connect(): ETIMEDOUT"); |
| 489 | port_range_release_port(fdinfo[fd].port_range, fdinfo[fd].local_port); |
| 490 | fdinfo[fd].port_range = NULL; |
| 491 | close(fd); |
| 492 | conn->err_code = CO_ER_SOCK_ERR; |
| 493 | conn->flags |= CO_FL_ERROR; |
| 494 | return SF_ERR_SRVTO; |
| 495 | } else { |
| 496 | // (errno == ECONNREFUSED || errno == ENETUNREACH || errno == EACCES || errno == EPERM) |
| 497 | //qfprintf(stderr,"Connect(): %d", errno); |
| 498 | port_range_release_port(fdinfo[fd].port_range, fdinfo[fd].local_port); |
| 499 | fdinfo[fd].port_range = NULL; |
| 500 | close(fd); |
| 501 | conn->err_code = CO_ER_SOCK_ERR; |
| 502 | conn->flags |= CO_FL_ERROR; |
| 503 | return SF_ERR_SRVCL; |
| 504 | } |
| 505 | } |
| 506 | else { |
| 507 | /* connect() == 0, this is great! */ |
| 508 | conn->flags &= ~CO_FL_WAIT_L4_CONN; |
| 509 | } |
| 510 | |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 511 | conn_ctrl_init(conn); /* registers the FD */ |
Willy Tarreau | b41a6e9 | 2021-04-06 17:49:19 +0200 | [diff] [blame] | 512 | HA_ATOMIC_OR(&fdtab[fd].state, FD_LINGER_RISK); /* close hard if needed */ |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 513 | |
| 514 | if (conn->flags & CO_FL_WAIT_L4_CONN) { |
| 515 | fd_want_send(fd); |
| 516 | fd_cant_send(fd); |
| 517 | fd_cant_recv(fd); |
| 518 | } |
| 519 | |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 520 | return SF_ERR_NONE; /* connection is OK */ |
| 521 | } |
| 522 | |
Frédéric Lécaille | 884f2e9 | 2020-11-23 14:23:21 +0100 | [diff] [blame] | 523 | /* Add listener <listener> to protocol <proto>. Technically speaking we just |
| 524 | * initialize a few entries which should be doable during quic_bind_listener(). |
| 525 | * The end of the initialization goes on with the default function. |
| 526 | */ |
| 527 | static void quic_add_listener(struct protocol *proto, struct listener *listener) |
| 528 | { |
Amaury Denoyelle | 683b5fc | 2022-01-26 11:56:48 +0100 | [diff] [blame] | 529 | listener->rx.flags |= RX_F_LOCAL_ACCEPT; |
Amaury Denoyelle | 2ce99fe | 2022-01-19 15:46:11 +0100 | [diff] [blame] | 530 | |
Frédéric Lécaille | 884f2e9 | 2020-11-23 14:23:21 +0100 | [diff] [blame] | 531 | default_add_listener(proto, listener); |
| 532 | } |
| 533 | |
Frédéric Lécaille | c1029f6 | 2021-10-20 11:09:58 +0200 | [diff] [blame] | 534 | /* Allocate the RX buffers for <l> listener. |
| 535 | * Return 1 if succeeded, 0 if not. |
| 536 | */ |
| 537 | static int quic_alloc_rxbufs_listener(struct listener *l) |
| 538 | { |
| 539 | int i; |
Amaury Denoyelle | 1cba8d6 | 2022-10-06 15:16:22 +0200 | [diff] [blame] | 540 | struct quic_receiver_buf *tmp; |
Frédéric Lécaille | c1029f6 | 2021-10-20 11:09:58 +0200 | [diff] [blame] | 541 | |
Frédéric Lécaille | c1029f6 | 2021-10-20 11:09:58 +0200 | [diff] [blame] | 542 | MT_LIST_INIT(&l->rx.rxbuf_list); |
Willy Tarreau | 8d49253 | 2022-12-21 09:16:55 +0100 | [diff] [blame] | 543 | for (i = 0; i < my_popcountl(l->rx.bind_thread); i++) { |
Amaury Denoyelle | 1cba8d6 | 2022-10-06 15:16:22 +0200 | [diff] [blame] | 544 | struct quic_receiver_buf *rxbuf; |
Frédéric Lécaille | c1029f6 | 2021-10-20 11:09:58 +0200 | [diff] [blame] | 545 | char *buf; |
Frédéric Lécaille | 794d068 | 2022-01-27 10:23:31 +0100 | [diff] [blame] | 546 | |
Amaury Denoyelle | 1cba8d6 | 2022-10-06 15:16:22 +0200 | [diff] [blame] | 547 | rxbuf = calloc(1, sizeof(*rxbuf)); |
Frédéric Lécaille | 794d068 | 2022-01-27 10:23:31 +0100 | [diff] [blame] | 548 | if (!rxbuf) |
| 549 | goto err; |
Frédéric Lécaille | c1029f6 | 2021-10-20 11:09:58 +0200 | [diff] [blame] | 550 | |
Frédéric Lécaille | c1029f6 | 2021-10-20 11:09:58 +0200 | [diff] [blame] | 551 | buf = pool_alloc(pool_head_quic_rxbuf); |
Frédéric Lécaille | 794d068 | 2022-01-27 10:23:31 +0100 | [diff] [blame] | 552 | if (!buf) { |
| 553 | free(rxbuf); |
Frédéric Lécaille | c1029f6 | 2021-10-20 11:09:58 +0200 | [diff] [blame] | 554 | goto err; |
Frédéric Lécaille | 794d068 | 2022-01-27 10:23:31 +0100 | [diff] [blame] | 555 | } |
| 556 | |
Frédéric Lécaille | c1029f6 | 2021-10-20 11:09:58 +0200 | [diff] [blame] | 557 | rxbuf->buf = b_make(buf, QUIC_RX_BUFSZ, 0, 0); |
Amaury Denoyelle | 1cba8d6 | 2022-10-06 15:16:22 +0200 | [diff] [blame] | 558 | LIST_INIT(&rxbuf->dgram_list); |
| 559 | MT_LIST_APPEND(&l->rx.rxbuf_list, &rxbuf->rxbuf_el); |
Frédéric Lécaille | c1029f6 | 2021-10-20 11:09:58 +0200 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | return 1; |
| 563 | |
| 564 | err: |
Amaury Denoyelle | 1cba8d6 | 2022-10-06 15:16:22 +0200 | [diff] [blame] | 565 | while ((tmp = MT_LIST_POP(&l->rx.rxbuf_list, typeof(tmp), rxbuf_el))) { |
| 566 | pool_free(pool_head_quic_rxbuf, tmp->buf.area); |
| 567 | free(tmp); |
Frédéric Lécaille | 794d068 | 2022-01-27 10:23:31 +0100 | [diff] [blame] | 568 | } |
Frédéric Lécaille | c1029f6 | 2021-10-20 11:09:58 +0200 | [diff] [blame] | 569 | return 0; |
| 570 | } |
| 571 | |
Amaury Denoyelle | 75839a4 | 2022-11-21 10:04:14 +0100 | [diff] [blame] | 572 | /* Check if platform supports the required feature set for quic-conn owned |
| 573 | * socket. <l> listener must already be binded; a dummy socket will be opened |
| 574 | * on the same address as one of the support test. |
| 575 | * |
| 576 | * Returns true if platform is deemed compatible else false. |
| 577 | */ |
| 578 | static int quic_test_sock_per_conn_support(struct listener *l) |
| 579 | { |
| 580 | const struct receiver *rx = &l->rx; |
| 581 | int ret = 1, fdtest; |
| 582 | |
Amaury Denoyelle | 8d46acd | 2022-12-01 14:51:16 +0100 | [diff] [blame] | 583 | /* Check if IP destination address can be retrieved on recvfrom() |
| 584 | * operation. |
| 585 | */ |
| 586 | #if !defined(IP_PKTINFO) && !defined(IP_RECVDSTADDR) |
| 587 | ha_alert("Your platform does not seem to support UDP source address retrieval through IP_PKTINFO or an alternative flag. " |
| 588 | "QUIC connections will use listener socket.\n"); |
| 589 | ret = 0; |
| 590 | #endif |
| 591 | |
Amaury Denoyelle | 75839a4 | 2022-11-21 10:04:14 +0100 | [diff] [blame] | 592 | /* Check if platform support multiple UDP sockets bind on the same |
| 593 | * local address. Create a dummy socket and bind it on the same address |
| 594 | * as <l> listener. If bind system call fails, deactivate socket per |
| 595 | * connection. All other errors are not taken into account. |
| 596 | */ |
| 597 | if (ret) { |
| 598 | fdtest = socket(rx->proto->fam->sock_domain, |
| 599 | rx->proto->sock_type, rx->proto->sock_prot); |
Amaury Denoyelle | 30fc277 | 2022-12-05 10:24:54 +0100 | [diff] [blame] | 600 | if (fdtest >= 0) { |
Amaury Denoyelle | 75839a4 | 2022-11-21 10:04:14 +0100 | [diff] [blame] | 601 | if (setsockopt(fdtest, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) && |
| 602 | bind(fdtest, (struct sockaddr *)&rx->addr, rx->proto->fam->sock_addrlen) < 0) { |
| 603 | ha_alert("Your platform does not seem to support multiple UDP sockets binded on the same address. " |
| 604 | "QUIC connections will use listener socket.\n"); |
| 605 | ret = 0; |
| 606 | } |
| 607 | |
| 608 | close(fdtest); |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | return ret; |
| 613 | } |
| 614 | |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 615 | /* This function tries to bind a QUIC4/6 listener. It may return a warning or |
| 616 | * an error message in <errmsg> if the message is at most <errlen> bytes long |
| 617 | * (including '\0'). Note that <errmsg> may be NULL if <errlen> is also zero. |
| 618 | * The return value is composed from ERR_ABORT, ERR_WARN, |
| 619 | * ERR_ALERT, ERR_RETRYABLE and ERR_FATAL. ERR_NONE indicates that everything |
| 620 | * was alright and that no message was returned. ERR_RETRYABLE means that an |
| 621 | * error occurred but that it may vanish after a retry (eg: port in use), and |
| 622 | * ERR_FATAL indicates a non-fixable error. ERR_WARN and ERR_ALERT do not alter |
| 623 | * the meaning of the error, but just indicate that a message is present which |
| 624 | * should be displayed with the respective level. Last, ERR_ABORT indicates |
| 625 | * that it's pointless to try to start other listeners. No error message is |
| 626 | * returned if errlen is NULL. |
| 627 | */ |
| 628 | static int quic_bind_listener(struct listener *listener, char *errmsg, int errlen) |
| 629 | { |
Amaury Denoyelle | 487d04f | 2022-10-11 16:22:18 +0200 | [diff] [blame] | 630 | const struct sockaddr_storage addr = listener->rx.addr; |
| 631 | int fd, err = ERR_NONE; |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 632 | char *msg = NULL; |
| 633 | |
| 634 | /* ensure we never return garbage */ |
| 635 | if (errlen) |
| 636 | *errmsg = 0; |
| 637 | |
| 638 | if (listener->state != LI_ASSIGNED) |
| 639 | return ERR_NONE; /* already bound */ |
| 640 | |
| 641 | if (!(listener->rx.flags & RX_F_BOUND)) { |
| 642 | msg = "receiving socket not bound"; |
| 643 | goto udp_return; |
| 644 | } |
| 645 | |
Amaury Denoyelle | 487d04f | 2022-10-11 16:22:18 +0200 | [diff] [blame] | 646 | /* Set IP_PKTINFO to retrieve destination address on recv. */ |
| 647 | fd = listener->rx.fd; |
| 648 | switch (addr.ss_family) { |
| 649 | case AF_INET: |
| 650 | #if defined(IP_PKTINFO) |
| 651 | setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &one, sizeof(one)); |
| 652 | #elif defined(IP_RECVDSTADDR) |
| 653 | setsockopt(fd, IPPROTO_IP, IP_RECVDSTADDR, &one, sizeof(one)); |
| 654 | #endif /* IP_PKTINFO || IP_RECVDSTADDR */ |
| 655 | break; |
| 656 | case AF_INET6: |
| 657 | #ifdef IPV6_RECVPKTINFO |
| 658 | setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &one, sizeof(one)); |
| 659 | #endif |
| 660 | break; |
| 661 | default: |
| 662 | break; |
| 663 | } |
| 664 | |
Willy Tarreau | cab054b | 2022-10-11 08:36:21 +0200 | [diff] [blame] | 665 | if (!quic_alloc_rxbufs_listener(listener)) { |
Amaury Denoyelle | 8524f0f | 2022-02-08 15:03:40 +0100 | [diff] [blame] | 666 | msg = "could not initialize tx/rx rings"; |
Frédéric Lécaille | 48f8e19 | 2021-07-06 15:39:26 +0200 | [diff] [blame] | 667 | err |= ERR_WARN; |
| 668 | goto udp_return; |
| 669 | } |
| 670 | |
Amaury Denoyelle | 75839a4 | 2022-11-21 10:04:14 +0100 | [diff] [blame] | 671 | if (global.tune.options & GTUNE_QUIC_SOCK_PER_CONN) { |
| 672 | if (!quic_test_sock_per_conn_support(listener)) |
| 673 | global.tune.options &= ~GTUNE_QUIC_SOCK_PER_CONN; |
| 674 | } |
| 675 | |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 676 | listener_set_state(listener, LI_LISTEN); |
| 677 | |
| 678 | udp_return: |
| 679 | if (msg && errlen) { |
| 680 | char pn[INET6_ADDRSTRLEN]; |
| 681 | |
| 682 | addr_to_str(&listener->rx.addr, pn, sizeof(pn)); |
Willy Tarreau | 6823a3a | 2021-10-14 11:59:15 +0200 | [diff] [blame] | 683 | snprintf(errmsg, errlen, "%s for [%s:%d]", msg, pn, get_host_port(&listener->rx.addr)); |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 684 | } |
| 685 | return err; |
| 686 | } |
| 687 | |
| 688 | /* Enable receipt of incoming connections for listener <l>. The receiver must |
| 689 | * still be valid. Does nothing in early boot (needs fd_updt). |
| 690 | */ |
| 691 | static void quic_enable_listener(struct listener *l) |
| 692 | { |
| 693 | /* FIXME: The following statements are incorrect. This |
Ilya Shipitsin | b8888ab | 2021-01-06 21:20:16 +0500 | [diff] [blame] | 694 | * is the responsibility of the QUIC xprt to stop accepting new |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 695 | * connections. |
| 696 | */ |
| 697 | if (fd_updt) |
| 698 | fd_want_recv(l->rx.fd); |
| 699 | } |
| 700 | |
| 701 | /* Disable receipt of incoming connections for listener <l>. The receiver must |
| 702 | * still be valid. Does nothing in early boot (needs fd_updt). |
| 703 | */ |
| 704 | static void quic_disable_listener(struct listener *l) |
| 705 | { |
| 706 | /* FIXME: The following statements are incorrect. This |
Ilya Shipitsin | b8888ab | 2021-01-06 21:20:16 +0500 | [diff] [blame] | 707 | * is the responsibility of the QUIC xprt to start accepting new |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 708 | * connections again. |
| 709 | */ |
| 710 | if (fd_updt) |
| 711 | fd_stop_recv(l->rx.fd); |
| 712 | } |
Amaury Denoyelle | 8524f0f | 2022-02-08 15:03:40 +0100 | [diff] [blame] | 713 | |
| 714 | static int quic_alloc_dghdlrs(void) |
| 715 | { |
| 716 | int i; |
| 717 | |
Tim Duesterhus | 9fb57e8 | 2022-06-01 21:58:37 +0200 | [diff] [blame] | 718 | quic_dghdlrs = calloc(global.nbthread, sizeof(*quic_dghdlrs)); |
Amaury Denoyelle | 8524f0f | 2022-02-08 15:03:40 +0100 | [diff] [blame] | 719 | if (!quic_dghdlrs) { |
| 720 | ha_alert("Failed to allocate the quic datagram handlers.\n"); |
| 721 | return 0; |
| 722 | } |
| 723 | |
| 724 | for (i = 0; i < global.nbthread; i++) { |
| 725 | struct quic_dghdlr *dghdlr = &quic_dghdlrs[i]; |
| 726 | |
| 727 | dghdlr->task = tasklet_new(); |
| 728 | if (!dghdlr->task) { |
| 729 | ha_alert("Failed to allocate the quic datagram handler on thread %d.\n", i); |
| 730 | return 0; |
| 731 | } |
| 732 | |
| 733 | tasklet_set_tid(dghdlr->task, i); |
| 734 | dghdlr->task->context = dghdlr; |
| 735 | dghdlr->task->process = quic_lstnr_dghdlr; |
| 736 | |
Amaury Denoyelle | 8524f0f | 2022-02-08 15:03:40 +0100 | [diff] [blame] | 737 | dghdlr->cids = EB_ROOT_UNIQUE; |
| 738 | |
| 739 | MT_LIST_INIT(&dghdlr->dgrams); |
| 740 | } |
| 741 | |
| 742 | return 1; |
| 743 | } |
| 744 | REGISTER_POST_CHECK(quic_alloc_dghdlrs); |
| 745 | |
| 746 | static int quic_deallocate_dghdlrs(void) |
| 747 | { |
| 748 | int i; |
| 749 | |
| 750 | if (quic_dghdlrs) { |
| 751 | for (i = 0; i < global.nbthread; ++i) |
| 752 | tasklet_free(quic_dghdlrs[i].task); |
| 753 | free(quic_dghdlrs); |
| 754 | } |
| 755 | |
| 756 | return 1; |
| 757 | } |
| 758 | REGISTER_POST_DEINIT(quic_deallocate_dghdlrs); |
Frédéric Lécaille | ca42b2c | 2020-11-02 14:27:08 +0100 | [diff] [blame] | 759 | |
| 760 | /* |
| 761 | * Local variables: |
| 762 | * c-indent-level: 8 |
| 763 | * c-basic-offset: 8 |
| 764 | * End: |
| 765 | */ |