Changes to compile and run on NetBSD #6146
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Short description
These are the minimal changes to make the authoritative server, the
recursor, and dnsdist compile and run properly on NetBSD.
The changes fall into three groups:
A number of existing "#if defined" lines already in place for other
BSD variants needed to be expanded with "|| defined(NetBSD)" to
get the same effect here.
The pthread CPU affinity code in pdns/misc.cc needed changes,
because the underlying cpuset_t is opaque in NetBSD, and one must
use function calls operating on a pointer to a CPU set returned by
cpuset_create(), instead of declaring a local struct and operating
on that.
The socket control message interface uses the CMSG_DATA() macro to
fetch optional information for packets, but expects that to assume
a "const struct cmsghdr" declaration. NetBSD has a CCMSG_DATA()
that does this.
The implementation of socket options IP_PKTINFO et al in NetBSD was
not compatible with anything, and this has required source code
workarounds in software that uses them. As part of this project,
I submitted a set of fixes to NetBSD that makes it source code
compatible with Linux, Solaris, and FreeBSD -- the two former by
making the IP_PKTINFO support detect which of their behaviours the
programmer expects, the latter by implementing IP_SENDSRCADDR. My
modifications are expected to be in NetBSD 8.0 when it is released.
My change here is simply to "#undef IP_PKTINFO" unless the version
of NetBSD we're compiling on is new enough to have my changes. For
older versions, server sockets bound to INADDR_ANY won't work right.
This has been the way NetBSD "pkgsrc" has handled this so far, too,
so it's not likely to surprise anyone.
The result works as it should, and I've verified that the servers now
respond correctly to queries addressed to them on IPv4 addresses other
than the one that's the primary address of the interface the query
arrives on.
One quirk I haven't done anything about is the difficulty configure
experiences finding libedit on NetBSD, where it is in the base
installation. The workaround is to configure dnsdist by saying
./configure LIBEDIT_CFLAGS="-I/usr/include" "LIBEDIT_LIBS=-L/usr/lib -ledit"
but I'm sure something could be done to configure to help it. I don't
know the tool well enough to try, though.
Checklist
I have: