Skip to content

Commit

Permalink
c/health: added validation of received health report node_id
Browse files Browse the repository at this point in the history
Added validation of the node_id of the reply received from the node. The
report is not considered as valid if the reply node id doesn't match the
id of node the report was sent to.

Signed-off-by: Michał Maślanka <michal@redpanda.com>
  • Loading branch information
mmaslankaprv committed Aug 9, 2024
1 parent 6a8f390 commit 08de93d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/v/cluster/health_monitor_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -370,20 +370,23 @@ health_monitor_backend::collect_remote_node_health(model::node_id id) {
});
}

result<node_health_report>
map_reply_result(result<get_node_health_reply> reply) {
result<node_health_report> map_reply_result(
model::node_id target_node_id, result<get_node_health_reply> reply) {
if (!reply) {
return {reply.error()};
}
if (!reply.value().report.has_value()) {
return {reply.value().error};
}
if (reply.value().report->id != target_node_id) {
return {errc::invalid_target_node_id};
}
return {std::move(*reply.value().report).to_in_memory()};
}

result<node_health_report> health_monitor_backend::process_node_reply(
model::node_id id, result<get_node_health_reply> reply) {
auto res = map_reply_result(std::move(reply));
auto res = map_reply_result(id, std::move(reply));
auto [status_it, _] = _status.try_emplace(id);
if (!res) {
vlog(
Expand Down

0 comments on commit 08de93d

Please sign in to comment.