platform/upstream/nbd.git
10 years agoDocument -V option
Wouter Verhelst [Wed, 1 Oct 2014 20:47:14 +0000 (22:47 +0200)]
Document -V option

10 years agoFix various warnings that pop up by default with gcc 4.9
Wouter Verhelst [Wed, 1 Oct 2014 20:42:18 +0000 (22:42 +0200)]
Fix various warnings that pop up by default with gcc 4.9

10 years agoReplace return by break statement
Wouter Verhelst [Wed, 1 Oct 2014 20:35:44 +0000 (22:35 +0200)]
Replace return by break statement

Both are extraneous, really, but keep the break there for consistency (and to
avoid "eep, forgot... ah, no" kind of things)

Using return instead (without argument) makes clang choke, which is useless.

10 years agoUpdate nbd-server.c
txt.file [Wed, 1 Oct 2014 14:07:20 +0000 (16:07 +0200)]
Update nbd-server.c

Added a parameter to output a version string.

10 years agoRevert "Enable automatic coverity coverage"
Wouter Verhelst [Thu, 18 Sep 2014 08:32:46 +0000 (10:32 +0200)]
Revert "Enable automatic coverity coverage"

This reverts commit eb6365af2c4c8eecf62317940c06f2bc58810a98.

The travis stuff isn't supposed to work that way; also, we're doing
weekly coverity builds with buildbot now, so it's less relevant.

10 years agoImplement new config file option "cowdir"
Wouter Verhelst [Mon, 15 Sep 2014 19:02:17 +0000 (21:02 +0200)]
Implement new config file option "cowdir"

Allows to specify a location where copy-on-write files should be
written.

10 years agoUpdate clientacl.c
delmasce [Sun, 14 Sep 2014 22:30:51 +0000 (00:30 +0200)]
Update clientacl.c

Update test code with new prototype of address_matches()

10 years agoPass whole struct sockaddr to function address_matches() and use it to
delmasce [Sun, 14 Sep 2014 21:53:51 +0000 (23:53 +0200)]
Pass whole struct sockaddr to function address_matches() and use it to
compare against the masks defined in auth file.

10 years agoFix obi-wan (whoops)
Wouter Verhelst [Sun, 14 Sep 2014 21:27:20 +0000 (23:27 +0200)]
Fix obi-wan (whoops)

10 years agoadd missing include syslog.h
Christian Hesse [Fri, 9 May 2014 07:06:06 +0000 (09:06 +0200)]
add missing include syslog.h

10 years agoClear ai on return, also in case of error
Wouter Verhelst [Sun, 14 Sep 2014 18:42:58 +0000 (20:42 +0200)]
Clear ai on return, also in case of error

Coverity CID#1238644

10 years agoEnsure pidftemplate is always 0-terminated
Wouter Verhelst [Sun, 14 Sep 2014 09:58:47 +0000 (11:58 +0200)]
Ensure pidftemplate is always 0-terminated

Coverity CID#1238650

10 years agoEnsure the "errstr" buffer is always 0-terminated
Wouter Verhelst [Sun, 14 Sep 2014 09:54:55 +0000 (11:54 +0200)]
Ensure the "errstr" buffer is always 0-terminated

Coverity CID#1238651 (and many others)

10 years agoDon't try to be smarter than the compiler about inlining
Wouter Verhelst [Fri, 25 Jul 2014 07:46:19 +0000 (09:46 +0200)]
Don't try to be smarter than the compiler about inlining

When we specify "inline int foo()" (as opposed to "static inline", I
guess), compilation may fail when compiling with -O0, as I sometimes do
to simplify debugging.

The compiler is way smarter about deciding when things are best inlined,
anyway. So stop trying to tell it what to do.

10 years agoDon't warn about oldstyle exports if oldstyle is set to true.
Wouter Verhelst [Fri, 25 Jul 2014 07:45:52 +0000 (09:45 +0200)]
Don't warn about oldstyle exports if oldstyle is set to true.

Bug reported through Ubuntu Launchpad

10 years agoFix up parse_cfile signature
Wouter Verhelst [Fri, 25 Jul 2014 07:44:24 +0000 (09:44 +0200)]
Fix up parse_cfile signature

