New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to compile and run on NetBSD #6146

Merged
merged 1 commit into from Jan 8, 2018

Conversation

Projects
None yet
4 participants
@tih
Contributor

tih commented Jan 5, 2018

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:

  1. 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.

  2. 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.

  3. 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.

  4. 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:

  • read the CONTRIBUTING.md document
  • compiled and tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)
  • checked that this code was merged to master
@tih

This comment has been minimized.

Contributor

tih commented Jan 6, 2018

Re-reading the patch, there's a clarification I guess I should have made: in pdns/misc.cc, there was an #ifdef, #endif, #ifdef, #endif sequence, that I replace with #if, #elif, #endif. This sequence would have created unnecessary extra code on NetBSD, it being the only OS where both of the conditions would be true. My modifications, committed to NetBSD-current, and expected to be released with NetBSD 8, make both the IP_PKTINFO and the IP_SENDSRCADDR control messages available for use with sendmsg().

@Habbie Habbie merged commit 6c0d63d into PowerDNS:master Jan 8, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@rgacogne rgacogne added this to the dnsdist-1.2.x milestone Mar 18, 2018

@tih tih deleted the tih:netbsd-fixes branch Oct 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment