quic: Hotfix crypto context on migrate 48/24048/2
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>
Wed, 18 Dec 2019 12:37:45 +0000 (13:37 +0100)
committerDave Wallace <dwallacelf@gmail.com>
Wed, 18 Dec 2019 14:19:05 +0000 (14:19 +0000)
Type: fix

quicly_connections have internal references to crypto
contexts which need to be updated when we switch thread
as the supporting pools are thread-based.
This under the assumption that the new contexts will be
exactly identical

Change-Id: I38083e59657ff068e347d9e7b47abe91a1167b6c
Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
src/plugins/quic/quic.c

index 7382901..04c756a 100644 (file)
@@ -1607,6 +1607,19 @@ quic_check_quic_session_connected (quic_ctx_t * ctx)
   quic_on_quic_session_connected (ctx);
 }
 
+static inline void
+quic_update_conn_ctx (quicly_conn_t * conn, quicly_context_t * quicly_context)
+{
+  /* we need to update the quicly_conn on migrate
+   * as it contains a pointer to the crypto context */
+  ptls_context_t **tls;
+  quicly_context_t **_quicly_context;
+  _quicly_context = (quicly_context_t **) conn;
+  *_quicly_context = quicly_context;
+  tls = (ptls_context_t **) quicly_get_tls (conn);
+  *tls = quicly_context->tls;
+}
+
 static void
 quic_receive_connection (void *arg)
 {
@@ -1614,6 +1627,7 @@ quic_receive_connection (void *arg)
   quic_ctx_t *temp_ctx, *new_ctx;
   clib_bihash_kv_16_8_t kv;
   quicly_conn_t *conn;
+  quicly_context_t *quicly_context;
   session_t *udp_session;
 
   temp_ctx = arg;
@@ -1631,6 +1645,9 @@ quic_receive_connection (void *arg)
   quic_acquire_crypto_context (new_ctx);
 
   conn = new_ctx->conn;
+  quicly_context = quic_get_quicly_ctx_from_ctx (new_ctx);
+  quic_update_conn_ctx (conn, quicly_context);
+
   quic_store_conn_ctx (conn, new_ctx);
   quic_make_connection_key (&kv, quicly_get_master_id (conn));
   kv.value = ((u64) thread_index) << 32 | (u64) new_ctx_id;