parse_cfile repurposed the genconf parameter as a boolean flag (in
addition to its storing of generic configuration) to signal the
expectation (or absense thereof) of a [generic] section in the
configuration file.

Not only is this confusing, it also makes it impossible to reliably
detect whether we want an oldstyle export. Fix for that in the next
commit.

10 years agofix typo
Christian Hesse [Thu, 8 May 2014 09:10:59 +0000 (11:10 +0200)]
fix typo

10 years agodo not try to open authorization file without filename
Christian Hesse [Thu, 8 May 2014 09:10:58 +0000 (11:10 +0200)]
do not try to open authorization file without filename

10 years agoGuard against errors
Wouter Verhelst [Thu, 20 Mar 2014 07:34:12 +0000 (08:34 +0100)]
Guard against errors

10 years agoEnable automatic coverity coverage
Wouter Verhelst [Thu, 20 Mar 2014 07:16:37 +0000 (08:16 +0100)]
Enable automatic coverity coverage

10 years agoMake the travis stuff work (after some testing on a separate branch)
Wouter Verhelst [Thu, 20 Mar 2014 07:08:26 +0000 (08:08 +0100)]
Make the travis stuff work (after some testing on a separate branch)

10 years agoClean up cliserv.h
Wouter Verhelst [Thu, 20 Mar 2014 07:06:18 +0000 (08:06 +0100)]
Clean up cliserv.h

Previously, cliserv.h also contained some functions, which would then be
defined twice if we hadn't inlined them.

That is a fairly ugly way of doing things, so instead move the few
functions in cliserv.h to a new cliserv.c, and compile and link that in.

This should also make more recent versions of clang not be unhappy about
"missing" functions

10 years agoInstall a more recent version of automake through apt pinning. I hope.
Wouter Verhelst [Wed, 19 Mar 2014 23:19:05 +0000 (00:19 +0100)]
Install a more recent version of automake through apt pinning. I hope.

10 years agoFigure out which versions of automake we have to work with
Wouter Verhelst [Wed, 19 Mar 2014 22:53:27 +0000 (23:53 +0100)]
Figure out which versions of automake we have to work with

10 years agoautotools need to be regenerated
Wouter Verhelst [Wed, 19 Mar 2014 22:41:27 +0000 (23:41 +0100)]
autotools need to be regenerated

10 years agoAdd travis config file
Wouter Verhelst [Wed, 19 Mar 2014 22:30:28 +0000 (23:30 +0100)]
Add travis config file

10 years agoPrepare for 3.8 nbd-3.8
Wouter Verhelst [Wed, 19 Mar 2014 18:05:34 +0000 (19:05 +0100)]
Prepare for 3.8

10 years agoDon't go out of bounds in an array...
Wouter Verhelst [Wed, 19 Mar 2014 17:55:52 +0000 (18:55 +0100)]
Don't go out of bounds in an array...

10 years agoZero-terminate buffers with data supplied by remote parties
Wouter Verhelst [Wed, 19 Mar 2014 17:39:25 +0000 (18:39 +0100)]
Zero-terminate buffers with data supplied by remote parties

Found by coverity scan

10 years agoClose the directory handle when we no longer need it
Wouter Verhelst [Wed, 19 Mar 2014 17:36:36 +0000 (18:36 +0100)]
Close the directory handle when we no longer need it

Found by coverity scan

10 years agoAdd assertion, to make LLVM static analyzer happy
Wouter Verhelst [Wed, 19 Mar 2014 17:09:16 +0000 (18:09 +0100)]
Add assertion, to make LLVM static analyzer happy

10 years agoRevert "Make this part of the code at least look similar"
Wouter Verhelst [Tue, 28 Jan 2014 07:44:13 +0000 (08:44 +0100)]
Revert "Make this part of the code at least look similar"

This reverts commit 701af5d057f523c714517085469dec556aa76b28.

The test suite apparently expects this to be there... do this properly
later on.

10 years agoSupport systemd initrd kill protection
Wouter Verhelst [Tue, 28 Jan 2014 07:39:41 +0000 (08:39 +0100)]
Support systemd initrd kill protection

systemd wants us to mark our argv[0] when we don't want to be killed.

Since I think that's a bit ugly, add an option so it's only done when
necessary.

10 years agoMake this part of the code at least look similar
Wouter Verhelst [Sun, 26 Jan 2014 20:23:20 +0000 (21:23 +0100)]
Make this part of the code at least look similar

First we assert that s != NULL.

Then we check if a != NULL, and return -1 if it is. That just makes no sense.

Change the check for a to also be an assertion, and make things at least look similar.

10 years agoSilence warning
Wouter Verhelst [Sat, 25 Jan 2014 11:56:00 +0000 (12:56 +0100)]
Silence warning

10 years agoBe less verbose
Wouter Verhelst [Wed, 22 Jan 2014 09:47:33 +0000 (10:47 +0100)]
Be less verbose

If we list each and every request, that means a build log becomes huge
and unwieldy, so reduce the chatter somewhat.

10 years agoAdd build status applet, too
Wouter Verhelst [Wed, 22 Jan 2014 00:44:24 +0000 (01:44 +0100)]
Add build status applet, too

Somewhat ugly, but it works -- and that's what matters most.

10 years agoDisable integrityhuge test
Wouter Verhelst [Tue, 21 Jan 2014 20:57:24 +0000 (21:57 +0100)]
Disable integrityhuge test

nbd-server currently may deadlock on huge reads or writes, especially on
slower machines.

We're fixing this on the io_transaction branch, but meanwhile disable
integrityhuge again.

10 years agoRelease 3.7 nbd-3.7
Wouter Verhelst [Tue, 21 Jan 2014 20:40:04 +0000 (21:40 +0100)]
Release 3.7

10 years agoAdd README.md to Makefile.am
Wouter Verhelst [Tue, 21 Jan 2014 19:52:06 +0000 (20:52 +0100)]
Add README.md to Makefile.am

README files are distributed automatically, but README.md files are not;
so add it explicitly

10 years agoCreate Coverity model
Wouter Verhelst [Tue, 21 Jan 2014 19:36:18 +0000 (20:36 +0100)]
Create Coverity model

10 years agoFix typo
Wouter Verhelst [Tue, 21 Jan 2014 19:16:56 +0000 (20:16 +0100)]
Fix typo

the "dir" parameter contains the name of the directory, while the "dirh"
variable is an opendir() handle that'll only be NULL in case of error.

By complete accident, this compiled, but it wouldn't actually ever do
anything useful.

10 years agoDon't leak resources
Wouter Verhelst [Tue, 21 Jan 2014 19:14:06 +0000 (20:14 +0100)]
Don't leak resources

Close the authorized file in _all_ cases, not just when authorized.

Found by coverity scan.

10 years agoReformat README to markdown
Wouter Verhelst [Tue, 21 Jan 2014 19:12:35 +0000 (20:12 +0100)]
Reformat README to markdown

10 years agoMake things work again
Wouter Verhelst [Wed, 15 Jan 2014 12:32:09 +0000 (13:32 +0100)]
Make things work again

10 years agoTickle the git repository
Wouter Verhelst [Wed, 15 Jan 2014 12:16:33 +0000 (13:16 +0100)]
Tickle the git repository

Did something wrong, hopefully it will work now.

10 years agoTest build failure mail thing
Wouter Verhelst [Wed, 15 Jan 2014 12:13:22 +0000 (13:13 +0100)]
Test build failure mail thing

buildbot has a "send mail upon build failure" option. This should test that.

We'll revert the break once everything seems to work ;-)

10 years agoMake the implementation of size_autodetect follow the documentation
Wouter Verhelst [Wed, 15 Jan 2014 09:54:28 +0000 (10:54 +0100)]
Make the implementation of size_autodetect follow the documentation

The documentation claimed that size_autodetect could return UINT64_MAX
if size autodetection would fail. In fact, however, it would call err(),
which is for fatal errors.

Additionally, the final test (to use lseek SEEK_END) would never be
called, since it was preceded by an if structure which would call return
in one of its branches and err() in the other.

10 years agoRemove off_t from what will eventually be a public API
Wouter Verhelst [Wed, 15 Jan 2014 09:49:13 +0000 (10:49 +0100)]
Remove off_t from what will eventually be a public API

