Type: fix
Add SESSION_F_IS_MIGRATING flag for session. It is set by the session
layer before poking the transport for migration. It's the transport
responsibility to unset the flag & act apropriatly if RX happens on
a migrating session.
Change-Id: Ie722917f1cf9344d8f041cad4ed8b064fb5853b6
Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
static void
quic_ctx_free (quic_ctx_t * ctx)
{
static void
quic_ctx_free (quic_ctx_t * ctx)
{
- QUIC_DBG (2, "Free ctx %u", ctx->c_c_index);
+ QUIC_DBG (2, "Free ctx %u %x", ctx->c_thread_index, ctx->c_c_index);
u32 thread_index = ctx->c_thread_index;
if (CLIB_DEBUG)
clib_memset (ctx, 0xfb, sizeof (*ctx));
u32 thread_index = ctx->c_thread_index;
if (CLIB_DEBUG)
clib_memset (ctx, 0xfb, sizeof (*ctx));
static quicly_context_t *
quic_get_quicly_ctx_from_ctx (quic_ctx_t * ctx)
{
static quicly_context_t *
quic_get_quicly_ctx_from_ctx (quic_ctx_t * ctx)
{
- app_worker_t *app_wrk;
- application_t *app;
- app_wrk = app_worker_get_if_valid (ctx->parent_app_wrk_id);
- if (!app_wrk)
- return 0;
- app = application_get (app_wrk->app_index);
- return (quicly_context_t *) app->quicly_ctx;
+ return ctx->quicly_ctx;
}
static quicly_context_t *
quic_get_quicly_ctx_from_udp (u64 udp_session_handle)
{
}
static quicly_context_t *
quic_get_quicly_ctx_from_udp (u64 udp_session_handle)
{
- session_t *udp_session;
- application_t *app;
- udp_session = session_get_from_handle (udp_session_handle);
- app = application_get (udp_session->opaque);
- return (quicly_context_t *) app->quicly_ctx;
+ session_t *udp_session = session_get_from_handle (udp_session_handle);
+ quic_ctx_t *ctx =
+ quic_ctx_get (udp_session->opaque, udp_session->thread_index);
+ return ctx->quicly_ctx;
quic_connection_delete (ctx);
break;
default:
quic_connection_delete (ctx);
break;
default:
+ QUIC_DBG (0, "BUG %d", ctx->conn_state);
cargs->sep_ext.ns_index = app->ns_index;
quic_store_quicly_ctx (app, 1 /* is client */ );
cargs->sep_ext.ns_index = app->ns_index;
quic_store_quicly_ctx (app, 1 /* is client */ );
+ /* Also store it in ctx for convenience
+ * Waiting for crypto_ctx logic */
+ ctx->quicly_ctx = (quicly_context_t *) app->quicly_ctx;
if ((error = vnet_connect (cargs)))
return error;
if ((error = vnet_connect (cargs)))
return error;
lctx = quic_ctx_get (lctx_index, 0);
lctx->flags |= QUIC_F_IS_LISTENER;
lctx = quic_ctx_get (lctx_index, 0);
lctx->flags |= QUIC_F_IS_LISTENER;
+ /* Also store it in ctx for convenience
+ * Waiting for crypto_ctx logic */
+ lctx->quicly_ctx = (quicly_context_t *) app->quicly_ctx;
clib_memcpy (&lctx->c_rmt_ip, &args->sep.peer.ip, sizeof (ip46_address_t));
clib_memcpy (&lctx->c_lcl_ip, &args->sep.ip, sizeof (ip46_address_t));
clib_memcpy (&lctx->c_rmt_ip, &args->sep.peer.ip, sizeof (ip46_address_t));
clib_memcpy (&lctx->c_lcl_ip, &args->sep.ip, sizeof (ip46_address_t));
/* Trigger write on this connection if necessary */
udp_session = session_get_from_handle (new_ctx->udp_session_handle);
/* Trigger write on this connection if necessary */
udp_session = session_get_from_handle (new_ctx->udp_session_handle);
+ udp_session->opaque = new_ctx_id;
+ udp_session->flags &= ~SESSION_F_IS_MIGRATING;
if (svm_fifo_max_dequeue (udp_session->tx_fifo))
quic_set_udp_tx_evt (udp_session);
}
if (svm_fifo_max_dequeue (udp_session->tx_fifo))
quic_set_udp_tx_evt (udp_session);
}
is_fail, thread_index, (ctx) ? ctx_index : ~0);
ctx->udp_session_handle = session_handle (udp_session);
is_fail, thread_index, (ctx) ? ctx_index : ~0);
ctx->udp_session_handle = session_handle (udp_session);
- udp_session->opaque = ctx->parent_app_id;
+ udp_session->opaque = ctx_index;
/* Init QUIC lib connection
* Generate required sockaddr & salen */
/* Init QUIC lib connection
* Generate required sockaddr & salen */
static void
quic_udp_session_migrate_callback (session_t * s, session_handle_t new_sh)
{
static void
quic_udp_session_migrate_callback (session_t * s, session_handle_t new_sh)
{
- /*
- * TODO we need better way to get the connection from the session
- * This will become possible once we stop storing the app id in the UDP
- * session opaque
- */
- u32 thread_index = vlib_get_thread_index ();
- u64 old_session_handle = session_handle (s);
u32 new_thread = session_thread_from_handle (new_sh);
quic_ctx_t *ctx;
QUIC_DBG (1, "Session %x migrated to %lx", s->session_index, new_sh);
u32 new_thread = session_thread_from_handle (new_sh);
quic_ctx_t *ctx;
QUIC_DBG (1, "Session %x migrated to %lx", s->session_index, new_sh);
- /* *INDENT-OFF* */
- pool_foreach (ctx, quic_main.ctx_pool[thread_index],
- ({
- if (ctx->udp_session_handle == old_session_handle)
- {
- /* Right ctx found, move associated conn */
- QUIC_DBG (5, "Found right ctx: %x", ctx->c_c_index);
- ctx->udp_session_handle = new_sh;
- quic_transfer_connection (ctx->c_c_index, new_thread);
- return;
- }
- }));
- /* *INDENT-ON* */
- QUIC_DBG (0, "BUG: Connection to migrate not found");
+ ASSERT (vlib_get_thread_index () == s->thread_index);
+ ctx = quic_ctx_get (s->opaque, s->thread_index);
+ ASSERT (ctx->udp_session_handle == session_handle (s));
+
+ ctx->udp_session_handle = new_sh;
+#if QUIC_DEBUG >= 1
+ s->opaque = 0xfeedface;
+#endif
+ quic_transfer_connection (ctx->c_c_index, new_thread);
ctx->conn_state = QUIC_CONN_STATE_OPENED;
ctx->c_flags |= TRANSPORT_CONNECTION_F_NO_LOOKUP;
ctx->conn_state = QUIC_CONN_STATE_OPENED;
ctx->c_flags |= TRANSPORT_CONNECTION_F_NO_LOOKUP;
- udp_session->opaque = ctx->parent_app_id;
+ /* Also store it in ctx for convenience
+ * Waiting for crypto_ctx logic */
+ ctx->quicly_ctx = lctx->quicly_ctx;
+
+ udp_session->opaque = ctx_index;
/* Put this ctx in the "opening" pool */
pool_get (quic_main.wrk_ctx[ctx->c_thread_index].opening_ctx_pool,
/* Put this ctx in the "opening" pool */
pool_get (quic_main.wrk_ctx[ctx->c_thread_index].opening_ctx_pool,
-quic_process_one_rx_packet (u64 udp_session_handle,
- quicly_context_t * quicly_ctx, svm_fifo_t * f,
+quic_process_one_rx_packet (u64 udp_session_handle, svm_fifo_t * f,
u32 * fifo_offset, u32 * max_packet, u32 packet_n,
quic_rx_packet_ctx_t * packet_ctx)
{
u32 * fifo_offset, u32 * max_packet, u32 packet_n,
quic_rx_packet_ctx_t * packet_ctx)
{
u32 thread_index = vlib_get_thread_index ();
u32 *opening_ctx_pool, *ctx_index_ptr;
u32 cur_deq = svm_fifo_max_dequeue (f) - *fifo_offset;
u32 thread_index = vlib_get_thread_index ();
u32 *opening_ctx_pool, *ctx_index_ptr;
u32 cur_deq = svm_fifo_max_dequeue (f) - *fifo_offset;
+ quicly_context_t *quicly_ctx;
quic_udp_session_rx_callback (session_t * udp_session)
{
/* Read data from UDP rx_fifo and pass it to the quicly conn. */
quic_udp_session_rx_callback (session_t * udp_session)
{
/* Read data from UDP rx_fifo and pass it to the quicly conn. */
quic_ctx_t *ctx = NULL;
svm_fifo_t *f;
u32 max_deq;
quic_ctx_t *ctx = NULL;
svm_fifo_t *f;
u32 max_deq;
- u32 app_index = udp_session->opaque;
u64 udp_session_handle = session_handle (udp_session);
int rv = 0;
u32 thread_index = vlib_get_thread_index ();
quic_rx_packet_ctx_t packets_ctx[16];
u32 i, fifo_offset, max_packets;
u64 udp_session_handle = session_handle (udp_session);
int rv = 0;
u32 thread_index = vlib_get_thread_index ();
quic_rx_packet_ctx_t packets_ctx[16];
u32 i, fifo_offset, max_packets;
- if (!(app = application_get_if_valid (app_index)))
+ if (udp_session->flags & SESSION_F_IS_MIGRATING)
- QUIC_DBG (1, "Got RX on detached app");
- /* TODO: close this session, cleanup state? */
- return 1;
+ QUIC_DBG (3, "RX on migrating udp session");
+ return 0;
fifo_offset = 0;
max_packets = 16;
for (i = 0; i < max_packets; i++)
fifo_offset = 0;
max_packets = 16;
for (i = 0; i < max_packets; i++)
- quic_process_one_rx_packet (udp_session_handle,
- (quicly_context_t *) app->quicly_ctx, f,
- &fifo_offset, &max_packets, i,
- &packets_ctx[i]);
+ quic_process_one_rx_packet (udp_session_handle, f, &fifo_offset,
+ &max_packets, i, &packets_ctx[i]);
for (i = 0; i < max_packets; i++)
{
for (i = 0; i < max_packets; i++)
{
u32 parent_app_wrk_id;
u32 parent_app_id;
u8 flags;
u32 parent_app_wrk_id;
u32 parent_app_id;
u8 flags;
+ quicly_context_t *quicly_ctx;
} quic_ctx_t;
/* Make sure our custom fields don't overlap with the fields we use in
} quic_ctx_t;
/* Make sure our custom fields don't overlap with the fields we use in
new_s->rx_fifo->master_session_index = new_s->session_index;
new_s->rx_fifo->master_thread_index = new_s->thread_index;
new_s->session_state = SESSION_STATE_READY;
new_s->rx_fifo->master_session_index = new_s->session_index;
new_s->rx_fifo->master_thread_index = new_s->thread_index;
new_s->session_state = SESSION_STATE_READY;
+ new_s->flags |= SESSION_F_IS_MIGRATING;
session_lookup_add_connection (tc, session_handle (new_s));
/*
session_lookup_add_connection (tc, session_handle (new_s));
/*
SESSION_F_RX_EVT = 1,
SESSION_F_PROXY = (1 << 1),
SESSION_F_CUSTOM_TX = (1 << 2),
SESSION_F_RX_EVT = 1,
SESSION_F_PROXY = (1 << 1),
SESSION_F_CUSTOM_TX = (1 << 2),
+ SESSION_F_IS_MIGRATING = (1 << 3),
} session_flags_t;
typedef struct session_
} session_flags_t;
typedef struct session_