Report netlink-map failures in its exit status #121

Open
koolkhel wants to merge 1 commits from koolkhel/vitastor:nbd-netlink-map-status into master
Contributor

Description

netlink-map and netlink-revive forked before configuring the device, and the parent exited 0 at once. So a failed configuration (a busy device, no permission, no nbd netlink family) still returned 0, and the command could return before the device was set up. With this change the parent waits until the daemon sends the device number, and exits 1 if the daemon dies first.

Tested as non-root against an empty local etcd, with netlink-map --inode 1 --pool 1 --size 1073741824, where netlink_configure() fails with Operation not permitted. Before the change, the command exited 0 while the daemon printed the error. After it, the command exits 1 with the same error, and --foreground exits 1 too.

Contributor Name

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

CLA

### Description `netlink-map` and `netlink-revive` forked before configuring the device, and the parent exited 0 at once. So a failed configuration (a busy device, no permission, no nbd netlink family) still returned 0, and the command could return before the device was set up. With this change the parent waits until the daemon sends the device number, and exits 1 if the daemon dies first. Tested as non-root against an empty local etcd, with `netlink-map --inode 1 --pool 1 --size 1073741824`, where `netlink_configure()` fails with `Operation not permitted`. Before the change, the command exited 0 while the daemon printed the error. After it, the command exits 1 with the same error, and `--foreground` exits 1 too. ### 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-16 22:16:56 +03:00
netlink-map and netlink-revive forked before configuring the device, and
the parent exited 0 at once. So a failed configuration (a busy device,
no permission, no nbd netlink family) still returned 0, and the command
could return before the device was set up. Keep the parent until the
daemon sends the device number, and exit 1 if the daemon dies first.
vitalif reviewed 2026-11-17 10:33:20 +03:00
@@ -825,6 +829,41 @@ help:
exit(0);
}
// Like daemonize_fork(), but the parent prints the device and exits 0 only
Owner

Если хочется такое сделать, нужно скопипастить с ublk_server, там по идее такая же штука реализована уже, не нужно чтобы в двух файлах было 2 разных реализации примерно одного и того же, и также не надо чтобы было аж 4 функции - daemonize_fork, daemonize_reopen_stdio, daemonize_begin, daemonize_end

Если хочется такое сделать, нужно скопипастить с ublk_server, там по идее такая же штука реализована уже, не нужно чтобы в двух файлах было 2 разных реализации примерно одного и того же, и также не надо чтобы было аж 4 функции - daemonize_fork, daemonize_reopen_stdio, daemonize_begin, daemonize_end
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u nbd-netlink-map-status:koolkhel-nbd-netlink-map-status
git checkout koolkhel-nbd-netlink-map-status
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#121
No description provided.