summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibor Peltan <libor.peltan@nic.cz>2024-09-13 10:59:33 +0200
committerDaniel Salzman <daniel.salzman@nic.cz>2024-09-13 13:42:58 +0200
commitad0ea6e3a88884ac52da5d3d10f72d3c6cb23f69 (patch)
tree8d6a552ef5c5c208ae088680b7884291d84698ed /src
parenttests: flush before random_ddns() to ensure clean zonefile format (diff)
downloadknot-ad0ea6e3a88884ac52da5d3d10f72d3c6cb23f69.tar.xz
knot-ad0ea6e3a88884ac52da5d3d10f72d3c6cb23f69.zip
libknot/QUIC/DDNS: fix race when unblocking conn after sent DDNS reply
Diffstat (limited to 'src')
-rw-r--r--src/libknot/quic/quic.c3
-rw-r--r--src/libknot/quic/quic_conn.c2
2 files changed, 3 insertions, 2 deletions
diff --git a/src/libknot/quic/quic.c b/src/libknot/quic/quic.c
index baa556f98..fd5ac2a56 100644
--- a/src/libknot/quic/quic.c
+++ b/src/libknot/quic/quic.c
@@ -611,7 +611,6 @@ int knot_quic_handle(knot_quic_table_t *table, knot_quic_reply_t *reply,
ngtcp2_version_cid decoded_cids = { 0 };
ngtcp2_cid scid = { 0 }, dcid = { 0 }, odcid = { 0 };
- uint64_t now = get_timestamp();
if (reply->in_payload->iov_len < 1) {
reply->handle_ret = KNOT_EOK;
return KNOT_EOK;
@@ -640,6 +639,8 @@ int knot_quic_handle(knot_quic_table_t *table, knot_quic_reply_t *reply,
return KNOT_EOK;
}
+ uint64_t now = get_timestamp(); // the timestamps needs to be collected AFTER the check for blocked conn
+
ngtcp2_path path;
path.remote.addr = (struct sockaddr *)reply->ip_rem;
path.remote.addrlen = addr_len((struct sockaddr_in6 *)reply->ip_rem);
diff --git a/src/libknot/quic/quic_conn.c b/src/libknot/quic/quic_conn.c
index 1a3b9dfea..4cd9d03e3 100644
--- a/src/libknot/quic/quic_conn.c
+++ b/src/libknot/quic/quic_conn.c
@@ -575,8 +575,8 @@ void knot_quic_conn_block(knot_quic_conn_t *conn, bool block)
conn->next_expiry = UINT64_MAX;
conn_heap_reschedule(conn, conn->quic_table);
} else {
- conn->flags &= ~KNOT_QUIC_CONN_BLOCKED;
quic_conn_mark_used(conn, conn->quic_table);
+ conn->flags &= ~KNOT_QUIC_CONN_BLOCKED; // unblocking needs to be the last thing to do since other thread may accept next packet
}
}