Since the size of off_t may vary depending on whether the LFS defines
have been set, it is not a good idea to expose that, as the recently
fixed bug has shown. As long as we use nbdsrv.h internally only this
doesn't matter, but since the long-term goal is to make libnbdsrv a
public library, we'd better avoid such an issue.

We'll still use off_t internally, but that won't be exposed anymore.

10 years agoRemove duplicate ISSERVER definition
Wouter Verhelst [Wed, 15 Jan 2014 09:48:47 +0000 (10:48 +0100)]
Remove duplicate ISSERVER definition

10 years agoReorder LFS includes so it actually works
Wouter Verhelst [Wed, 15 Jan 2014 00:43:54 +0000 (01:43 +0100)]
Reorder LFS includes so it actually works

10 years agoAdd missing lfs.h include
Wouter Verhelst [Wed, 15 Jan 2014 00:03:22 +0000 (01:03 +0100)]
Add missing lfs.h include

lfs.h has an influence on sizeof(off_t), which has an influence on the
offsets of the SERVER data type, which makes things fail on 32 bit...
whoops.

10 years agoFix cleanup in simple_test
Wouter Verhelst [Mon, 13 Jan 2014 19:42:40 +0000 (20:42 +0100)]
Fix cleanup in simple_test

If nbd-server dies during the test for some reason or other, then the
kill call in the cleanup subroutine would fail, causing (due to 'set
-e') the script to abort immediately. As a result, the "rm -rf" of the
tempdir wouldn't happen, which would leave cruft in /tmp.

Fix.

10 years agoFully initialize hints
Wouter Verhelst [Mon, 13 Jan 2014 19:21:34 +0000 (20:21 +0100)]
Fully initialize hints

POSIX 1003.1 says:

 In this hints structure every member other than ai_flags, ai_family,
 ai_socktype, and ai_protocol shall be set to zero or a null pointer.

which Linux doesn't enforce, but FreeBSD does.

10 years agoFix missing include
Wouter Verhelst [Mon, 13 Jan 2014 18:58:29 +0000 (19:58 +0100)]
Fix missing include

Linux automatically includes <netinet/in.h> as a dependency of one of
the other include files, but this is not required by POSIX, and FreeBSD
doesn't do so.

Since we directly use some of the structs from that file,
add the include

10 years agoPrepare for 3.6 nbd-3.6
Wouter Verhelst [Fri, 3 Jan 2014 15:44:20 +0000 (16:44 +0100)]
Prepare for 3.6

10 years agoSwitch to xz (and away from bzip2)
Wouter Verhelst [Mon, 30 Dec 2013 19:09:07 +0000 (20:09 +0100)]
Switch to xz (and away from bzip2)

Might change back, depending on discussion on mailinglist.

10 years agoFix build
Wouter Verhelst [Mon, 30 Dec 2013 19:08:20 +0000 (20:08 +0100)]
Fix build

If we introduce a new file, we need to make sure to add it to the
Makefile, too, otherwise it won't be distributed...

10 years agoAdd check for size_autodetect
Wouter Verhelst [Mon, 30 Dec 2013 18:12:28 +0000 (19:12 +0100)]
Add check for size_autodetect

10 years agoMove size_autodetect to library
Wouter Verhelst [Mon, 30 Dec 2013 18:00:12 +0000 (19:00 +0100)]
Move size_autodetect to library

10 years agoAdd check for getmaskbyte(), too
Wouter Verhelst [Sun, 29 Dec 2013 01:05:34 +0000 (02:05 +0100)]
Add check for getmaskbyte(), too

10 years agoDon't forget to distribute this new "macro.h", too
Wouter Verhelst [Mon, 23 Dec 2013 19:24:14 +0000 (20:24 +0100)]
Don't forget to distribute this new "macro.h", too

10 years agoAdd a check for append_serve, too
Wouter Verhelst [Mon, 23 Dec 2013 19:22:02 +0000 (20:22 +0100)]
Add a check for append_serve, too

10 years agoSeparate out a useful macro
Wouter Verhelst [Mon, 23 Dec 2013 19:21:46 +0000 (20:21 +0100)]
Separate out a useful macro

10 years agoUpdate comment to reflect today's realities
Wouter Verhelst [Mon, 23 Dec 2013 19:21:14 +0000 (20:21 +0100)]
Update comment to reflect today's realities

10 years agoMove "append_serve" to library, too.
Wouter Verhelst [Mon, 23 Dec 2013 19:20:55 +0000 (20:20 +0100)]
Move "append_serve" to library, too.

That completes what can be moved without rewriting anything.

10 years agoWhitespace fix
Wouter Verhelst [Mon, 23 Dec 2013 19:20:38 +0000 (20:20 +0100)]
Whitespace fix

10 years agoFix Makefile.am's so that "make distcheck" works again
Wouter Verhelst [Sun, 22 Dec 2013 15:50:11 +0000 (16:50 +0100)]
Fix Makefile.am's so that "make distcheck" works again

10 years agoAdd .gitignore with compiled files in this directory.
Wouter Verhelst [Sun, 22 Dec 2013 15:25:30 +0000 (16:25 +0100)]
Add .gitignore with compiled files in this directory.

10 years agoMake it compile (and pass)
Wouter Verhelst [Sun, 22 Dec 2013 15:24:56 +0000 (16:24 +0100)]
Make it compile (and pass)

10 years agoAdd test for dup_serve
Wouter Verhelst [Sun, 22 Dec 2013 15:15:38 +0000 (16:15 +0100)]
Add test for dup_serve

10 years agoMove dup_serve() to library
Wouter Verhelst [Sun, 22 Dec 2013 15:15:16 +0000 (16:15 +0100)]
Move dup_serve() to library

10 years agoEnable maintainer-mode by default
Wouter Verhelst [Sun, 22 Dec 2013 15:13:52 +0000 (16:13 +0100)]
Enable maintainer-mode by default

10 years agoDo a htonl conversion of opt.
Wouter Verhelst [Wed, 18 Dec 2013 11:24:37 +0000 (12:24 +0100)]
Do a htonl conversion of opt.

Closes github issue #6, but breaks backwards compatibility on
little-endian systems.

I've decided not to care anymore about that. Cross-endian same-version
compatibility matters more than backwards compatibility.

So there.

10 years agoAdd a "code" test suite
Wouter Verhelst [Wed, 18 Dec 2013 11:19:10 +0000 (12:19 +0100)]
Add a "code" test suite

This test suite will test functions in libnbdsrv.la. For now, only test
that the authorized_client function does what it's supposed to do.

10 years agoMake a start with a library
Wouter Verhelst [Wed, 18 Dec 2013 11:16:48 +0000 (12:16 +0100)]
Make a start with a library

The library does not contain much useful stuff yet, so make it a
noinst_LTLIBRARY for now, rather than a lib_LTLIBRARY.

As we move code to the library, we'll modify it so that it becomes
selfsufficient, and clean it up as we go.

For now, only move the freshly rewritten authorized_client() function
there.

This adds libtool to the list of stuff needed when compiling from git,
but that's not much of an issue.

10 years agoSeparate the test suite out into a separate directory
Wouter Verhelst [Wed, 18 Dec 2013 11:11:50 +0000 (12:11 +0100)]
Separate the test suite out into a separate directory

... in preparation of also adding a "code" test suite which tests
functions in the code, not runtime behaviour of nbd-server

10 years agoBring documentation in sync with code
Wouter Verhelst [Wed, 18 Dec 2013 10:13:19 +0000 (11:13 +0100)]
Bring documentation in sync with code

10 years agoImprove acl file parsing robustness
Wouter Verhelst [Wed, 18 Dec 2013 10:04:13 +0000 (11:04 +0100)]
Improve acl file parsing robustness

We now support comments, empty lines, and leading whitespace (which all get
skipped)

Lines with junk will _probably_ get skipped too, depending on how bad
the junk really is.

10 years agoUnbreak virtstyle parameter parsing
Wouter Verhelst [Tue, 17 Dec 2013 13:20:27 +0000 (14:20 +0100)]
Unbreak virtstyle parameter parsing

There have been issues with the "cidrhash" option of the "virtstyle"
parameter since a long time, in that the way things were being parsed
wasn't very endian-independent.

Fix it the same way we just fixed the authorized_client function.

10 years agoFix authorized_client implementation a bit more
Wouter Verhelst [Tue, 17 Dec 2013 13:17:41 +0000 (14:17 +0100)]
Fix authorized_client implementation a bit more

We previously added a fix for CVE-2013-6410, but that one accidentally
broke checks for non-netmasked entries entirely, rather than limiting it
to what it was actually supposed to allow. '\n' is also a character...

This fixes it properly, by not relying on string functions anymore, but
instead parsing all IP addresses to their binary representation, and
comparing that.

As an added bonus, we now also support IPv6 addresses in the ACL file.

10 years agoMerge pull request #15 from alexsn/master
Wouter Verhelst [Sat, 7 Dec 2013 01:01:58 +0000 (17:01 -0800)]
Merge pull request #15 from alexsn/master

Fix potential socket leak in opennet()

10 years agogznbd: fix warning with newer zlib
Mike Frysinger [Mon, 2 Dec 2013 05:26:32 +0000 (00:26 -0500)]
gznbd: fix warning with newer zlib

When you build against newer zlib, you get a lot of warnings like so:

gznbd.c: In function 'main':
gznbd.c:87:5: warning: assignment from incompatible pointer type [enabled by default]
gznbd.c:109:5: warning: passing argument 1 of 'gzread' from incompatible pointer type [enabled by default]
In file included from gznbd.c:37:0:
/usr/include/zlib.h:1313:21: note: expected 'gzFile' but argument is of type 'struct gzFile_s **'
gznbd.c:118:9: warning: passing argument 1 of 'gzerror' from incompatible pointer type [enabled by default]

This is because the zlib API uses just gzFile everywhere, not a pointer
to a gzFile.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Wouter Verhelst <w@uter.be>
10 years agogznbd: use PRId64 for printing 64bit types
Mike Frysinger [Mon, 2 Dec 2013 05:26:31 +0000 (00:26 -0500)]
gznbd: use PRId64 for printing 64bit types

Gcc complains about printing these 64bit types:

gznbd.c:199:1: warning: format '%Ld' expects argument of type 'long long int',
but argument 5 has type 'u64' [-Wformat]

Use the standard defines from inttypes.h to avoid this issue.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Wouter Verhelst <w@uter.be>
10 years agoAdd the actual text of the GPLv2, as the license requires us to
Wouter Verhelst [Mon, 2 Dec 2013 09:22:37 +0000 (10:22 +0100)]
Add the actual text of the GPLv2, as the license requires us to

10 years agoUpdate nbd-client.c
alexsn [Sat, 30 Nov 2013 22:24:39 +0000 (00:24 +0200)]
Update nbd-client.c

Fix potential socket leak in opennet()

10 years agoPrepare for 3.5 nbd-3.5
Wouter Verhelst [Sat, 30 Nov 2013 22:11:45 +0000 (23:11 +0100)]
Prepare for 3.5

10 years agoUse strcmp() rather than strncmp()
Wouter Verhelst [Tue, 26 Nov 2013 13:32:31 +0000 (14:32 +0100)]
Use strcmp() rather than strncmp()

This results in some false positives. If the authfile contains:

192.168.0.12

and the client is

192.168.0.1

then access will be granted, because the strcmp was limiting to
"192.168.0.1" for no particularly good reason.

We should also canonicalize our names and work on that, rather than
doing a simple strcmp(), but that's for later.

10 years agoFix documentation to reflect reality
Wouter Verhelst [Tue, 26 Nov 2013 13:25:26 +0000 (14:25 +0100)]
Fix documentation to reflect reality

11 years ago3.4 was released...
Wouter Verhelst [Fri, 6 Sep 2013 13:34:56 +0000 (15:34 +0200)]
3.4 was released...

11 years agore-enable integrityhuge test nbd-3.4
Wouter Verhelst [Wed, 26 Jun 2013 12:08:37 +0000 (14:08 +0200)]
re-enable integrityhuge test

We disabled it at the time because it would deadlock in some cases
(though not on my machine).

Since then, some deadlock fixes have accumulated. I don't know whether
the culprit has been found and remedied, but it doesn't hurt to try. If
it turns out to still be a problem, we can always disable them again
afterwards.

While here, remove generated files ("missing") from git.

11 years agoRemove the same ioctl() call in another place
Wouter Verhelst [Tue, 18 Jun 2013 06:58:58 +0000 (08:58 +0200)]
Remove the same ioctl() call in another place

Not sure why we do this twice anymore, but hey.

Signed-off-by: Wouter Verhelst <w@uter.be>
11 years agoRemove obsolete NBD_CLEAR_QUE ioctl.
Wouter Verhelst [Mon, 17 Jun 2013 20:39:56 +0000 (22:39 +0200)]
Remove obsolete NBD_CLEAR_QUE ioctl.

Signed-off-by: Wouter Verhelst <w@uter.be>
11 years agonbd-server: const'd function parameter variable
Tuomas Räsänen [Tue, 11 Jun 2013 15:49:58 +0000 (18:49 +0300)]
nbd-server: const'd function parameter variable

Making the parameter variable const revealed a smelly assignment
statement which was deemed unnecessary and hence removed.

Signed-off-by: Tuomas Räsänen <tuomasjjrasanen@tjjr.fi>
Signed-off-by: Wouter Verhelst <w@uter.be>
11 years agonbd-server: remove superfluous 2nd parameter from handle_oldstyle_connection()
Tuomas Räsänen [Tue, 11 Jun 2013 15:49:49 +0000 (18:49 +0300)]
nbd-server: remove superfluous 2nd parameter from handle_oldstyle_connection()

A pointer to the server struct is passed anyways, the socket can be
accessed via that pointer.

Signed-off-by: Tuomas Räsänen <tuomasjjrasanen@tjjr.fi>
Signed-off-by: Wouter Verhelst <w@uter.be>
11 years agonbd-server: refactor out common code
Tuomas Räsänen [Wed, 12 Jun 2013 09:58:37 +0000 (11:58 +0200)]
nbd-server: refactor out common code

Signed-off-by: Tuomas Räsänen <tuomasjjrasanen@tjjr.fi>
Signed-off-by: Wouter Verhelst <w@uter.be>
11 years agonbd-server: rename handle_connection() -> handle_oldstyle_connection()
Tuomas Räsänen [Wed, 5 Jun 2013 17:42:42 +0000 (20:42 +0300)]
nbd-server: rename handle_connection() -> handle_oldstyle_connection()

The new name describes better the actual usage.

Remove also the fourth parameter, CLIENT*, which was always NULL.

Signed-off-by: Tuomas Räsänen <tuomasjjrasanen@tjjr.fi>
11 years agonbd-server: handle modern-style negotiation in a child process
Tuomas Räsänen [Wed, 5 Jun 2013 17:42:31 +0000 (20:42 +0300)]
nbd-server: handle modern-style negotiation in a child process

Previously, the modern style negotiation was carried out in the root
server (listener) process before forking the actual client handler. This
made it possible for a malfunctioning or evil client to terminate the
root process simply by querying a non-existent export or aborting in the
middle of the negotation process (caused SIGPIPE in the server).

This commit moves the negotiation process to the child to keep the root
process up and running no matter what happens during the negotiation.

See http://sourceforge.net/mailarchive/message.php?msg_id=30410146

Signed-off-by: Tuomas Räsänen <tuomasjjrasanen@tjjr.fi>
11 years agoClarify that we're using tests which expect the serial test protocol
Wouter Verhelst [Sun, 9 Jun 2013 17:13:01 +0000 (19:13 +0200)]
Clarify that we're using tests which expect the serial test protocol

Automake changed its defaults from using the serial protocol to using
the parallel protocol sometime between 1.11 and 1.13.

Our test suite makes a few assumptions which are valid for the serial
protocol, but not for the parallel protocol, which makes the test suite
fail with 1.13. As such, explicitly state that we want the serial
protocol so that things don't break with recent versions of automake.

A proper fix would be to make the test suite work with the parallel
protocol, but that's a lot more work than we have time for right now.

11 years agonbd-server: narrow the scope of a function-local variable
Tuomas Räsänen [Sat, 1 Jun 2013 18:20:51 +0000 (21:20 +0300)]
nbd-server: narrow the scope of a function-local variable

It's better to keep variables strictly inside their usage scope than in
more wider scope to avoid unintentional variable shadowing and leaking.

Signed-off-by: Tuomas Räsänen <tuomasjjrasanen@tjjr.fi>