Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve stability of channels_test:Key rotation #6782

Merged
merged 19 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/ds/non_blocking.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ namespace ringbuffer
{
for (auto& it : pending)
{
const auto buffer_end = it.buffer.data() + it.buffer.size();
if (
it.marker == marker.value() &&
marker.value() != reinterpret_cast<uint64_t>(buffer_end))
if (it.marker == marker.value())
achamayou marked this conversation as resolved.
Show resolved Hide resolved
{
// This is a pending write - dump data directly to write marker,
// which should be within the appropriate buffer
Expand All @@ -118,6 +115,7 @@ namespace ringbuffer
(size_t)it.buffer.data()));
}

const auto buffer_end = it.buffer.data() + it.buffer.size();
if (dest + size > buffer_end)
{
throw std::runtime_error(fmt::format(
Expand All @@ -128,7 +126,11 @@ namespace ringbuffer
(size_t)buffer_end));
}

std::memcpy(dest, bytes, size);
if (size != 0)
{
std::memcpy(dest, bytes, size);
}

dest += size;
it.marker = (size_t)dest;
return {it.marker};
Expand Down
12 changes: 9 additions & 3 deletions src/node/channels.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,6 @@ namespace ccf
}
}

class KeyExchangeProtocol
{};

// Key exchange states are:
// - Have nothing
// - Initiated (have my own share)
Expand Down Expand Up @@ -251,6 +248,8 @@ namespace ccf

send_key = nullptr;
recv_key = nullptr;
reset_key_exchange();
initiate();
achamayou marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -542,6 +541,8 @@ namespace ccf
// shares back to the initiator
send_key_exchange_response();

flush_pending_outgoing();

return true;
}

Expand Down Expand Up @@ -633,6 +634,8 @@ namespace ccf

send_key_exchange_final();

flush_pending_outgoing();

update_recv_key();

establish();
Expand Down Expand Up @@ -804,7 +807,10 @@ namespace ccf
"Node certificate serial numbers: node={} peer={}",
node_cv->serial_number(),
peer_cv->serial_number());
}

void flush_pending_outgoing()
maxtropets marked this conversation as resolved.
Show resolved Hide resolved
{
if (outgoing_consensus_msg.has_value())
{
send_unsafe(
Expand Down
Loading
Loading