aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-quic.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2018-09-19 00:40:12 +0200
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2018-09-19 05:46:11 +0000
commitfc9e404ab2dd2d76e92fc492126cc489c17d019a (patch)
tree3ca937cdfa4e992d59bfe5a1791f88041e082d87 /epan/dissectors/packet-quic.c
parentcff328d5bc11435e3486d395bc2d07945135c376 (diff)
QUIC: small connection tracking optimization
Track valid CID lengths, this makes it possible to detect whether any valid QUIC long packet is present in the capture and allows for skipping some hash-table lookups. Change-Id: I20db2ca1d40af2a9b34fffe24b4b636f358d5795 Ping-Bug: 13881 Reviewed-on: https://code.wireshark.org/review/29727 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-quic.c')
-rw-r--r--epan/dissectors/packet-quic.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/epan/dissectors/packet-quic.c b/epan/dissectors/packet-quic.c
index 0a23415852..5a142ca810 100644
--- a/epan/dissectors/packet-quic.c
+++ b/epan/dissectors/packet-quic.c
@@ -255,6 +255,7 @@ typedef struct quic_datagram {
static wmem_map_t *quic_client_connections, *quic_server_connections;
static wmem_map_t *quic_initial_connections; /* Initial.DCID -> connection */
static wmem_list_t *quic_connections; /* All unique connections. */
+static guint32 quic_cid_lengths; /* Bitmap of CID lengths. */
static guint quic_connections_count;
/* Returns the QUIC draft version or 0 if not applicable. */
@@ -649,6 +650,13 @@ quic_cids_insert(quic_cid_t *cid, quic_info_data_t *conn, gboolean from_server)
// Replace any previous CID key with the new one.
wmem_map_remove(connections, cid);
wmem_map_insert(connections, cid, conn);
+ quic_cid_lengths |= (1 << cid->len);
+}
+
+static inline gboolean
+quic_cids_is_known_length(const quic_cid_t *cid)
+{
+ return (quic_cid_lengths & (1 << cid->len)) != 0;
}
/**
@@ -669,7 +677,7 @@ quic_connection_find_dcid(packet_info *pinfo, const quic_cid_t *dcid, gboolean *
quic_info_data_t *conn = NULL;
gboolean check_ports = FALSE;
- if (dcid && dcid->len > 0) {
+ if (dcid && dcid->len > 0 && quic_cids_is_known_length(dcid)) {
conn = (quic_info_data_t *) wmem_map_lookup(quic_client_connections, dcid);
if (conn) {
// DCID recognized by client, so it was from server.
@@ -738,7 +746,9 @@ quic_connection_find(packet_info *pinfo, guint8 long_packet_type,
// actual DCID is unknown, so just keep decrementing until found.
while (!conn && dcid->len > 4) {
dcid->len--;
- conn = quic_connection_find_dcid(pinfo, dcid, from_server);
+ if (quic_cids_is_known_length(dcid)) {
+ conn = quic_connection_find_dcid(pinfo, dcid, from_server);
+ }
}
if (!conn) {
// No match found, truncate DCID (not really needed, but this
@@ -2291,6 +2301,7 @@ quic_init(void)
quic_initial_connections = wmem_map_new(wmem_file_scope(), quic_connection_hash, quic_connection_equal);
quic_client_connections = wmem_map_new(wmem_file_scope(), quic_connection_hash, quic_connection_equal);
quic_server_connections = wmem_map_new(wmem_file_scope(), quic_connection_hash, quic_connection_equal);
+ quic_cid_lengths = 0;
}
/** Release QUIC dissection state on closing a capture file. */