From 8052d0493b7bad97ac322f183a218487b605326f Mon Sep 17 00:00:00 2001 From: Libor Peltan Date: Thu, 24 Aug 2023 14:14:11 +0200 Subject: quic: set logging callbacks to NULL if unused for optimization --- src/libknot/quic/quic.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/libknot/quic/quic.c b/src/libknot/quic/quic.c index 1083de54c..141467f2b 100644 --- a/src/libknot/quic/quic.c +++ b/src/libknot/quic/quic.c @@ -760,8 +760,10 @@ static void user_qlog(void *user_data, uint32_t flags, const void *data, size_t static int conn_new(ngtcp2_conn **pconn, const ngtcp2_path *path, const ngtcp2_cid *scid, const ngtcp2_cid *dcid, const ngtcp2_cid *odcid, uint32_t version, uint64_t now, size_t udp_pl, uint64_t idle_timeout_ns, - void *user_data, bool server, bool retry_sent) + knot_quic_conn_t *qconn, bool server, bool retry_sent) { + knot_quic_table_t *qtable = qconn->quic_table; + // I. CALLBACKS const ngtcp2_callbacks callbacks = { ngtcp2_crypto_client_initial_cb, @@ -809,8 +811,12 @@ static int conn_new(ngtcp2_conn **pconn, const ngtcp2_path *path, const ngtcp2_c ngtcp2_settings settings; ngtcp2_settings_default(&settings); settings.initial_ts = now; - settings.log_printf = user_printf; - settings.qlog_write = user_qlog; + if (qtable->log_cb != NULL) { + settings.log_printf = user_printf; + } + if (qtable->qlog_dir != NULL) { + settings.qlog_write = user_qlog; + } if (udp_pl != 0) { settings.max_tx_udp_payload_size = udp_pl; } @@ -847,10 +853,10 @@ static int conn_new(ngtcp2_conn **pconn, const ngtcp2_path *path, const ngtcp2_c if (server) { return ngtcp2_conn_server_new(pconn, dcid, scid, path, version, &callbacks, - &settings, ¶ms, NULL, user_data); + &settings, ¶ms, NULL, qconn); } else { return ngtcp2_conn_client_new(pconn, dcid, scid, path, version, &callbacks, - &settings, ¶ms, NULL, user_data); + &settings, ¶ms, NULL, qconn); } } -- cgit v1.2.3 From f7e665918782bec5aeaed745d3f777f0823da6e8 Mon Sep 17 00:00:00 2001 From: Libor Peltan Date: Thu, 24 Aug 2023 14:22:34 +0200 Subject: quic: remove unnecessary argument --- src/libknot/quic/quic.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/libknot/quic/quic.c b/src/libknot/quic/quic.c index 141467f2b..2d871c724 100644 --- a/src/libknot/quic/quic.c +++ b/src/libknot/quic/quic.c @@ -759,7 +759,7 @@ static void user_qlog(void *user_data, uint32_t flags, const void *data, size_t static int conn_new(ngtcp2_conn **pconn, const ngtcp2_path *path, const ngtcp2_cid *scid, const ngtcp2_cid *dcid, const ngtcp2_cid *odcid, uint32_t version, - uint64_t now, size_t udp_pl, uint64_t idle_timeout_ns, + uint64_t now, uint64_t idle_timeout_ns, knot_quic_conn_t *qconn, bool server, bool retry_sent) { knot_quic_table_t *qtable = qconn->quic_table; @@ -817,8 +817,8 @@ static int conn_new(ngtcp2_conn **pconn, const ngtcp2_path *path, const ngtcp2_c if (qtable->qlog_dir != NULL) { settings.qlog_write = user_qlog; } - if (udp_pl != 0) { - settings.max_tx_udp_payload_size = udp_pl; + if (qtable->udp_payload_limit != 0) { + settings.max_tx_udp_payload_size = qtable->udp_payload_limit; } settings.handshake_timeout = idle_timeout_ns; // NOTE setting handshake timeout to idle_timeout for simplicity @@ -884,7 +884,7 @@ int knot_quic_client(knot_quic_table_t *table, struct sockaddr_in6 *dest, path.local.addrlen = addr_len((const struct sockaddr_in6 *)via); int ret = conn_new(&conn->conn, &path, &dcid, &scid, NULL, NGTCP2_PROTO_VER_V1, now, - table->udp_payload_limit, 5000000000L, conn, false, false); + 5000000000L, conn, false, false); if (ret == KNOT_EOK) { ret = tls_init_conn_session(conn, false); } @@ -988,8 +988,7 @@ int knot_quic_handle(knot_quic_table_t *table, knot_quic_reply_t *reply, quic_conn_mark_used(conn, table, now); ret = conn_new(&conn->conn, &path, &dcid, &scid, &odcid, decoded_cids.version, - now, table->udp_payload_limit, idle_timeout, conn, true, - header.tokenlen > 0); + now, idle_timeout, conn, true, header.tokenlen > 0); if (ret >= 0) { ret = tls_init_conn_session(conn, true); } -- cgit v1.2.3