aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>2019-12-02 17:12:22 +0100
committerDave Wallace <dwallacelf@gmail.com>2019-12-04 15:04:02 +0000
commitdeb268febb3a06102f55259e57c54f0e02b1613e (patch)
tree529c9d1a9dc753b1ee33846def33b57f76239fb4
parent2f566c23fbac5c36cf95db8c0f738abbd3b5555c (diff)
quic: refactor connection search fn
Type: refactor Change-Id: I55aace44773e4fab0470d27b14dd68544f7d99c5 Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
-rw-r--r--src/plugins/quic/quic.c58
1 files changed, 31 insertions, 27 deletions
diff --git a/src/plugins/quic/quic.c b/src/plugins/quic/quic.c
index 983358ea852..6c2dd6af316 100644
--- a/src/plugins/quic/quic.c
+++ b/src/plugins/quic/quic.c
@@ -1715,42 +1715,46 @@ tx_end:
static inline int
quic_find_packet_ctx (quic_rx_packet_ctx_t * pctx, u32 caller_thread_index)
{
- quic_ctx_t *ctx_;
- quicly_conn_t *conn_;
clib_bihash_kv_16_8_t kv;
clib_bihash_16_8_t *h;
+ quic_ctx_t *ctx;
+ u32 index, thread_id;
h = &quic_main.connection_hash;
quic_make_connection_key (&kv, &pctx->packet.cid.dest.plaintext);
QUIC_DBG (3, "Searching conn with id %lu %lu", kv.key[0], kv.key[1]);
- if (clib_bihash_search_16_8 (h, &kv, &kv) == 0)
+ if (clib_bihash_search_16_8 (h, &kv, &kv))
{
- u32 index = kv.value & UINT32_MAX;
- u32 thread_id = kv.value >> 32;
- /* Check if this connection belongs to this thread, otherwise
- * ask for it to be moved */
- if (thread_id != caller_thread_index)
- {
- QUIC_DBG (2, "Connection is on wrong thread");
- /* Cannot make full check with quicly_is_destination... */
- pctx->ctx_index = index;
- pctx->thread_index = thread_id;
- return QUIC_PACKET_TYPE_MIGRATE;
- }
- ctx_ = quic_ctx_get (index, vlib_get_thread_index ());
- conn_ = ctx_->conn;
- if (conn_
- && quicly_is_destination (conn_, NULL, &pctx->sa, &pctx->packet))
- {
- QUIC_DBG (3, "Connection found");
- pctx->ctx_index = index;
- pctx->thread_index = thread_id;
- return QUIC_PACKET_TYPE_RECEIVE;
- }
+ QUIC_DBG (3, "connection not found");
+ return QUIC_PACKET_TYPE_NONE;
}
- QUIC_DBG (3, "connection not found");
- return QUIC_PACKET_TYPE_NONE;
+
+ index = kv.value & UINT32_MAX;
+ thread_id = kv.value >> 32;
+ /* Check if this connection belongs to this thread, otherwise
+ * ask for it to be moved */
+ if (thread_id != caller_thread_index)
+ {
+ QUIC_DBG (2, "Connection is on wrong thread");
+ /* Cannot make full check with quicly_is_destination... */
+ pctx->ctx_index = index;
+ pctx->thread_index = thread_id;
+ return QUIC_PACKET_TYPE_MIGRATE;
+ }
+ ctx = quic_ctx_get (index, vlib_get_thread_index ());
+ if (!ctx->conn)
+ {
+ QUIC_ERR ("ctx has no conn");
+ return QUIC_PACKET_TYPE_NONE;
+ }
+ if (!quicly_is_destination (ctx->conn, NULL, &pctx->sa, &pctx->packet))
+ return QUIC_PACKET_TYPE_NONE;
+
+ QUIC_DBG (3, "Connection found");
+ pctx->ctx_index = index;
+ pctx->thread_index = thread_id;
+ return QUIC_PACKET_TYPE_RECEIVE;
}
static int