]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Changes to compile and run on NetBSD 6146/head
authorTom Ivar Helbekkmo <tih@hamartun.priv.no>
Fri, 5 Jan 2018 13:24:08 +0000 (14:24 +0100)
committerTom Ivar Helbekkmo <tih@hamartun.priv.no>
Fri, 5 Jan 2018 13:24:08 +0000 (14:24 +0100)
pdns/dns.hh
pdns/dnsdist-console.cc
pdns/dnsdist.cc
pdns/iputils.cc
pdns/iputils.hh
pdns/kqueuemplexer.cc
pdns/misc.cc

index 88a658c5a52ff384a06382bbd4b7998d101d2b78..e6d0385cdb305a786d4ffd3f304323ba1f49e511 100644 (file)
@@ -130,7 +130,7 @@ struct EDNS0Record
 
 static_assert(sizeof(EDNS0Record) == 4, "EDNS0Record size must be 4");
 
-#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
+#if defined(__FreeBSD__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
 #include <machine/endian.h>
 #elif __linux__ || __GNU__
 # include <endian.h>
index 40aa405eaf3894b63598247af3d4fcf4c601c651..87bcb8a11385c0486b6a32a60f572bf5eb28bcc0 100644 (file)
@@ -23,7 +23,7 @@
 #include "sodcrypto.hh"
 #include "pwd.h"
 
-#if defined (__OpenBSD__)
+#if defined (__OpenBSD__) || defined(__NetBSD__)
 #include <readline/readline.h>
 #include <readline/history.h>
 #else
index c3018e0bd018c460386a524b5e73ff47378761ff..c5578b6cc6fdf9f6b9aa4762bb0527a2f8c544b5 100644 (file)
@@ -27,7 +27,7 @@
 #include <limits>
 #include "dolog.hh"
 
-#if defined (__OpenBSD__)
+#if defined (__OpenBSD__) || defined(__NetBSD__)
 #include <readline/readline.h>
 #else
 #include <editline/readline.h>
index d6facc02958f314afa2bf0bcc25e26fc317638a7..b2d512182a2837c168fe02a7c7061951295b9660 100644 (file)
@@ -146,7 +146,11 @@ bool HarvestTimestamp(struct msghdr* msgh, struct timeval* tv)
 bool HarvestDestinationAddress(const struct msghdr* msgh, ComboAddress* destination)
 {
   memset(destination, 0, sizeof(*destination));
+#ifdef __NetBSD__
+  struct cmsghdr* cmsg;
+#else
   const struct cmsghdr* cmsg;
+#endif
   for (cmsg = CMSG_FIRSTHDR(msgh); cmsg != NULL; cmsg = CMSG_NXTHDR(const_cast<struct msghdr*>(msgh), const_cast<struct cmsghdr*>(cmsg))) {
 #if defined(IP_PKTINFO)
      if ((cmsg->cmsg_level == IPPROTO_IP) && (cmsg->cmsg_type == IP_PKTINFO)) {
index 8ab4f13c3473311d8e82625e461e26eabc95165e..b6cf7b4bd6213802a8487fb1c80d6978231ea55a 100644 (file)
 #include <sys/endian.h>
 #endif
 
+#if defined(__NetBSD__) && defined(IP_PKTINFO) && !defined(IP_SENDSRCADDR)
+// The IP_PKTINFO option in NetBSD was incompatible with Linux until a
+// change that also introduced IP_SENDSRCADDR for FreeBSD compatibility.
+#undef IP_PKTINFO
+#endif
+
 union ComboAddress {
   struct sockaddr_in sin4;
   struct sockaddr_in6 sin6;
@@ -992,6 +998,7 @@ int SSetsockopt(int sockfd, int level, int opname, int value);
 #elif defined(IP_RECVDSTADDR)
   #define GEN_IP_PKTINFO IP_RECVDSTADDR 
 #endif
+
 bool IsAnyAddress(const ComboAddress& addr);
 bool HarvestDestinationAddress(const struct msghdr* msgh, ComboAddress* destination);
 bool HarvestTimestamp(struct msghdr* msgh, struct timeval* tv);
index b3510c501fe1880c86bf9594f8007ffc8c383669..2fb66c8c78bd1dcdd3112ce23f2f66b2a642876f 100644 (file)
@@ -28,7 +28,7 @@
 #include <unistd.h>
 #include "misc.hh"
 #include <sys/types.h>
-#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__NetBSD__)
 #include <sys/event.h>
 #endif
 #include <sys/time.h>
index 88e05802e035a46a53e85c96c1988e4be6b93590..8dc5d4b360e3db1d1dca0a59c65c1ee24689cd19 100644 (file)
 #ifdef __FreeBSD__
 #  include <pthread_np.h>
 #endif
+#ifdef __NetBSD__
+#  include <pthread.h>
+#  include <sched.h>
+#endif
 
 bool g_singleThreaded;
 
@@ -866,7 +870,7 @@ void addCMsgSrcAddr(struct msghdr* msgh, void* cmsgbuf, const ComboAddress* sour
     pkt->ipi6_ifindex = itfIndex;
   }
   else {
-#ifdef IP_PKTINFO
+#if defined(IP_PKTINFO)
     struct in_pktinfo *pkt;
 
     msgh->msg_control = cmsgbuf;
@@ -881,8 +885,7 @@ void addCMsgSrcAddr(struct msghdr* msgh, void* cmsgbuf, const ComboAddress* sour
     memset(pkt, 0, sizeof(*pkt));
     pkt->ipi_spec_dst = source->sin4.sin_addr;
     pkt->ipi_ifindex = itfIndex;
-#endif
-#ifdef IP_SENDSRCADDR
+#elif defined(IP_SENDSRCADDR)
     struct in_addr *in;
 
     msgh->msg_control = cmsgbuf;
@@ -1329,9 +1332,20 @@ bool isSettingThreadCPUAffinitySupported()
 int mapThreadToCPUList(pthread_t tid, const std::set<int>& cpus)
 {
 #ifdef HAVE_PTHREAD_SETAFFINITY_NP
-#  ifdef __FreeBSD__
-#    define cpu_set_t cpuset_t
-#  endif
+#  ifdef __NetBSD__
+  cpuset_t *cpuset;
+  cpuset = cpuset_create();
+  for (const auto cpuID : cpus) {
+    cpuset_set(cpuID, cpuset);
+  }
+
+  return pthread_setaffinity_np(tid,
+                                cpuset_size(cpuset),
+                                cpuset);
+#  else
+#    ifdef __FreeBSD__
+#      define cpu_set_t cpuset_t
+#    endif
   cpu_set_t cpuset;
   CPU_ZERO(&cpuset);
   for (const auto cpuID : cpus) {
@@ -1341,6 +1355,7 @@ int mapThreadToCPUList(pthread_t tid, const std::set<int>& cpus)
   return pthread_setaffinity_np(tid,
                                 sizeof(cpuset),
                                 &cpuset);
+#  endif
 #endif /* HAVE_PTHREAD_SETAFFINITY_NP */
   return ENOSYS;
 }