16 #include <sys/socket.h> 22 #include <vpp/app/version.h> 31 #include <quicly/defaults.h> 46 ctx->c_thread_index = thread_index;
47 QUIC_DBG (3,
"Allocated quic_ctx %u on thread %u",
48 ctx - qm->
ctx_pool[thread_index], thread_index);
49 return ctx - qm->
ctx_pool[thread_index];
55 QUIC_DBG (2,
"Free ctx %u", ctx->c_c_index);
56 u32 thread_index = ctx->c_thread_index;
58 memset (ctx, 0xfb,
sizeof (*ctx));
80 conn_data = (
u64) * quicly_get_data (conn);
81 return quic_ctx_get (conn_data & UINT32_MAX, conn_data >> 32);
87 *quicly_get_data (conn) =
88 (
void *) (((
u64) ctx->c_thread_index) << 32 | (
u64) ctx->c_c_index);
116 const quicly_cid_plaintext_t *
id)
118 kv->
key[0] = ((
u64) id->master_id) << 32 | (
u64) id->thread_id;
119 kv->
key[1] = id->node_id;
131 static quicly_context_t *
143 static quicly_context_t *
159 quicly_stream_t *stream;
173 quicly_stream_sync_recvbuf (stream, stream_data->
app_rx_data_len - max_deq);
195 tw_timer_wheel_1t_3w_1024sl_ov_t *tw;
199 QUIC_DBG (2,
"Deleting connection %u", ctx->c_c_index);
213 QUIC_DBG (2,
"Deleting conn with id %lu %lu from map", kv.
key[0],
220 quicly_free (ctx->
conn);
234 QUIC_DBG (2,
"QUIC connection %u/%u closed", ctx->c_thread_index,
282 len = packet->data.len;
288 QUIC_DBG (1,
"Too much data to send, max_enqueue %u, len %u",
303 ASSERT (packet->sa.sa_family == AF_INET);
304 struct sockaddr_in *sa4 = (
struct sockaddr_in *) &packet->sa;
306 hdr.
rmt_ip.ip4.as_u32 = sa4->sin_addr.s_addr;
310 ASSERT (packet->sa.sa_family == AF_INET6);
311 struct sockaddr_in6 *sa6 = (
struct sockaddr_in6 *) &packet->sa;
317 if (ret !=
sizeof (hdr))
319 QUIC_DBG (1,
"Not enough space to enqueue header");
325 QUIC_DBG (1,
"Not enough space to enqueue payload");
337 size_t num_packets,
i, max_packets;
338 quicly_packet_allocator_t *pa;
339 quicly_context_t *quicly_context;
364 clib_warning (
"Tried to send packets on non existing app worker %u",
369 pa = quicly_context->packet_allocator;
375 num_packets = max_packets;
376 if ((err = quicly_send (conn, packets, &num_packets)))
379 for (i = 0; i != num_packets; ++
i)
384 pa->free_packet (pa, packets[i]);
387 while (num_packets > 0 && num_packets == max_packets);
402 if (err && err != QUICLY_ERROR_PACKET_IGNORED
403 && err != QUICLY_ERROR_FREE_CONNECTION)
423 session_get (sctx->c_s_index, sctx->c_thread_index);
424 QUIC_DBG (2,
"DESTROYED_STREAM: session 0x%lx (%U)",
442 session_get (sctx->c_s_index, sctx->c_thread_index);
443 clib_warning (
"(NOT IMPLEMENTD) STOP_SENDING: session 0x%lx (%U)",
458 session_get (sctx->c_s_index, sctx->c_thread_index);
470 QUIC_DBG (3,
"received data: %lu bytes, offset %lu", len, off);
485 QUIC_DBG (3,
"Enqueuing %u at off %u in %u space", len, off, max_enq);
488 QUIC_DBG (1,
"Error RX fifo is full");
525 quicly_stream_sync_sendbuf (stream, 0);
530 size_t *
len,
int *wrote_all)
534 u32 deq_max, first_deq, max_rd_chunk, rem_offset;
539 QUIC_DBG (3,
"Emitting %u, offset %u", *len, off);
543 if (off + *len < deq_max)
550 *len = deq_max - off;
551 QUIC_DBG (3,
"Wrote ALL, %u", *len);
558 if (off < max_rd_chunk)
560 first_deq =
clib_min (*len, max_rd_chunk - off);
564 if (max_rd_chunk < off + *len)
566 rem_offset = max_rd_chunk < off ? off - max_rd_chunk : 0;
586 quicly_stream_t *stream = (quicly_stream_t *) s;
587 session_t *stream_session, *quic_session;
599 QUIC_DBG (2,
"ACCEPTED stream_session 0x%lx ctx %u",
605 sctx->c_c_index = sctx_id;
612 stream_data->
ctx_id = sctx_id;
622 quic_session =
session_get (qctx->c_s_index, qctx->c_thread_index);
628 QUIC_DBG (1,
"failed to allocate fifos");
639 QUIC_DBG (1,
"failed to notify accept worker app");
649 QUIC_DBG (2,
"on_stream_open called");
654 if (!quicly_stream_is_self_initiated (stream))
663 int code, uint64_t frame_type,
664 const char *reason,
size_t reason_len)
669 clib_warning (
"Session 0x%lx closed by peer (%U) %.*s ",
722 tw_timer_wheel_1t_3w_1024sl_ov_t *tw;
726 tw_timer_expire_timers_1t_3w_1024sl_ov (tw, now);
733 QUIC_DBG (4,
"Timer expired for conn %u at %ld", conn_index,
743 tw_timer_wheel_1t_3w_1024sl_ov_t *tw;
744 int64_t next_timeout, next_interval;
748 next_timeout = quicly_get_first_timeout (ctx->
conn);
751 if (next_timeout == 0 || next_interval <= 0)
759 quic_session =
session_get (ctx->c_s_index, ctx->c_thread_index);
770 QUIC_DBG (4,
"Timer set to %ld (int %ld) for ctx %u", next_timeout,
771 next_interval, ctx->c_c_index);
775 if (next_timeout == INT64_MAX)
777 QUIC_DBG (4,
"timer for ctx %u already stopped", ctx->c_c_index);
781 tw_timer_start_1t_3w_1024sl_ov (tw, ctx->c_c_index, 0, next_interval);
785 if (next_timeout == INT64_MAX)
789 QUIC_DBG (4,
"Stopping timer for ctx %u", ctx->c_c_index);
803 for (i = 0; i <
vec_len (expired_timers); i++)
817 int is_encrypt, ptls_buffer_t *
dst, ptls_iovec_t
src)
826 free (self->data.base);
827 if ((self->data.base = malloc (src.len)) ==
NULL)
828 return PTLS_ERROR_NO_MEMORY;
830 ptls_get_context (tls)->random_bytes (self->id, sizeof (self->id));
831 memcpy (self->data.base, src.base, src.len);
832 self->data.len = src.len;
835 if ((ret = ptls_buffer_reserve (dst,
sizeof (self->id))) != 0)
837 memcpy (dst->base + dst->off, self->id, sizeof (self->id));
838 dst->off +=
sizeof (
self->id);
845 if (src.len != sizeof (self->id))
846 return PTLS_ERROR_SESSION_NOT_FOUND;
847 if (memcmp (self->id, src.base, sizeof (self->id)) != 0)
848 return PTLS_ERROR_SESSION_NOT_FOUND;
851 if ((ret = ptls_buffer_reserve (dst, self->data.len)) != 0)
853 memcpy (dst->base + dst->off, self->data.base, self->data.len);
854 dst->off +=
self->data.len;
872 ptls_iovec_t key_vec;
878 clib_memset (quicly_ctx_data, 0,
sizeof (*quicly_ctx_data));
881 ptls_ctx->random_bytes = ptls_openssl_random_bytes;
882 ptls_ctx->get_time = &ptls_get_time;
883 ptls_ctx->key_exchanges = ptls_openssl_key_exchanges;
885 ptls_ctx->certificates.list =
NULL;
886 ptls_ctx->certificates.count = 0;
887 ptls_ctx->esni =
NULL;
888 ptls_ctx->on_client_hello =
NULL;
889 ptls_ctx->emit_certificate =
NULL;
890 ptls_ctx->sign_certificate =
NULL;
891 ptls_ctx->verify_certificate =
NULL;
892 ptls_ctx->ticket_lifetime = 86400;
893 ptls_ctx->max_early_data_size = 8192;
894 ptls_ctx->hkdf_label_prefix__obsolete =
NULL;
895 ptls_ctx->require_dhe_on_psk = 1;
899 memcpy (quicly_ctx, &quicly_spec_context,
sizeof (quicly_context_t));
906 quicly_amend_ptls_context (quicly_ctx->tls);
908 quicly_ctx->event_log.mask = 0;
909 quicly_ctx->event_log.cb = quicly_new_default_event_logger (stderr);
912 quicly_ctx->transport_params.max_streams_uni = (uint64_t) 1 << 60;
913 quicly_ctx->transport_params.max_streams_bidi = (uint64_t) 1 << 60;
914 quicly_ctx->transport_params.max_stream_data.bidi_local = (
QUIC_FIFO_SIZE - 1);
915 quicly_ctx->transport_params.max_stream_data.bidi_remote = (
QUIC_FIFO_SIZE - 1);
916 quicly_ctx->transport_params.max_stream_data.uni =
QUIC_INT_MAX;
918 quicly_ctx->tls->random_bytes (quicly_ctx_data->
cid_key, 16);
919 quicly_ctx_data->
cid_key[16] = 0;
921 ptls_iovec_init (quicly_ctx_data->
cid_key,
922 strlen (quicly_ctx_data->
cid_key));
923 quicly_ctx->cid_encryptor =
924 quicly_new_default_cid_encryptor (&ptls_openssl_bfecb,
925 &ptls_openssl_sha256, key_vec);
932 QUIC_DBG (1,
"failed to read private key from app configuration\n");
937 QUIC_DBG (1,
"failed to load certificate\n");
951 uint64_t quic_session_handle;
954 quicly_stream_t *stream;
963 QUIC_DBG (2,
"Opening new stream (qsession %u)", quic_session_handle);
968 QUIC_DBG (1,
"received incompatible session");
975 QUIC_DBG (1,
"Invalid app worker :(");
985 QUIC_DBG (1,
"session is a stream");
993 sctx->c_c_index = sctx_index;
999 if (!conn || !quicly_connection_is_ready (conn))
1002 if ((rv = quicly_open_stream (conn, &stream, 0 )))
1004 QUIC_DBG (2,
"Stream open failed with %d", rv);
1009 QUIC_DBG (2,
"Opened stream %d, creating session", stream->stream_id);
1012 QUIC_DBG (2,
"Allocated stream_session 0x%lx ctx %u",
1024 QUIC_DBG (1,
"failed to app_worker_init_connected");
1038 QUIC_DBG (1,
"failed to notify app");
1045 stream_data->
ctx_id = sctx->c_c_index;
1066 ctx->c_c_index = ctx_index;
1087 cargs->api_context = ctx_index;
1092 cargs->sep_ext.ns_index = app->
ns_index;
1105 QUIC_DBG (2,
"Called quic_connect");
1125 session_get (ctx->c_s_index, ctx->c_thread_index);
1130 quicly_stream_t *stream = ctx->
stream;
1140 quicly_conn_t *conn = ctx->
conn;
1186 memset (args, 0,
sizeof (*args));
1188 args->sep_ext = *sep;
1189 args->sep_ext.ns_index = app->
ns_index;
1194 udp_handle = args->handle;
1197 udp_listen_session->
opaque = lctx_index;
1202 clib_memcpy (&lctx->c_rmt_ip, &args->sep.peer.ip, sizeof (ip46_address_t));
1203 clib_memcpy (&lctx->c_lcl_ip, &args->sep.ip, sizeof (ip46_address_t));
1204 lctx->c_rmt_port = args->sep.peer.port;
1205 lctx->c_lcl_port = args->sep.port;
1206 lctx->c_is_ip4 = args->sep.is_ip4;
1207 lctx->c_fib_index = args->sep.fib_index;
1212 lctx->c_s_index = quic_listen_session_index;
1214 QUIC_DBG (2,
"Listening UDP session 0x%lx",
1216 QUIC_DBG (2,
"Listening QUIC session 0x%lx", quic_listen_session_index);
1223 QUIC_DBG (2,
"Called quic_stop_listen");
1252 QUIC_DBG (2,
"Called quic_listener_get");
1262 u32 verbose = va_arg (*args,
u32);
1267 str =
format (str,
"[#%d][Q] ", ctx->c_thread_index);
1272 str =
format (str,
"Stream %ld conn %d",
1275 str =
format (str,
"Conn %d UDP %d", ctx->c_c_index,
1284 s =
format (s,
"%s\n", str);
1292 u32 qc_index = va_arg (*args,
u32);
1293 u32 thread_index = va_arg (*args,
u32);
1294 u32 verbose = va_arg (*args,
u32);
1303 u32 qc_index = va_arg (*args,
u32);
1304 u32 thread_index = va_arg (*args,
u32);
1315 u32 tci = va_arg (*args,
u32);
1316 u32 thread_index = va_arg (*args,
u32);
1317 u32 verbose = va_arg (*args,
u32);
1336 struct sockaddr_in *sa4 = (
struct sockaddr_in *) sa;
1337 sa4->sin_family = AF_INET;
1338 sa4->sin_port =
port;
1339 sa4->sin_addr.s_addr = addr->ip4.as_u32;
1340 *salen =
sizeof (
struct sockaddr_in);
1344 struct sockaddr_in6 *sa6 = (
struct sockaddr_in6 *) sa;
1345 sa6->sin6_family = AF_INET6;
1346 sa6->sin6_port =
port;
1348 *salen =
sizeof (
struct sockaddr_in6);
1357 u32 ctx_id = ctx->c_c_index;
1358 u32 thread_index = ctx->c_thread_index;
1380 QUIC_DBG (1,
"failed to app_worker_init_connected");
1389 QUIC_DBG (1,
"failed to notify app %d", rv);
1407 quicly_conn_t *conn;
1414 QUIC_DBG (2,
"Received conn %u (now %u)", temp_ctx->c_thread_index,
1418 memcpy (new_ctx, temp_ctx,
sizeof (
quic_ctx_t));
1421 new_ctx->c_thread_index = thread_index;
1422 new_ctx->c_c_index = new_ctx_id;
1424 conn = new_ctx->
conn;
1427 kv.
value = ((
u64) thread_index) << 32 | (
u64) new_ctx_id;
1428 QUIC_DBG (2,
"Registering conn with id %lu %lu", kv.
key[0], kv.
key[1]);
1438 QUIC_DBG (4,
"Cannot send TX event");
1444 tw_timer_wheel_1t_3w_1024sl_ov_t *tw;
1448 QUIC_DBG (2,
"Transferring conn %u to thread %u", ctx_index, dest_thread);
1473 QUIC_DBG (2,
"QSession is now connected (id %u)",
1478 struct sockaddr_in6 sa6;
1479 struct sockaddr *sa = (
struct sockaddr *) &sa6;
1483 quicly_conn_t *conn;
1497 api_context = ctx->c_s_index;
1503 ctx->c_thread_index = thread_index;
1504 ctx->c_c_index = ctx_index;
1506 QUIC_DBG (2,
"Quic connect returned %u. New ctx [%u]%x",
1507 is_fail, thread_index, (ctx) ? ctx_index : ~0);
1529 kv.
value = ((
u64) thread_index) << 32 | (
u64) ctx_index;
1530 QUIC_DBG (2,
"Registering conn with id %lu %lu", kv.
key[0], kv.
key[1]);
1571 if (ctx->udp_session_handle == old_session_handle)
1574 QUIC_DBG (5,
"Found right ctx: %x", ctx->c_c_index);
1575 ctx->udp_session_handle = new_sh;
1576 quic_transfer_connection (ctx->c_c_index, new_thread);
1581 QUIC_DBG (0,
"BUG: Connection to migrate not found");
1594 udp_listen_session =
1600 ctx->c_c_index = ctx_index;
1619 *pool_index = ctx_index;
1628 QUIC_DBG (2,
"Called quic_add_segment_callback");
1637 QUIC_DBG (2,
"Called quic_del_segment_callback");
1648 QUIC_DBG (3,
"Received app READ notification");
1663 quicly_stream_t *stream;
1684 if (!quicly_sendstate_is_open (&stream->sendstate))
1686 QUIC_DBG (1,
"Warning: tried to send on closed stream");
1690 if ((rv = quicly_stream_sync_sendbuf (stream, 1)) != 0)
1707 struct sockaddr *sa, socklen_t salen,
1708 quicly_decoded_packet_t * packet,
1709 u32 caller_thread_index)
1712 quicly_conn_t *conn_;
1714 clib_bihash_16_8_t *
h;
1718 QUIC_DBG (3,
"Searching conn with id %lu %lu", kv.
key[0], kv.
key[1]);
1720 if (clib_bihash_search_16_8 (h, &kv, &kv) == 0)
1726 if (thread_id != caller_thread_index)
1728 QUIC_DBG (2,
"Connection is on wrong thread");
1731 *ctx_thread = thread_id;
1736 if (conn_ && quicly_is_destination (conn_, sa, salen, packet))
1740 *ctx_thread = thread_id;
1744 QUIC_DBG (3,
"connection not found");
1750 quicly_decoded_packet_t packet)
1753 u32 ctx_id = ctx->c_c_index;
1754 u32 thread_index = ctx->c_thread_index;
1756 rv = quicly_receive (conn, &packet);
1767 if (quicly_connection_is_ready (conn))
1770 if (quicly_is_client (conn))
1789 QUIC_DBG (2,
"Allocated quic_session, 0x%lx ctx %u",
1806 QUIC_DBG (1,
"failed to allocate fifos");
1813 QUIC_DBG (1,
"failed to notify accept worker app");
1821 socklen_t salen, quicly_decoded_packet_t packet)
1825 quicly_conn_t *conn;
1834 if ((rv = quicly_accept (&conn, quicly_ctx, sa, salen,
1835 &packet, ptls_iovec_init (
NULL, 0),
1840 QUIC_DBG (1,
"Accept failed with %d", rv);
1856 kv.
value = ((
u64) thread_index) << 32 | (
u64) ctx_index;
1858 QUIC_DBG (2,
"Registering conn with id %lu %lu", kv.
key[0], kv.
key[1]);
1865 struct sockaddr *sa, socklen_t salen,
1866 quicly_decoded_packet_t packet)
1873 QUIC_DBG (2,
"Sending stateless reset");
1875 quicly_datagram_t *dgram;
1878 if (packet.cid.dest.plaintext.node_id != 0
1879 || packet.cid.dest.plaintext.thread_id != 0)
1882 dgram = quicly_send_stateless_reset (quicly_ctx, sa, salen,
1883 &packet.cid.dest.plaintext);
1897 quicly_decoded_packet_t packet;
1903 struct sockaddr_in6 sa6;
1904 struct sockaddr *sa = (
struct sockaddr *) &sa6;
1906 u32 max_deq, full_len, ctx_index = UINT32_MAX, ctx_thread = UINT32_MAX, ret;
1909 u32 *opening_ctx_pool, *ctx_index_ptr;
1919 QUIC_DBG (1,
"Got RX on detached app");
1934 QUIC_DBG (1,
"Not enough data for even a header in RX");
1940 QUIC_DBG (1,
"Not enough data for header in RX");
1945 if (full_len > max_deq)
1947 QUIC_DBG (1,
"Not enough data in fifo RX");
1957 QUIC_DBG (1,
"Not enough data peeked in RX");
1966 plen = quicly_decode_packet (quicly_ctx, &packet, data, ph.
data_length);
1967 if (plen != SIZE_MAX)
1971 &packet, thread_index);
1977 else if (ctx_index != UINT32_MAX)
1998 pool_put (opening_ctx_pool, ctx_index_ptr);
1999 goto ctx_search_done;
2087 .transport_options = {
2096 ptls_cipher_suite_t ** ciphers)
2106 u32 segment_size = 256 << 20;
2108 tw_timer_wheel_1t_3w_1024sl_ov_t *tw;
2117 memset (a, 0,
sizeof (*a));
2118 memset (options, 0,
sizeof (options));
2122 a->options = options;
2123 a->name =
format (0,
"quic");
2141 for (i = 0; i < num_threads; i++)
2149 clib_bihash_init_16_8 (&qm->
connection_hash,
"quic connections", 1024,
2165 ptls_openssl_cipher_suites);
2184 else if (
unformat (input,
"picotls"))
2195 .path =
"quic set crypto api",
2196 .short_help =
"quic set crypto api [picotls, vpp]",
2201 .version = VPP_BUILD_VER,
2202 .description =
"Quic transport protocol",
static void quic_accept_stream(void *s)
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static int quic_ctx_is_stream(quic_ctx_t *ctx)
int app_worker_lock_and_send_event(app_worker_t *app, session_t *s, u8 evt_type)
Send event to application.
u32 connection_index
Index of the transport connection associated to the session.
static quicly_context_t * quic_get_quicly_ctx_from_ctx(quic_ctx_t *ctx)
int app_worker_init_accepted(session_t *s)
static void quic_connection_delete(quic_ctx_t *ctx)
session_type_t session_type
Type built from transport and network protocol types.
static void quic_session_migrate_callback(session_t *s, session_handle_t new_sh)
static u32 svm_fifo_max_enqueue_prod(svm_fifo_t *f)
Maximum number of bytes that can be enqueued into fifo.
static u32 quic_stop_listen(u32 lctx_index)
quic_worker_ctx_t * wrk_ctx
static int quic_custom_app_rx_callback(transport_connection_t *tc)
quicly_stream_t * stream
STREAM ctx case.
u32 ns_index
Namespace the application belongs to.
static int64_t quic_get_thread_time(u8 thread_index)
#define QUIC_SEND_PACKET_VEC_SIZE
quicly_cid_plaintext_t next_cid
struct _vnet_connect_args vnet_connect_args_t
struct _vnet_unlisten_args_t vnet_unlisten_args_t
#define QUIC_TSTAMP_RESOLUTION
u32 session_index
Index in thread pool where session was allocated.
static void quic_register_cipher_suite(quic_crypto_engine_t type, ptls_cipher_suite_t **ciphers)
static quicly_closed_by_peer_t on_closed_by_peer
#define clib_memcpy_fast(a, b, c)
void session_transport_delete_notify(transport_connection_t *tc)
Notification from transport that connection is being deleted.
transport_connection_t * session_get_transport(session_t *s)
static f64 vlib_time_now(vlib_main_t *vm)
svm_fifo_t * rx_fifo
Pointers to rx/tx buffers.
static int quic_on_receive(quicly_stream_t *stream, size_t off, const void *src, size_t len)
static session_t * listen_session_get_from_handle(session_handle_t handle)
static quic_ctx_t * quic_ctx_get(u32 ctx_index, u32 thread_index)
#define vec_terminate_c_string(V)
(If necessary) NULL terminate a vector containing a c-string.
int64_t time_now
worker time
void session_send_rpc_evt_to_thread(u32 thread_index, void *fp, void *rpc_args)
int svm_fifo_peek(svm_fifo_t *f, u32 offset, u32 len, u8 *dst)
Peek data from fifo.
void session_transport_reset_notify(transport_connection_t *tc)
Notify application that connection has been reset.
static void svm_fifo_reset_has_deq_ntf(svm_fifo_t *f)
Clear has notification flag.
clib_bihash_16_8_t connection_hash
static void quic_store_quicly_ctx(application_t *app, u8 is_client)
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
static void quic_build_sockaddr(struct sockaddr *sa, socklen_t *salen, ip46_address_t *addr, u16 port, u8 is_ip4)
static u32 svm_fifo_max_enqueue(svm_fifo_t *f)
static session_t * session_get(u32 si, u32 thread_index)
static int quic_connect(transport_endpoint_cfg_t *tep)
int vnet_unlisten(vnet_unlisten_args_t *a)
static void quic_timer_expired(u32 conn_index)
#define QUIC_ERROR_FULL_FIFO
f64 tstamp_ticks_per_clock
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
static void quic_expired_timers_dispatch(u32 *expired_timers)
int quic_fifo_egress_emit(quicly_stream_t *stream, size_t off, void *dst, size_t *len, int *wrote_all)
#define QUIC_DBG(_lvl, _fmt, _args...)
application_t * application_get_if_valid(u32 app_index)
struct _vnet_bind_args_t vnet_listen_args_t
static session_handle_t session_handle(session_t *s)
struct _svm_fifo svm_fifo_t
void session_get_endpoint(session_t *s, transport_endpoint_t *tep, u8 is_lcl)
#define clib_memcpy(d, s, n)
void session_transport_closing_notify(transport_connection_t *tc)
Notification from transport that connection is being closed.
static int quic_send_packets(quic_ctx_t *ctx)
void session_free_w_fifos(session_t *s)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
static clib_error_t * quic_plugin_crypto_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static void quic_receive_connection(void *arg)
#define VLIB_INIT_FUNCTION(x)
struct _vnet_disconnect_args_t vnet_disconnect_args_t
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
Fifo max bytes to dequeue.
static u32 svm_fifo_max_dequeue_cons(svm_fifo_t *f)
Fifo max bytes to dequeue optimized for consumer.
static void quic_proto_on_close(u32 ctx_index, u32 thread_index)
static transport_connection_t * quic_connection_get(u32 ctx_index, u32 thread_index)
#define clib_error_return(e, args...)
static int quic_app_rx_callback(session_t *udp_session)
static const transport_proto_vft_t quic_proto
static void quic_ack_rx_data(session_t *stream_session)
int session_send_io_evt_to_thread(svm_fifo_t *f, session_evt_type_t evt_type)
ptls_handshake_properties_t hs_properties
static u32 quic_start_listen(u32 quic_listen_session_index, transport_endpoint_t *tep)
#define SESSION_INVALID_HANDLE
static u8 * svm_fifo_head(svm_fifo_t *f)
static int quic_on_stream_open(quicly_stream_open_t *self, quicly_stream_t *stream)
static session_t * get_stream_session_from_stream(quicly_stream_t *stream)
#define QUIC_MAX_PACKET_SIZE
static u32 svm_fifo_max_read_chunk(svm_fifo_t *f)
Max contiguous chunk of data that can be read.
int load_bio_certificate_chain(ptls_context_t *ctx, const char *cert_data)
struct _vnet_app_attach_args_t vnet_app_attach_args_t
struct _transport_proto_vft transport_proto_vft_t
struct _session_endpoint_cfg session_endpoint_cfg_t
#define QUIC_TIMER_HANDLE_INVALID
vl_api_fib_path_type_t type
quicly_context_t quicly_ctx
static session_type_t session_type_from_proto_and_ip(transport_proto_t proto, u8 is_ip4)
static quic_ctx_t * quic_ctx_get_if_valid(u32 ctx_index, u32 thread_index)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
struct quicly_ctx_data_ quicly_ctx_data_t
static void quic_connection_closed(quic_ctx_t *ctx)
Called when quicly return an error This function interacts tightly with quic_proto_on_close.
int app_worker_accept_notify(app_worker_t *app_wrk, session_t *s)
static session_t * session_get_from_handle(session_handle_t handle)
session_t * app_listener_get_session(app_listener_t *al)
static u32 quic_set_time_now(u32 thread_index)
static int quic_connect_new_connection(session_endpoint_cfg_t *sep)
#define pool_put(P, E)
Free an object E in pool P.
#define APP_INVALID_INDEX
int svm_fifo_enqueue(svm_fifo_t *f, u32 len, const u8 *src)
Enqueue data to fifo.
static int quic_create_connection(u32 ctx_index, struct sockaddr *sa, socklen_t salen, quicly_decoded_packet_t packet)
int load_bio_private_key(ptls_context_t *ctx, const char *pk_data)
static u8 * format_quic_connection(u8 *s, va_list *args)
u32 wrk_index
Worker index in global worker pool.
app_worker_t * app_worker_get_if_valid(u32 wrk_index)
static u32 quic_ctx_alloc(u32 thread_index)
static u64 listen_session_get_handle(session_t *s)
int vnet_application_attach(vnet_app_attach_args_t *a)
Attach application to vpp.
static session_t * session_get_from_handle_if_valid(session_handle_t handle)
static int quic_connect_new_stream(session_t *quic_session, u32 opaque)
static void quic_store_conn_ctx(quicly_conn_t *conn, quic_ctx_t *ctx)
static u8 svm_fifo_set_event(svm_fifo_t *f)
Set fifo event flag.
quicly_conn_t * conn
QUIC ctx case.
transport_connection_t connection
static quicly_stream_open_t on_stream_open
session_handle_t listener_handle
Parent listener session index if the result of an accept.
static_always_inline uword vlib_get_thread_index(void)
static quicly_now_t quicly_vpp_now_cb
static void quic_get_transport_listener_endpoint(u32 listener_index, transport_endpoint_t *tep, u8 is_lcl)
static int quic_reset_connection(u64 udp_session_handle, struct sockaddr *sa, socklen_t salen, quicly_decoded_packet_t packet)
ptls_cipher_suite_t *** quic_ciphers
static clib_error_t * quic_init(vlib_main_t *vm)
#define vec_free(V)
Free vector's memory (no header).
#define SESSION_CONN_HDR_LEN
void session_free(session_t *s)
#define clib_warning(format, args...)
struct _stream_session_cb_vft session_cb_vft_t
static quic_main_t quic_main
ptls_encrypt_ticket_t super
Don't register connection in lookup Does not apply to local apps and transports using the network lay...
#define QUIC_SESSION_INVALID
struct _transport_connection transport_connection_t
static int quic_send_datagram(session_t *udp_session, quicly_datagram_t *packet)
static int quic_on_receive_reset(quicly_stream_t *stream, int err)
static int quic_add_segment_callback(u32 client_index, u64 seg_handle)
int app_worker_init_connected(app_worker_t *app_wrk, session_t *s)
static void quic_transfer_connection(u32 ctx_index, u32 dest_thread)
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
void quic_fifo_egress_shift(quicly_stream_t *stream, size_t delta)
static void quic_on_closed_by_peer(quicly_closed_by_peer_t *self, quicly_conn_t *conn, int code, uint64_t frame_type, const char *reason, size_t reason_len)
static transport_proto_t session_type_transport_proto(session_type_t st)
static void quic_update_time(f64 now, u8 thread_index)
tw_timer_wheel_1t_3w_1024sl_ov_t timer_wheel
worker timer wheel
application_t * application_get(u32 app_index)
static void quic_update_timer(quic_ctx_t *ctx)
static u32 session_thread_from_handle(session_handle_t handle)
void transport_register_protocol(transport_proto_t transport_proto, const transport_proto_vft_t *vft, fib_protocol_t fib_proto, u32 output_node)
Register transport virtual function table.
static int quic_custom_tx_callback(void *s, u32 max_burst_size)
static transport_connection_t * quic_listener_get(u32 listener_index)
#define VLIB_CLI_COMMAND(x,...)
apps acting as transports
static void quic_session_disconnect_callback(session_t *s)
app_listener_t * app_listener_get_w_handle(session_handle_t handle)
Get app listener for listener session handle.
static int quic_ctx_is_listener(quic_ctx_t *ctx)
static int quic_del_segment_callback(u32 client_index, u64 seg_handle)
static int quic_create_quic_session(quic_ctx_t *ctx)
u32 quic_connection_ctx_id
Notify on transition to empty.
int vnet_listen(vnet_listen_args_t *a)
static u8 * format_quic_listener(u8 *s, va_list *args)
#define QUIC_APP_ACCEPT_NOTIFY_ERROR
static void clib_mem_free(void *p)
#define QUICLY_PACKET_TYPE_INITIAL
session_handle_t udp_session_handle
int svm_fifo_enqueue_with_offset(svm_fifo_t *f, u32 offset, u32 len, u8 *src)
Enqueue a future segment.
u8 * tls_key
PEM encoded key.
static void svm_fifo_add_want_deq_ntf(svm_fifo_t *f, u8 ntf_type)
Set specific want notification flag.
static int quic_on_client_connected(quic_ctx_t *ctx)
static int quic_session_connected_callback(u32 quic_app_index, u32 ctx_index, session_t *udp_session, u8 is_fail)
static void * clib_mem_alloc(uword size)
int vnet_connect(vnet_connect_args_t *a)
Notify on transition from full.
static vlib_main_t * vlib_get_main(void)
#define QUIC_APP_CONNECT_NOTIFY_ERROR
u8 thread_index
Index of the thread that allocated the session.
session_t * session_alloc(u32 thread_index)
int vlib_main(vlib_main_t *volatile vm, unformat_input_t *input)
#define QUIC_APP_ALLOCATION_ERROR
static void quic_disconnect_transport(quic_ctx_t *ctx)
#define QUICLY_PACKET_TYPE_BITMASK
int quic_session_accepted_callback(session_t *udp_session)
static int quic_encrypt_ticket_cb(ptls_encrypt_ticket_t *_self, ptls_t *tls, int is_encrypt, ptls_buffer_t *dst, ptls_iovec_t src)
static session_cb_vft_t quic_app_cb_vft
u8 * quic_format_err(u8 *s, va_list *args)
app_worker_t * app_worker_get(u32 wrk_index)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static int64_t quic_get_time(quicly_now_t *self)
volatile u8 session_state
State in session layer state machine.
#define QUIC_APP_ERROR_CLOSE_NOTIFY
enum quic_crypto_engine_ quic_crypto_engine_t
u32 opaque
Opaque, for general use.
ptls_cipher_suite_t * vpp_crypto_cipher_suites[]
int app_worker_alloc_connects_segment_manager(app_worker_t *app)
static void quic_get_transport_endpoint(u32 ctx_index, u32 thread_index, transport_endpoint_t *tep, u8 is_lcl)
int vnet_disconnect_session(vnet_disconnect_args_t *a)
static int quic_on_stop_sending(quicly_stream_t *stream, int err)
static int quic_receive(quic_ctx_t *ctx, quicly_conn_t *conn, quicly_decoded_packet_t packet)
int session_send_io_evt_to_thread_custom(void *data, u32 thread_index, session_evt_type_t evt_type)
u32 app_index
Index of owning app.
static void quic_ctx_free(quic_ctx_t *ctx)
static vlib_thread_main_t * vlib_get_thread_main()
u8 * tls_cert
Certificate to be used for listen sessions.
u32 app_wrk_index
Index of the app worker that owns the session.
static u8 * format_quic_ctx(u8 *s, va_list *args)
quic_session_cache_t session_cache
static void quic_session_reset_callback(session_t *s)
static void quic_make_connection_key(clib_bihash_kv_16_8_t *kv, const quicly_cid_plaintext_t *id)
static void quic_on_stream_destroy(quicly_stream_t *stream, int err)
int svm_fifo_dequeue_drop(svm_fifo_t *f, u32 len)
Dequeue and drop bytes from fifo.
static quic_ctx_t * quic_get_conn_ctx(quicly_conn_t *conn)
static int quic_find_packet_ctx(u32 *ctx_thread, u32 *ctx_index, struct sockaddr *sa, socklen_t salen, quicly_decoded_packet_t *packet, u32 caller_thread_index)
static quicly_context_t * quic_get_quicly_ctx_from_udp(u64 udp_session_handle)
int app_worker_connect_notify(app_worker_t *app_wrk, session_t *s, u32 opaque)
static void quic_common_get_transport_endpoint(quic_ctx_t *ctx, transport_endpoint_t *tep, u8 is_lcl)
static const quicly_stream_callbacks_t quic_stream_callbacks
static u8 * format_quic_half_open(u8 *s, va_list *args)
static int quic_sendable_packet_count(session_t *udp_session)