16 #include <sys/socket.h> 22 #include <vpp/app/version.h> 31 #include <quicly/defaults.h> 34 #define quic_error(n,s) s, 52 ctx->c_thread_index = thread_index;
53 QUIC_DBG (3,
"Allocated quic_ctx %u on thread %u",
54 ctx - qm->
ctx_pool[thread_index], thread_index);
55 return ctx - qm->
ctx_pool[thread_index];
61 QUIC_DBG (2,
"Free ctx %u", ctx->c_c_index);
62 u32 thread_index = ctx->c_thread_index;
64 memset (ctx, 0xfb,
sizeof (*ctx));
86 conn_data = (
u64) * quicly_get_data (conn);
87 return quic_ctx_get (conn_data & UINT32_MAX, conn_data >> 32);
93 *quicly_get_data (conn) =
94 (
void *) (((
u64) ctx->c_thread_index) << 32 | (
u64) ctx->c_c_index);
122 const quicly_cid_plaintext_t *
id)
124 kv->
key[0] = ((
u64) id->master_id) << 32 | (
u64) id->thread_id;
125 kv->
key[1] = id->node_id;
137 static quicly_context_t *
149 static quicly_context_t *
165 quicly_stream_t *stream;
179 quicly_stream_sync_recvbuf (stream, stream_data->
app_rx_data_len - max_deq);
201 tw_timer_wheel_1t_3w_1024sl_ov_t *tw;
205 QUIC_DBG (2,
"Deleting connection %u", ctx->c_c_index);
219 QUIC_DBG (2,
"Deleting conn with id %lu %lu from map", kv.
key[0],
226 quicly_free (ctx->
conn);
247 const quicly_event_attribute_t * attributes,
248 size_t num_attributes)
250 if (type == QUICLY_EVENT_TYPE_PACKET_LOST)
257 quicly_event_logger_t *
273 struct st_quicly_default_event_log_t *
self = (
void *) _self;
284 QUIC_DBG (2,
"QUIC connection %u/%u closed", ctx->c_thread_index,
330 len = packet->data.len;
336 QUIC_DBG (1,
"Too much data to send, max_enqueue %u, len %u",
351 ASSERT (packet->sa.sa_family == AF_INET);
352 struct sockaddr_in *sa4 = (
struct sockaddr_in *) &packet->sa;
354 hdr.
rmt_ip.ip4.as_u32 = sa4->sin_addr.s_addr;
358 ASSERT (packet->sa.sa_family == AF_INET6);
359 struct sockaddr_in6 *sa6 = (
struct sockaddr_in6 *) &packet->sa;
365 if (ret !=
sizeof (hdr))
367 QUIC_DBG (1,
"Not enough space to enqueue header");
373 QUIC_DBG (1,
"Not enough space to enqueue payload");
388 size_t num_packets,
i, max_packets;
389 quicly_packet_allocator_t *pa;
390 quicly_context_t *quicly_context;
415 clib_warning (
"Tried to send packets on non existing app worker %u",
420 pa = quicly_context->packet_allocator;
426 num_packets = max_packets;
427 if ((err = quicly_send (conn, packets, &num_packets)))
430 for (i = 0; i != num_packets; ++
i)
435 pa->free_packet (pa, packets[i]);
438 while (num_packets > 0 && num_packets == max_packets);
453 if (err && err != QUICLY_ERROR_PACKET_IGNORED
454 && err != QUICLY_ERROR_FREE_CONNECTION)
474 session_get (sctx->c_s_index, sctx->c_thread_index);
475 QUIC_DBG (2,
"DESTROYED_STREAM: session 0x%lx (%U)",
493 session_get (sctx->c_s_index, sctx->c_thread_index);
494 clib_warning (
"(NOT IMPLEMENTD) STOP_SENDING: session 0x%lx (%U)",
509 session_get (sctx->c_s_index, sctx->c_thread_index);
521 QUIC_DBG (3,
"received data: %lu bytes, offset %lu", len, off);
536 QUIC_DBG (3,
"Enqueuing %u at off %u in %u space", len, off, max_enq);
539 QUIC_DBG (1,
"Error RX fifo is full");
576 quicly_stream_sync_sendbuf (stream, 0);
581 size_t *
len,
int *wrote_all)
585 u32 deq_max, first_deq, max_rd_chunk, rem_offset;
590 QUIC_DBG (3,
"Emitting %u, offset %u", *len, off);
594 if (off + *len < deq_max)
601 *len = deq_max - off;
602 QUIC_DBG (3,
"Wrote ALL, %u", *len);
609 if (off < max_rd_chunk)
611 first_deq =
clib_min (*len, max_rd_chunk - off);
615 if (max_rd_chunk < off + *len)
617 rem_offset = max_rd_chunk < off ? off - max_rd_chunk : 0;
637 quicly_stream_t *stream = (quicly_stream_t *) s;
638 session_t *stream_session, *quic_session;
653 if (quicly_connection_is_ready (qctx->
conn))
656 if (quicly_is_client (qctx->
conn))
666 QUIC_DBG (2,
"ACCEPTED stream_session 0x%lx ctx %u",
672 sctx->c_c_index = sctx_id;
679 stream_data->
ctx_id = sctx_id;
689 quic_session =
session_get (qctx->c_s_index, qctx->c_thread_index);
695 QUIC_DBG (1,
"failed to allocate fifos");
706 QUIC_DBG (1,
"failed to notify accept worker app");
716 QUIC_DBG (2,
"on_stream_open called");
721 if (!quicly_stream_is_self_initiated (stream))
728 int code, uint64_t frame_type,
729 const char *reason,
size_t reason_len)
734 clib_warning (
"Session 0x%lx closed by peer (%U) %.*s ",
787 tw_timer_wheel_1t_3w_1024sl_ov_t *tw;
791 tw_timer_expire_timers_1t_3w_1024sl_ov (tw, now);
798 QUIC_DBG (4,
"Timer expired for conn %u at %ld", conn_index,
808 tw_timer_wheel_1t_3w_1024sl_ov_t *tw;
809 int64_t next_timeout, next_interval;
813 next_timeout = quicly_get_first_timeout (ctx->
conn);
816 if (next_timeout == 0 || next_interval <= 0)
824 quic_session =
session_get (ctx->c_s_index, ctx->c_thread_index);
835 QUIC_DBG (4,
"Timer set to %ld (int %ld) for ctx %u", next_timeout,
836 next_interval, ctx->c_c_index);
840 if (next_timeout == INT64_MAX)
842 QUIC_DBG (4,
"timer for ctx %u already stopped", ctx->c_c_index);
846 tw_timer_start_1t_3w_1024sl_ov (tw, ctx->c_c_index, 0, next_interval);
850 if (next_timeout == INT64_MAX)
854 QUIC_DBG (4,
"Stopping timer for ctx %u", ctx->c_c_index);
868 for (i = 0; i <
vec_len (expired_timers); i++)
882 int is_encrypt, ptls_buffer_t *
dst, ptls_iovec_t
src)
891 free (self->data.base);
892 if ((self->data.base = malloc (src.len)) == NULL)
893 return PTLS_ERROR_NO_MEMORY;
895 ptls_get_context (tls)->random_bytes (self->id, sizeof (self->id));
896 memcpy (self->data.base, src.base, src.len);
897 self->data.len = src.len;
900 if ((ret = ptls_buffer_reserve (dst,
sizeof (self->id))) != 0)
902 memcpy (dst->base + dst->off, self->id, sizeof (self->id));
903 dst->off +=
sizeof (
self->id);
910 if (src.len != sizeof (self->id))
911 return PTLS_ERROR_SESSION_NOT_FOUND;
912 if (memcmp (self->id, src.base, sizeof (self->id)) != 0)
913 return PTLS_ERROR_SESSION_NOT_FOUND;
916 if ((ret = ptls_buffer_reserve (dst, self->data.len)) != 0)
918 memcpy (dst->base + dst->off, self->data.base, self->data.len);
919 dst->off +=
self->data.len;
936 quicly_context_t *quicly_ctx;
937 ptls_iovec_t key_vec;
943 clib_memset (quicly_ctx_data, 0,
sizeof (*quicly_ctx_data));
945 ptls_context_t *ptls_ctx = &quicly_ctx_data->
ptls_ctx;
946 ptls_ctx->random_bytes = ptls_openssl_random_bytes;
947 ptls_ctx->get_time = &ptls_get_time;
948 ptls_ctx->key_exchanges = ptls_openssl_key_exchanges;
950 ptls_ctx->certificates.list = NULL;
951 ptls_ctx->certificates.count = 0;
952 ptls_ctx->esni = NULL;
953 ptls_ctx->on_client_hello = NULL;
954 ptls_ctx->emit_certificate = NULL;
955 ptls_ctx->sign_certificate = NULL;
956 ptls_ctx->verify_certificate = NULL;
957 ptls_ctx->ticket_lifetime = 86400;
958 ptls_ctx->max_early_data_size = 8192;
959 ptls_ctx->hkdf_label_prefix__obsolete = NULL;
960 ptls_ctx->require_dhe_on_psk = 1;
964 memcpy (quicly_ctx, &quicly_spec_context,
sizeof (quicly_context_t));
967 quicly_ctx->tls = ptls_ctx;
971 quicly_amend_ptls_context (quicly_ctx->tls);
973 quicly_ctx->event_log.mask = UINT64_MAX;
977 quicly_ctx->transport_params.max_streams_uni = (uint64_t) 1 << 60;
978 quicly_ctx->transport_params.max_streams_bidi = (uint64_t) 1 << 60;
979 quicly_ctx->transport_params.max_stream_data.bidi_local = (qm->
udp_fifo_size - 1);
980 quicly_ctx->transport_params.max_stream_data.bidi_remote = (qm->
udp_fifo_size - 1);
981 quicly_ctx->transport_params.max_stream_data.uni =
QUIC_INT_MAX;
983 quicly_ctx->tls->random_bytes (quicly_ctx_data->
cid_key, 16);
984 quicly_ctx_data->
cid_key[16] = 0;
986 ptls_iovec_init (quicly_ctx_data->
cid_key,
987 strlen (quicly_ctx_data->
cid_key));
988 quicly_ctx->cid_encryptor =
989 quicly_new_default_cid_encryptor (&ptls_openssl_bfecb,
990 &ptls_openssl_sha256, key_vec);
997 QUIC_DBG (1,
"failed to read private key from app configuration\n");
1002 QUIC_DBG (1,
"failed to load certificate\n");
1016 uint64_t quic_session_handle;
1019 quicly_stream_t *stream;
1020 quicly_conn_t *conn;
1028 QUIC_DBG (2,
"Opening new stream (qsession %u)", quic_session_handle);
1031 TRANSPORT_PROTO_QUIC)
1033 QUIC_DBG (1,
"received incompatible session");
1040 QUIC_DBG (1,
"Invalid app worker :(");
1050 QUIC_DBG (1,
"session is a stream");
1058 sctx->c_c_index = sctx_index;
1064 if (!conn || !quicly_connection_is_ready (conn))
1067 if ((rv = quicly_open_stream (conn, &stream, 0 )))
1069 QUIC_DBG (2,
"Stream open failed with %d", rv);
1074 QUIC_DBG (2,
"Opened stream %d, creating session", stream->stream_id);
1077 QUIC_DBG (2,
"Allocated stream_session 0x%lx ctx %u",
1089 QUIC_DBG (1,
"failed to app_worker_init_connected");
1103 QUIC_DBG (1,
"failed to notify app");
1110 stream_data->
ctx_id = sctx->c_c_index;
1131 ctx->c_c_index = ctx_index;
1146 cargs->sep.transport_proto = TRANSPORT_PROTO_UDPC;
1148 cargs->api_context = ctx_index;
1153 cargs->sep_ext.ns_index = app->
ns_index;
1166 QUIC_DBG (2,
"Called quic_connect");
1186 session_get (ctx->c_s_index, ctx->c_thread_index);
1191 quicly_stream_t *stream = ctx->
stream;
1201 quicly_conn_t *conn = ctx->
conn;
1246 sep->transport_proto = TRANSPORT_PROTO_UDPC;
1247 memset (args, 0,
sizeof (*args));
1249 args->sep_ext = *sep;
1250 args->sep_ext.ns_index = app->
ns_index;
1255 udp_handle = args->handle;
1258 udp_listen_session->
opaque = lctx_index;
1263 clib_memcpy (&lctx->c_rmt_ip, &args->sep.peer.ip, sizeof (ip46_address_t));
1264 clib_memcpy (&lctx->c_lcl_ip, &args->sep.ip, sizeof (ip46_address_t));
1265 lctx->c_rmt_port = args->sep.peer.port;
1266 lctx->c_lcl_port = args->sep.port;
1267 lctx->c_is_ip4 = args->sep.is_ip4;
1268 lctx->c_fib_index = args->sep.fib_index;
1269 lctx->c_proto = TRANSPORT_PROTO_QUIC;
1273 lctx->c_s_index = quic_listen_session_index;
1275 QUIC_DBG (2,
"Listening UDP session 0x%lx",
1277 QUIC_DBG (2,
"Listening QUIC session 0x%lx", quic_listen_session_index);
1284 QUIC_DBG (2,
"Called quic_stop_listen");
1313 QUIC_DBG (2,
"Called quic_listener_get");
1323 u32 verbose = va_arg (*args,
u32);
1328 str =
format (str,
"[#%d][Q] ", ctx->c_thread_index);
1333 str =
format (str,
"Stream %ld conn %d",
1336 str =
format (str,
"Conn %d UDP %d", ctx->c_c_index,
1345 s =
format (s,
"%s\n", str);
1353 u32 qc_index = va_arg (*args,
u32);
1354 u32 thread_index = va_arg (*args,
u32);
1355 u32 verbose = va_arg (*args,
u32);
1364 u32 qc_index = va_arg (*args,
u32);
1365 u32 thread_index = va_arg (*args,
u32);
1376 u32 tci = va_arg (*args,
u32);
1377 u32 thread_index = va_arg (*args,
u32);
1378 u32 verbose = va_arg (*args,
u32);
1397 struct sockaddr_in *sa4 = (
struct sockaddr_in *) sa;
1398 sa4->sin_family = AF_INET;
1399 sa4->sin_port =
port;
1400 sa4->sin_addr.s_addr = addr->ip4.as_u32;
1401 *salen =
sizeof (
struct sockaddr_in);
1405 struct sockaddr_in6 *sa6 = (
struct sockaddr_in6 *) sa;
1406 sa6->sin6_family = AF_INET6;
1407 sa6->sin6_port =
port;
1409 *salen =
sizeof (
struct sockaddr_in6);
1418 u32 ctx_id = ctx->c_c_index;
1419 u32 thread_index = ctx->c_thread_index;
1441 QUIC_DBG (1,
"failed to app_worker_init_connected");
1450 QUIC_DBG (1,
"failed to notify app %d", rv);
1461 quic_session =
session_get (ctx->c_s_index, thread_index);
1472 ptls_context_t **tls;
1473 quicly_context_t **_quicly_context;
1474 _quicly_context = (quicly_context_t **) conn;
1475 *_quicly_context = quicly_context;
1476 tls = (ptls_context_t **) quicly_get_tls (conn);
1477 *tls = quicly_context->tls;
1486 quicly_conn_t *conn;
1487 quicly_context_t *quicly_context;
1494 QUIC_DBG (2,
"Received conn %u (now %u)", temp_ctx->c_thread_index,
1498 memcpy (new_ctx, temp_ctx,
sizeof (
quic_ctx_t));
1501 new_ctx->c_thread_index = thread_index;
1502 new_ctx->c_c_index = new_ctx_id;
1504 conn = new_ctx->
conn;
1510 kv.
value = ((
u64) thread_index) << 32 | (
u64) new_ctx_id;
1511 QUIC_DBG (2,
"Registering conn with id %lu %lu", kv.
key[0], kv.
key[1]);
1521 QUIC_DBG (4,
"Cannot send TX event");
1527 tw_timer_wheel_1t_3w_1024sl_ov_t *tw;
1531 QUIC_DBG (2,
"Transferring conn %u to thread %u", ctx_index, dest_thread);
1556 QUIC_DBG (2,
"QSession is now connected (id %u)",
1561 struct sockaddr_in6 sa6;
1562 struct sockaddr *sa = (
struct sockaddr *) &sa6;
1566 quicly_conn_t *conn;
1570 quicly_context_t *quicly_ctx;
1580 api_context = ctx->c_s_index;
1586 ctx->c_thread_index = thread_index;
1587 ctx->c_c_index = ctx_index;
1589 QUIC_DBG (2,
"Quic connect returned %u. New ctx [%u]%x",
1590 is_fail, thread_index, (ctx) ? ctx_index : ~0);
1612 kv.
value = ((
u64) thread_index) << 32 | (
u64) ctx_index;
1613 QUIC_DBG (2,
"Registering conn with id %lu %lu", kv.
key[0], kv.
key[1]);
1654 if (ctx->udp_session_handle == old_session_handle)
1657 QUIC_DBG (5,
"Found right ctx: %x", ctx->c_c_index);
1658 ctx->udp_session_handle = new_sh;
1659 quic_transfer_connection (ctx->c_c_index, new_thread);
1664 QUIC_DBG (0,
"BUG: Connection to migrate not found");
1677 udp_listen_session =
1683 ctx->c_c_index = ctx_index;
1702 *pool_index = ctx_index;
1711 QUIC_DBG (2,
"Called quic_add_segment_callback");
1720 QUIC_DBG (2,
"Called quic_del_segment_callback");
1731 QUIC_DBG (3,
"Received app READ notification");
1746 quicly_stream_t *stream;
1751 (stream_session->
session_state >= SESSION_STATE_TRANSPORT_CLOSING))
1767 if (!quicly_sendstate_is_open (&stream->sendstate))
1769 QUIC_DBG (1,
"Warning: tried to send on closed stream");
1773 if ((rv = quicly_stream_sync_sendbuf (stream, 1)) != 0)
1790 struct sockaddr *sa, socklen_t salen,
1791 quicly_decoded_packet_t * packet,
1792 u32 caller_thread_index)
1795 quicly_conn_t *conn_;
1797 clib_bihash_16_8_t *
h;
1801 QUIC_DBG (3,
"Searching conn with id %lu %lu", kv.
key[0], kv.
key[1]);
1803 if (clib_bihash_search_16_8 (h, &kv, &kv) == 0)
1809 if (thread_id != caller_thread_index)
1811 QUIC_DBG (2,
"Connection is on wrong thread");
1814 *ctx_thread = thread_id;
1819 if (conn_ && quicly_is_destination (conn_, sa, salen, packet))
1823 *ctx_thread = thread_id;
1827 QUIC_DBG (3,
"connection not found");
1840 QUIC_DBG (2,
"Allocated quic_session, 0x%lx ctx %u",
1857 QUIC_DBG (1,
"failed to allocate fifos");
1864 QUIC_DBG (1,
"failed to notify accept worker app");
1872 socklen_t salen, quicly_decoded_packet_t packet)
1876 quicly_conn_t *conn;
1878 quicly_context_t *quicly_ctx;
1885 if ((rv = quicly_accept (&conn, quicly_ctx, sa, salen,
1886 &packet, ptls_iovec_init (NULL, 0),
1891 QUIC_DBG (1,
"Accept failed with %d", rv);
1907 kv.
value = ((
u64) thread_index) << 32 | (
u64) ctx_index;
1909 QUIC_DBG (2,
"Registering conn with id %lu %lu", kv.
key[0], kv.
key[1]);
1916 struct sockaddr *sa, socklen_t salen,
1917 quicly_decoded_packet_t packet)
1924 QUIC_DBG (2,
"Sending stateless reset");
1926 quicly_datagram_t *dgram;
1928 quicly_context_t *quicly_ctx;
1929 if (packet.cid.dest.plaintext.node_id != 0
1930 || packet.cid.dest.plaintext.thread_id != 0)
1933 dgram = quicly_send_stateless_reset (quicly_ctx, sa, salen,
1934 &packet.cid.dest.plaintext);
1961 if (quicly_connection_is_ready (ctx->
conn))
1964 if (quicly_is_client (ctx->
conn))
1975 quicly_context_t * quicly_ctx,
svm_fifo_t * f,
1976 u32 * fifo_offset,
u32 * max_packet,
u32 packet_n,
1982 struct sockaddr_in6 sa6;
1983 struct sockaddr *sa = (
struct sockaddr *) &sa6;
1990 u32 *opening_ctx_pool, *ctx_index_ptr;
1995 *max_packet = packet_n + 1;
2001 QUIC_DBG (1,
"Not enough data for even a header in RX");
2007 QUIC_DBG (1,
"Not enough data for header in RX");
2010 ASSERT (ph.data_offset == 0);
2012 if (full_len > cur_deq)
2014 QUIC_DBG (1,
"Not enough data in fifo RX");
2023 if (ret != ph.data_length)
2025 QUIC_DBG (1,
"Not enough data peeked in RX");
2034 quicly_decode_packet (quicly_ctx, &packet_ctx->
packet, packet_ctx->
data,
2037 if (plen == SIZE_MAX)
2045 sa, salen, &packet_ctx->
packet, thread_index);
2049 rv = quicly_receive (ctx->
conn, &packet_ctx->
packet);
2051 QUIC_DBG (1,
"quicly_receive return error %d", rv);
2053 else if (packet_ctx->
ctx_index != UINT32_MAX)
2056 *max_packet = packet_n + 1;
2073 *max_packet = packet_n + 1;
2076 pool_put (opening_ctx_pool, ctx_index_ptr);
2110 QUIC_DBG (1,
"Got RX on detached app");
2125 u32 fifo_offset = 0;
2126 u32 max_packets = 16;
2127 for (
int i = 0;
i < max_packets;
i++)
2131 &fifo_offset, &max_packets,
i,
2135 for (
int i = 0;
i < max_packets;
i++)
2137 if (packets_ctx[
i].thread_index != thread_index)
2143 packets_ctx[i].thread_index);
2221 .transport_options = {
2230 ptls_cipher_suite_t ** ciphers)
2247 (
"error while getting segment_manager_props_t, can't update fifo-size");
2258 u32 segment_size = 256 << 20;
2260 tw_timer_wheel_1t_3w_1024sl_ov_t *tw;
2268 memset (a, 0,
sizeof (*a));
2269 memset (options, 0,
sizeof (options));
2274 a->name =
format (0,
"quic");
2293 for (i = 0; i < num_threads; i++)
2301 clib_bihash_init_16_8 (&qm->
connection_hash,
"quic connections", 1024,
2317 ptls_openssl_cipher_suites);
2336 else if (
unformat (input,
"picotls"))
2371 quicly_stats_t quicly_stats;
2373 quicly_get_stats (ctx->
conn, &quicly_stats);
2375 s =
format (s,
"\n\rQUIC conn stats \n\r");
2378 format (s,
"RTT: min:%d, smoothed:%d, variance:%d, latest:%d \n\r",
2379 quicly_stats.rtt.minimum, quicly_stats.rtt.smoothed,
2380 quicly_stats.rtt.variance, quicly_stats.rtt.latest);
2381 s =
format (s,
"Packet loss:%d \n\r", quicly_stats.num_packets.lost);
2395 for (
int i = 0;
i < num_workers + 1;
i++)
2400 if(!(ctx->flags & QUIC_F_IS_LISTENER) && !(ctx->flags & QUIC_F_IS_STREAM))
2401 vlib_cli_output (vm,
"%U", quic_format_ctx_stat, ctx);
2411 .path =
"quic set crypto api",
2412 .short_help =
"quic set crypto api [picotls, vpp]",
2417 .path =
"quic set fifo-size",
2418 .short_help =
"quic set fifo-size N[Kb|Mb|GB] (default 64K)",
2423 .path =
"show quic stats",
2424 .short_help =
"show quic stats",
2429 .version = VPP_BUILD_VER,
2430 .description =
"Quic transport protocol",
2431 .default_disabled = 1,
2472 .name =
"quic-input",
2473 .vector_size =
sizeof (
u32),
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) ...
u8 data[QUIC_MAX_PACKET_SIZE]
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)
static u8 * quic_format_ctx_stat(u8 *s, va_list *args)
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.
struct quic_rx_packet_ctx_ quic_rx_packet_ctx_t
u32 ns_index
Namespace the application belongs to.
static clib_error_t * quic_plugin_set_fifo_size_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
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
ptls_cipher_suite_t * quic_crypto_cipher_suites[]
#define QUIC_TSTAMP_RESOLUTION
u32 session_index
Index in thread pool where session was allocated.
quicly_event_logger_t * quic_new_event_logger()
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)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
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)
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)
void quic_event_log(quicly_event_logger_t *_self, quicly_event_type_t type, const quicly_event_attribute_t *attributes, size_t num_attributes)
#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)
static uword quic_node_fn(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
#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)
#define QUIC_DEFAULT_FIFO_SIZE
struct _vnet_disconnect_args_t vnet_disconnect_args_t
static clib_error_t * quic_plugin_showstats_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static u32 svm_fifo_max_dequeue(svm_fifo_t *f)
Fifo max bytes to dequeue.
static int quic_process_one_rx_packet(u64 udp_session_handle, quicly_context_t *quicly_ctx, svm_fifo_t *f, u32 *fifo_offset, u32 *max_packet, u32 packet_n, quic_rx_packet_ctx_t *packet_ctx)
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)
static clib_error_t * quic_config_fn(vlib_main_t *vm, unformat_input_t *input)
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.
void quic_free_event_logger(quicly_event_logger_t *_self)
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)
static void check_quic_client_connected(struct quic_rx_packet_ctx_ *quic_rx_ctx)
#define pool_put(P, E)
Free an object E in pool P.
#define APP_INVALID_INDEX
struct _segment_manager_props segment_manager_props_t
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)
static void quic_update_conn_ctx(quicly_conn_t *conn, quicly_context_t *quicly_context)
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 char * quic_error_strings[]
static u64 listen_session_get_handle(session_t *s)
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
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
#define VLIB_EARLY_CONFIG_FUNCTION(x, n,...)
static quicly_stream_open_t on_stream_open
#define VLIB_REGISTER_NODE(x,...)
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,...)
segment_manager_props_t * application_get_segment_manager_properties(u32 app_index)
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
quicly_decoded_packet_t packet
enum quic_crypto_engine_ quic_crypto_engine_t
u32 opaque
Opaque, for general use.
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)
void quic_increment_counter(u8 evt, u8 val)
static int quic_on_stop_sending(quicly_stream_t *stream, int err)
int session_send_io_evt_to_thread_custom(void *data, u32 thread_index, session_evt_type_t evt_type)
quicly_event_logger_t super
u32 app_index
Index of owning app.
static struct option options[]
static void quic_ctx_free(quic_ctx_t *ctx)
static vlib_thread_main_t * vlib_get_thread_main()
static u32 vlib_num_workers()
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 void quic_update_fifo_size()
vlib_node_registration_t quic_input_node
(constructor) VLIB_REGISTER_NODE (quic_input_node)
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)