Portability: Fix assumption about read() and write() on connecting sockets Without adns_if_noautosys, adns would attempt read() on its TCP client socket immediately after getting EINPROGRESS from connect(), and assume that EAGAIN/EWOULDBLOCK means the socket is connected. This is actually not correct on any platform that I'm aware of. However, on Linux, write() on a socket which is being connected returns EAGAIN, so everything seemed to work - adns would think that the socket's window was full and wait for it to become writeable. On many other platforms, write() on such a socket returns ENOTCONN. The result is that adns's TCP support may fail to work properly on such platforms, especially if the nameserver is not localhost. (A connect to a suitable server on localhost often completes immediately, which avoids exposing the bug.) adns might fail to be able to do TCP at all. We detect the completion (successful or otherwise) of connect() by selecting the fd (as contemplated by SuS). This might expose us to spurious fd writeability indications, if such things exist, but the nonblocking connect API demands that they don't at least in this case. We always do this select check, in adns_processwriteable. In theory this is sometimes unnecessary, because adns_processwriteable's caller has probably just got a writeability indication from poll or select. But adns should not assume that its caller will never feed it spurious events, and there seems little point optimising away one syscall per tcp connection (given that adns reuses the connection where possible.) This behaviour naturally causes a lot of the regression tests to fail. So in this commit we also update all the regression tests. This has been done in a programmatic way, by running perl -i ./update-extra-select case-*.sys update-extra-select is supplied in this commit. It is a (hopefully easy to understand) script which adds a select just before every applicable read. The pretended select always reports that the fd is useable, which is what would justify adns's subsequent behaviour. (Most of the tests run with adns_if_noautosys - since that's the default and has to be toggled off - and in those cases the socket has in any case just been reported as writeable.) Note that regress/update-extra-select is not idempotent. Here, it has been used exactly once. (It is going to be deleted again in the next commit.) Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
regress/: Replace PF_ with AF_ I don't much like PF_. None of the modern specs or docs talk about PF any more. Entirely formulaic patch: perl -i~ -pe 's/\bPF_INET\b/AF_INET/g' regress/* perl -i~ -pe 's/\bPF_INET6\b/AF_INET6/g' regress/* Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Support IPv6 in addr queries. This is the end-game. Add flags and options to allow clients and administrators to choose which address families they want returned. For logical compatibility with old clients, don't return foreign address families unless explicitly requested. Lots of tests are modified to select only IPv4 addresses. There's nothing else up my sleeve. A new test is added for the additional functionality; more are expected later. Signed-off-by: Mark Wooding <mdw@distorted.org.uk> Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
regress/: Include the protocol family in socket(2) lines. I updated the test files with this rune: grep -lZ "^ socket type=" *.sys | xargs -0r sed -i \ 's/^ socket type=/ socket domain=PF_INET type=/' Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
Bodge adns_r_addr query-id selection and fix regression tests to match. A future change is going to change how query-ids are allocated for adns_r_addr queries. So here we apply a simple bodge which will produce the same allocation pattern, but without the complexity of the rest of the change, and fix the test suite to match. I used the script regress/hack-query-ids to help me modify the case-*.sys files, though this was primarily a rather tedious manual process. Signed-off-by: Mark Wooding <mdw@distorted.org.uk> Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
regress/: Don't track the size of the socket-address buffer in recvfrom(3). This is system specific, and (more annoyingly) will break the tests if additional address families are supported in the future. Signed-off-by: Mark Wooding <mdw@distorted.org.uk>
+ General Improvements: @@ -3,6 +3,11 @@ Bugfixes: * Actually compile shared libraries by default ! + General Improvements: + * adnshost has --config option for overriding configuration. + * Regression tests now include `adnshost' invocations. + * Test cancellation both before and after query completion. + Portability fixes: * Fix <sys/fcntl.h> in client/adnsresfilter.c to <fcntl.h>. * #include <sys/types.h> and <unistd.h> for fcntl in */*.c. @@ -12,6 +17,7 @@ * adnstest: setvbuf(stdout,...) before we do first output. * Cast a sizeof(...) in src/event.c to unsigned long before printing. * #include <sys/select.h> if it exists. + * Regression tests work better if some syscalls are already macros. Portability cleanups: * Add list of tested platforms in INSTALL file.
+ * Race near adns_beforeselect which could cause infinite timeout fixed @@ -3,6 +3,8 @@ Bugfixes: + * Race near adns_beforeselect which could cause infinite timeout fixed + (it's now less agressive, and will more often return a zero timeout.)
New TCP tests.
Only accept a reply from the subset of servers we sent the query.
Restarting a TCP-using query doesn't abort.