NetworkBlockDevice / nbd

Network Block Device
GNU General Public License v2.0
450 stars 116 forks source link

nbd-server ignoring `unixsock` configuration option. #89

Closed Ferroin closed 5 years ago

Ferroin commented 5 years ago

Originally discovered using nbd-server 3.18 on Gentoo, tested all the way back to 3.15.3.

Put quite simply, nbd-server appears to be ignoring the presence of a unixsock config option in the [general] section, and just serves over TCP on all interfaces instead.

Sample config that's not working:

[generic]
max_threads = 16
unixsocket = /virt/swap/socket

[swap]
copyonwrite = true
cowdir = /virt/swap/data
exportname = /virt/swap/template
flush = true
fua = true
rotational = false
sparse_cow = true
trim = true

A quick look at the code in nbd-server.c seems to indicate that TCP servers get started unconditionally (I see exactly zero code paths whereby you can get to open_unix() without first having called open_nodern() successfully), which not only strikes me as wrong (as a general rule, people serve something over a unix socket because they don't want it served over the network), but seems like it's probably related to this.

yoe commented 5 years ago

[generic] max_threads = 16 unixsocket = /virt/swap/socket

That should say unixsock, not unixsocket. Currently, nbd-server does not produce errors or warnings for unknown configuration values; the way it's written, it doesn't even see them (this should probably be revisited, but ENOTIME right now). Closing since that's likely to be the reason; if not, feel free to reopen.

A quick look at the code in nbd-server.c seems to indicate that TCP servers get started unconditionally

Patches welcome ;-)

Ferroin commented 5 years ago

That should say unixsock, not unixsocket. Currently, nbd-server does not produce errors or warnings for unknown configuration values; the way it's written, it doesn't even see them (this should probably be revisited, but ENOTIME right now). Closing since that's likely to be the reason; if not, feel free to reopen.

Doh! You're right, I misread the documentation (and was a bit confused by the lack of an error message). Sorry about the noise.