Report invalid osd_network as a fatal error instead of an exception #152

Merged
vitalif merged 2 commits from koolkhel/vitastor:osd-network-fatal into master 2026-11-23 00:09:19 +03:00
Contributor

Description

cidr_parse() throws on an invalid mask and osd_messenger_t::parse_config() doesn't catch it, so a typo in osd_network or osd_cluster_network ends in std::terminate(). In a process that embeds the client (QEMU) this aborts it even with client_exit_on_error=false.

This reports it through fatal_error(), like an invalid proto_checksums value. For a client created with client_exit_on_error=false the open then fails with "Invalid IP address mask: ..."; an OSD prints the same error and exits with code 1 instead of aborting.

Tested: the new case in test_msgr_stop (without the fix it dies with terminate called after throwing an instance of 'std::runtime_error'). Also the same patch in our downstream tree with QEMU 8.2.2: blockdev-add with a config file that has osd_network: "10.0.0.0/33" returns a QMP error and QEMU keeps running, with and without io_uring; without the patch QEMU is killed by SIGABRT.

Contributor Name

Yury Luneff (MIND Software LLC, https://mindsw.io)

CLA

### Description `cidr_parse()` throws on an invalid mask and `osd_messenger_t::parse_config()` doesn't catch it, so a typo in `osd_network` or `osd_cluster_network` ends in `std::terminate()`. In a process that embeds the client (QEMU) this aborts it even with `client_exit_on_error=false`. This reports it through `fatal_error()`, like an invalid `proto_checksums` value. For a client created with `client_exit_on_error=false` the open then fails with "Invalid IP address mask: ..."; an OSD prints the same error and exits with code 1 instead of aborting. Tested: the new case in `test_msgr_stop` (without the fix it dies with `terminate called after throwing an instance of 'std::runtime_error'`). Also the same patch in our downstream tree with QEMU 8.2.2: `blockdev-add` with a config file that has `osd_network: "10.0.0.0/33"` returns a QMP error and QEMU keeps running, with and without io_uring; without the patch QEMU is killed by SIGABRT. ### Contributor Name Yury Luneff (MIND Software LLC, https://mindsw.io) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
koolkhel added 1 commit 2026-11-22 20:32:38 +03:00
cidr_parse() throws on an invalid mask and osd_messenger_t::parse_config()
doesn't catch it, so a typo in osd_network or osd_cluster_network ends
in std::terminate(). In a process that embeds the client (QEMU) this
aborts it even with client_exit_on_error=false.

Report it through fatal_error(), like an invalid proto_checksums value.
vitalif requested changes 2026-11-22 23:04:40 +03:00
@@ -369,3 +367,2 @@
this->osd_cluster_network_masks.clear();
for (auto & netstr: this->osd_cluster_networks)
this->osd_cluster_network_masks.push_back(cidr_parse(netstr));
try
Owner

просьба без try тогда, а сделать чтобы функции возвращали ошибку.

просьба без try тогда, а сделать чтобы функции возвращали ошибку.
vitalif marked this conversation as resolved
koolkhel added 1 commit 2026-11-22 23:19:28 +03:00
parse_config() checks the result and reports an invalid osd_network
or osd_cluster_network through fatal_error() without try/catch.
Author
Contributor

Переделал без try: cidr_parse() теперь возвращает bool и пишет результат по указателю, как string_to_addr(), а parse_config() при ошибке вызывает fatal_error(). Коммит 347bde76, при слиянии его можно склеить с первым.

Переделал без try: `cidr_parse()` теперь возвращает `bool` и пишет результат по указателю, как `string_to_addr()`, а `parse_config()` при ошибке вызывает `fatal_error()`. Коммит 347bde76, при слиянии его можно склеить с первым.
vitalif merged commit 9ebdc0ef89 into master 2026-11-23 00:09:19 +03:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#152
No description provided.