pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kea: add fixes from kea-git



Module Name:	pkgsrc-wip
Committed By:	Niclas Rosenvik <youremailsarecrap%gmail.com@localhost>
Pushed By:	nros
Date:		Fri Jan 17 17:59:51 2020 +0000
Changeset:	2e4b2b24f9cd57fbb0c97ea3ba999b8954bd90ab

Modified Files:
	kea/distinfo
	kea/options.mk
	kea/patches/patch-configure.ac
	kea/patches/patch-src_lib_dhcp_iface__mgr__sun.cc
	kea/patches/patch-src_lib_dhcp_pkt__filter__inet.cc
Added Files:
	kea/patches/patch-src_bin_dhcp4_tests_parser__unittest.cc
	kea/patches/patch-src_bin_dhcp6_tests_parser__unittest.cc
	kea/patches/patch-src_lib_dhcp_tests_Makefile.am
	kea/patches/patch-src_lib_dhcp_tests_iface__mgr__unittest.cc
	kea/patches/patch-src_lib_util_signal__set.cc

Log Message:
kea: add fixes from kea-git

Add fixes to kea that are in the kea-git package.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=2e4b2b24f9cd57fbb0c97ea3ba999b8954bd90ab

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 kea/distinfo                                       |  11 ++-
 kea/options.mk                                     |   7 +-
 kea/patches/patch-configure.ac                     |  12 ++-
 .../patch-src_bin_dhcp4_tests_parser__unittest.cc  |  18 ++++
 .../patch-src_bin_dhcp6_tests_parser__unittest.cc  |  18 ++++
 kea/patches/patch-src_lib_dhcp_iface__mgr__sun.cc  | 104 ++++++++++++++++++++-
 .../patch-src_lib_dhcp_pkt__filter__inet.cc        |  28 ++++--
 kea/patches/patch-src_lib_dhcp_tests_Makefile.am   |  17 ++++
 ...atch-src_lib_dhcp_tests_iface__mgr__unittest.cc |  34 +++++++
 kea/patches/patch-src_lib_util_signal__set.cc      |  32 +++++++
 10 files changed, 267 insertions(+), 14 deletions(-)

diffs:
diff --git a/kea/distinfo b/kea/distinfo
index 1368d813d1..002abeeafc 100644
--- a/kea/distinfo
+++ b/kea/distinfo
@@ -5,17 +5,22 @@ RMD160 (kea-1.6.1.tar.gz) = 261b0ea1bca0a70034532112011c64ad809c37ec
 SHA512 (kea-1.6.1.tar.gz) = 4220f46fc185f4434ad01886d2d43ba1f9dcca57f5afa33235c8593269220a79e2dcb4ad71298dec868444c29e7cb6febe66a1456fdc116a2d9fd3f019f740d8
 Size (kea-1.6.1.tar.gz) = 7155604 bytes
 SHA1 (patch-Makefile.am) = 4e4896be44290114160be878666878bb44d71a8e
-SHA1 (patch-configure.ac) = 70d7a8235ed6459a23f5404303d5babfdfec14db
+SHA1 (patch-configure.ac) = e6ef32f92a70d248749e72e627d8fde11fb50805
 SHA1 (patch-src_bin_agent_agent__lexer.ll) = de64c9ad03b1c6812f95f52c8fcd5f6c1aa1ef27
 SHA1 (patch-src_bin_d2_d2__lexer.ll) = 400b9f54b5bb9c9eb9c52c1ef23c9a377f29960e
 SHA1 (patch-src_bin_dhcp4_dhcp4__lexer.ll) = dfcca8319ca3b6b8902676bb1662ceb9abca74bc
+SHA1 (patch-src_bin_dhcp4_tests_parser__unittest.cc) = 6f213d5abd286b57c41b6fad27ada49c9301857a
 SHA1 (patch-src_bin_dhcp6_dhcp6__lexer.ll) = 6ebeb6b18dc8d86d0890ce3cfcaeea4c2658e958
+SHA1 (patch-src_bin_dhcp6_tests_parser__unittest.cc) = f671c6b5c26a6b6179971f2f10af8e2b1b8b7e6a
 SHA1 (patch-src_bin_keactrl_Makefile.am) = 5b6fd816da6011858d1167d297c83eda7947efd7
 SHA1 (patch-src_bin_netconf_netconf__lexer.ll) = ec316d436f791470df9dd5c106c76f3026a19b0e
 SHA1 (patch-src_lib_dhcp_Makefile.am) = 452036d0100a85f41c52562292931bea2501e396
-SHA1 (patch-src_lib_dhcp_iface__mgr__sun.cc) = 7bf79c4a24b3c074f8cf53b79fc83ae8255f63d7
-SHA1 (patch-src_lib_dhcp_pkt__filter__inet.cc) = 979ca0bd1d87bdaf3bf54b3e11b18fef72ecc860
+SHA1 (patch-src_lib_dhcp_iface__mgr__sun.cc) = ca4330b27adfa12b1ff6c6cc54c8c30f89f9851f
+SHA1 (patch-src_lib_dhcp_pkt__filter__inet.cc) = 32f70306483a719a8b400eff613cdbb935fe9cd0
+SHA1 (patch-src_lib_dhcp_tests_Makefile.am) = 9ee63ba82b05d02ea88e3a74183a7aa6da7b36c9
+SHA1 (patch-src_lib_dhcp_tests_iface__mgr__unittest.cc) = 8e274dbb5d9897ccd1708e4007cbe69ab2db0ef5
 SHA1 (patch-src_lib_dhcpsrv_Makefile.am) = bdd2be227d8c7f34b4329092e6de3bcaa7117284
 SHA1 (patch-src_lib_dhcpsrv_host__data__source__factory.cc) = a1bc71ec40b9eb5a6c9247360a84ce480521cad2
 SHA1 (patch-src_lib_util_encode_base__n.cc) = 61bf8402e4baf0578a7ec9444f396a9b6c69d87d
+SHA1 (patch-src_lib_util_signal__set.cc) = f060fcedecb8ccdda997fbef2040dab82c620cb0
 SHA1 (patch-src_lib_util_watch__socket.cc) = ab55b5e613bc431dcd92ef68bf3501a7e4aca7de
diff --git a/kea/options.mk b/kea/options.mk
index 06ca40e594..4303a95a37 100644
--- a/kea/options.mk
+++ b/kea/options.mk
@@ -1,7 +1,7 @@
 # $NetBSD$
 
 PKG_OPTIONS_VAR=		PKG_OPTIONS.kea
-PKG_SUPPORTED_OPTIONS=		mysql pgsql
+PKG_SUPPORTED_OPTIONS=		mysql pgsql tests
 PKG_SUGGESTED_OPTIONS=		mysql pgsql
 PLIST_VARS+=			mysql pgsql
 
@@ -22,3 +22,8 @@ PLIST.mysql=yes
 CONFIGURE_ARGS+=--with-pgsql=${PGSQL_PREFIX}/bin/pg_config
 PLIST.pgsql=yes
 .endif
+
+.if !empty(PKG_OPTIONS:Mtests)
+.  include "../../devel/googletest/buildlink3.mk"
+CONFIGURE_ARGS+=--with-gtest=${BUILDLINK_PREFIX.googletest}
+.endif
diff --git a/kea/patches/patch-configure.ac b/kea/patches/patch-configure.ac
index f287b9208b..0ffb32a549 100644
--- a/kea/patches/patch-configure.ac
+++ b/kea/patches/patch-configure.ac
@@ -1,9 +1,19 @@
 $NetBSD$
 
+* fix typo to find googletest
 * fix compatability errors
 
---- configure.ac.orig	2019-12-30 16:00:16.704565254 +0000
+--- configure.ac.orig	2019-11-19 14:50:46.000000000 +0000
 +++ configure.ac
+@@ -1148,7 +1148,7 @@ if test "x$enable_gtest" = "xyes" ; then
+             GTEST_FOUND="false"
+             for dir in $GTEST_PATHS; do
+                 if test -f "$dir/include/gtest/gtest.h"; then
+-                    if ! test -f "$dir/lib/libgtests.a"; then
++                    if ! test -f "$dir/lib/libgtest.a"; then
+                         AC_MSG_WARN([Found Google Test include but not the library in $dir.])
+                         continue
+                     fi
 @@ -1391,7 +1391,7 @@ if test "x$enable_generate_parser" != "x
         AC_MSG_ERROR([Flex is required for enable-generate-parser, but was not found])
      fi
diff --git a/kea/patches/patch-src_bin_dhcp4_tests_parser__unittest.cc b/kea/patches/patch-src_bin_dhcp4_tests_parser__unittest.cc
new file mode 100644
index 0000000000..ece57449e6
--- /dev/null
+++ b/kea/patches/patch-src_bin_dhcp4_tests_parser__unittest.cc
@@ -0,0 +1,18 @@
+$NetBSD$
+
+* put inclusion of asiolink on top so that std::map does not conlict with
+  map in net/if.h on illumos
+
+--- src/bin/dhcp4/tests/parser_unittest.cc.orig	2020-01-02 23:01:48.000000000 +0000
++++ src/bin/dhcp4/tests/parser_unittest.cc
+@@ -6,9 +6,9 @@
+ 
+ #include <config.h>
+ 
++#include <dhcpsrv/parsers/simple_parser4.h>
+ #include <gtest/gtest.h>
+ #include <dhcp4/parser_context.h>
+-#include <dhcpsrv/parsers/simple_parser4.h>
+ #include <testutils/io_utils.h>
+ #include <testutils/user_context_utils.h>
+ 
diff --git a/kea/patches/patch-src_bin_dhcp6_tests_parser__unittest.cc b/kea/patches/patch-src_bin_dhcp6_tests_parser__unittest.cc
new file mode 100644
index 0000000000..d31b671012
--- /dev/null
+++ b/kea/patches/patch-src_bin_dhcp6_tests_parser__unittest.cc
@@ -0,0 +1,18 @@
+$NetBSD$
+
+* put inclusion of asiolonk first so that map from net/if.h on illumos 
+  won't confict with std::map
+
+--- src/bin/dhcp6/tests/parser_unittest.cc.orig	2020-01-02 23:01:48.000000000 +0000
++++ src/bin/dhcp6/tests/parser_unittest.cc
+@@ -6,9 +6,9 @@
+ 
+ #include <config.h>
+ 
++#include <dhcpsrv/parsers/simple_parser6.h>
+ #include <gtest/gtest.h>
+ #include <dhcp6/parser_context.h>
+-#include <dhcpsrv/parsers/simple_parser6.h>
+ #include <testutils/io_utils.h>
+ #include <testutils/user_context_utils.h>
+ 
diff --git a/kea/patches/patch-src_lib_dhcp_iface__mgr__sun.cc b/kea/patches/patch-src_lib_dhcp_iface__mgr__sun.cc
index e29b6c9c0e..d31b5babb9 100644
--- a/kea/patches/patch-src_lib_dhcp_iface__mgr__sun.cc
+++ b/kea/patches/patch-src_lib_dhcp_iface__mgr__sun.cc
@@ -1,15 +1,115 @@
 $NetBSD$
 
 * map conflicts with map from net/if.h, use std::map explicitly
+* enable bpf filter
+* get the mac adresses the right way on illumos
+  based on illumos-ims.diff from
+  https://gitlab.isc.org/isc-projects/kes/issues/631
+  copyright ISC licensed under mpl-2.0
+  https://www.mozilla.org/en-US/MPL/2.0/
 
---- src/lib/dhcp/iface_mgr_sun.cc.orig	2019-11-19 14:50:43.000000000 +0000
+--- src/lib/dhcp/iface_mgr_sun.cc.orig	2020-01-02 23:01:48.000000000 +0000
 +++ src/lib/dhcp/iface_mgr_sun.cc
-@@ -39,7 +39,7 @@ IfaceMgr::detectIfaces() {
+@@ -10,6 +10,7 @@
+ 
+ #include <dhcp/iface_mgr.h>
+ #include <dhcp/iface_mgr_error_handler.h>
++#include <dhcp/pkt_filter_bpf.h>
+ #include <dhcp/pkt_filter_inet.h>
+ #include <exceptions/exceptions.h>
+ 
+@@ -39,7 +40,12 @@ IfaceMgr::detectIfaces() {
          isc_throw(Unexpected, "Network interfaces detection failed.");
      }
  
 -    typedef map<string, IfacePtr> IfaceLst;
++    int sock = socket(PF_INET, SOCK_DGRAM, 0);
++    if (sock < 0) {
++        isc_throw(Unexpected, "Can't get a socket.");
++    }
++
 +    typedef std::map<string, IfacePtr> IfaceLst;
      IfaceLst::iterator iface_iter;
      IfaceLst ifaces;
  
+@@ -51,6 +57,7 @@ IfaceMgr::detectIfaces() {
+         if (!(ifindex = if_nametoindex(ifname))) {
+             // Interface name does not have corresponding index ...
+             freeifaddrs(iflist);
++            close(sock);
+             isc_throw(Unexpected, "Interface " << ifname << " has no index");
+         }
+ 
+@@ -62,9 +69,26 @@ IfaceMgr::detectIfaces() {
+         IfacePtr iface(new Iface(ifname, ifindex));
+         iface->setFlags(ifptr->ifa_flags);
+         ifaces.insert(pair<string, IfacePtr>(ifname, iface));
++
++        // Get the MAC address.
++        struct lifreq lif;
++        memset(&lif, 0, sizeof(lif));
++        if (strlcpy(lif.lifr_name, ifname, LIFNAMSIZ) > LIFNAMSIZ) {
++           freeifaddrs(iflist);
++           close(sock);
++           isc_throw(Unexpected, "ifname to long for lifr_name in iface_mrg_sun");
++        }
++        if (ioctl(sock, SIOCGLIFHWADDR, &lif) < 0) {
++            continue;
++        }
++        struct sockaddr_dl * ldata =
++            reinterpret_cast<struct sockaddr_dl *>(&lif.lifr_addr);
++        const uint8_t * ptr = reinterpret_cast<uint8_t *>(LLADDR(ldata));
++        iface->setHWType(ldata->sdl_type);
++        iface->setMac(ptr, ldata->sdl_alen);
+     }
+ 
+-    // Second lookup to get MAC and IP addresses
++    // Second lookup to get IP addresses
+     for (ifptr = iflist; ifptr != 0; ifptr = ifptr->ifa_next) {
+         iface_iter = ifaces.find(ifptr->ifa_name);
+         if (iface_iter == ifaces.end()) {
+@@ -72,15 +96,7 @@ IfaceMgr::detectIfaces() {
+         }
+         // Common byte pointer for following data
+         const uint8_t * ptr = 0;
+-        if(ifptr->ifa_addr->sa_family == AF_LINK) {
+-            // HWAddr
+-            struct sockaddr_dl * ldata =
+-                reinterpret_cast<struct sockaddr_dl *>(ifptr->ifa_addr);
+-            ptr = reinterpret_cast<uint8_t *>(LLADDR(ldata));
+-
+-            iface_iter->second->setHWType(ldata->sdl_type);
+-            iface_iter->second->setMac(ptr, ldata->sdl_alen);
+-        } else if(ifptr->ifa_addr->sa_family == AF_INET6) {
++        if(ifptr->ifa_addr->sa_family == AF_INET6) {
+             // IPv6 Addr
+             struct sockaddr_in6 * adata =
+                 reinterpret_cast<struct sockaddr_in6 *>(ifptr->ifa_addr);
+@@ -100,6 +116,7 @@ IfaceMgr::detectIfaces() {
+     }
+ 
+     freeifaddrs(iflist);
++    close(sock);
+ 
+     // Interfaces registering
+     for(IfaceLst::const_iterator iface_iter = ifaces.begin();
+@@ -124,10 +141,17 @@ void Iface::setFlags(uint64_t flags) {
+ }
+ 
+ void
+-IfaceMgr::setMatchingPacketFilter(const bool /* direct_response_desired */) {
++IfaceMgr::setMatchingPacketFilter(const bool direct_response_desired) {
+     // @todo Currently we ignore the preference to use direct traffic
+     // because it hasn't been implemented for Solaris.
+-    setPacketFilter(PktFilterPtr(new PktFilterInet()));
++    // Fixed: solaris/illumos now supports bpf
++    if (direct_response_desired) {
++        setPacketFilter(PktFilterPtr(new PktFilterBPF()));
++
++    } else {
++        setPacketFilter(PktFilterPtr(new PktFilterInet()));
++
++    }
+ }
+ 
+ bool
diff --git a/kea/patches/patch-src_lib_dhcp_pkt__filter__inet.cc b/kea/patches/patch-src_lib_dhcp_pkt__filter__inet.cc
index b084e4b776..132794c690 100644
--- a/kea/patches/patch-src_lib_dhcp_pkt__filter__inet.cc
+++ b/kea/patches/patch-src_lib_dhcp_pkt__filter__inet.cc
@@ -1,21 +1,35 @@
 $NetBSD$
+
 * illumos uses ip_pktinfo just like linux
---- src/lib/dhcp/pkt_filter_inet.cc.orig	2019-11-19 14:50:43.000000000 +0000
+
+--- src/lib/dhcp/pkt_filter_inet.cc.orig	2020-01-02 23:01:48.000000000 +0000
 +++ src/lib/dhcp/pkt_filter_inet.cc
-@@ -86,9 +86,9 @@ PktFilterInet::openSocket(Iface& iface,
+@@ -86,8 +86,8 @@ PktFilterInet::openSocket(Iface& iface,
                    << "/port=" << port);
      }
  
 -    // On Linux systems IP_PKTINFO socket option is supported. This
 -    // option is used to retrieve destination address of the packet.
--#if defined (IP_PKTINFO) && defined (OS_LINUX)
 +    // On Linux and Solaris systems IP_PKTINFO socket option is supported.
 +    // This option is used to retrieve destination address of the packet.
-+#if defined (IP_PKTINFO) && (defined (OS_LINUX) || defined (OS_SOLARIS))
+ #if defined (IP_PKTINFO) && defined (OS_LINUX)
      int flag = 1;
      if (setsockopt(sock, IPPROTO_IP, IP_PKTINFO, &flag, sizeof(flag)) != 0) {
-         close(sock);
-@@ -167,7 +167,7 @@ PktFilterInet::receive(Iface& iface, con
+@@ -95,6 +95,13 @@ PktFilterInet::openSocket(Iface& iface,
+         isc_throw(SocketConfigError, "setsockopt: IP_PKTINFO: failed.");
+     }
+ 
++#elif defined (IP_RECVPKTINFO) && defined (OS_SOLARIS)
++    int flag = 1;
++    if (setsockopt(sock, IPPROTO_IP, IP_RECVPKTINFO, &flag, sizeof(flag)) != 0) {
++        close(sock);
++        isc_throw(SocketConfigError, "setsockopt: IP_RECVPKTINFO: failed.");
++    }
++
+     // On BSD systems IP_RECVDSTADDR is used instead of IP_PKTINFO.
+ #elif defined (IP_RECVDSTADDR) && defined (OS_BSD)
+     int flag = 1;
+@@ -167,7 +174,7 @@ PktFilterInet::receive(Iface& iface, con
  // Linux systems support IP_PKTINFO option which is used to retrieve the
  // destination address of the received packet. On BSD systems IP_RECVDSTADDR
  // is used instead.
@@ -24,7 +38,7 @@ $NetBSD$
      struct in_pktinfo* pktinfo;
      struct cmsghdr* cmsg = CMSG_FIRSTHDR(&m);
  
-@@ -243,7 +243,7 @@ PktFilterInet::send(const Iface&, uint16
+@@ -243,7 +250,7 @@ PktFilterInet::send(const Iface&, uint16
  // In the future the OS-specific code may be abstracted to a different
  // file but for now we keep it here because there is no code yet, which
  // is specific to non-Linux systems.
diff --git a/kea/patches/patch-src_lib_dhcp_tests_Makefile.am b/kea/patches/patch-src_lib_dhcp_tests_Makefile.am
new file mode 100644
index 0000000000..4f5223f68f
--- /dev/null
+++ b/kea/patches/patch-src_lib_dhcp_tests_Makefile.am
@@ -0,0 +1,17 @@
+$NetBSD$
+
+* illumos uses bpf
+
+--- src/lib/dhcp/tests/Makefile.am.orig	2020-01-02 23:01:48.000000000 +0000
++++ src/lib/dhcp/tests/Makefile.am
+@@ -97,6 +97,10 @@ if OS_BSD
+ libdhcp___unittests_SOURCES += pkt_filter_bpf_unittest.cc
+ endif
+ 
++if OS_SOLARIS
++libdhcp___unittests_SOURCES += pkt_filter_bpf_unittest.cc
++endif
++
+ libdhcp___unittests_SOURCES += protocol_util_unittest.cc
+ libdhcp___unittests_SOURCES += duid_unittest.cc
+ 
diff --git a/kea/patches/patch-src_lib_dhcp_tests_iface__mgr__unittest.cc b/kea/patches/patch-src_lib_dhcp_tests_iface__mgr__unittest.cc
new file mode 100644
index 0000000000..e466453642
--- /dev/null
+++ b/kea/patches/patch-src_lib_dhcp_tests_iface__mgr__unittest.cc
@@ -0,0 +1,34 @@
+$NetBSD$
+
+* enable test on illumos
+* use ifru_addr_sa that is available both on illumos and linux
+
+--- src/lib/dhcp/tests/iface_mgr_unittest.cc.orig	2020-01-02 23:01:48.000000000 +0000
++++ src/lib/dhcp/tests/iface_mgr_unittest.cc
+@@ -1569,7 +1569,7 @@ TEST_F(IfaceMgrTest, setPacketFilter6) {
+ }
+ 
+ 
+-#if defined OS_LINUX || OS_BSD
++#if defined OS_LINUX || OS_BSD || OS_SOLARIS
+ 
+ // This test is only supported on Linux and BSD systems. It checks
+ // if it is possible to use the IfaceMgr to select the packet filter
+@@ -2600,7 +2600,7 @@ checkIfFlags(const Iface & iface,
+ bool
+ checkIfAddrs(const Iface & iface, struct ifaddrs *& ifptr) {
+     const unsigned char * p = 0;
+-#if defined(OS_LINUX)
++#if defined(OS_LINUX) || defined(OS_SOLARIS)
+     // Workaround for Linux ...
+     if(ifptr->ifa_data != 0) {
+         // We avoid localhost as it has no MAC Address
+@@ -2624,7 +2624,7 @@ checkIfAddrs(const Iface & iface, struct
+         }
+ 
+         const uint8_t * p =
+-            reinterpret_cast<uint8_t *>(ifr.ifr_ifru.ifru_hwaddr.sa_data);
++            reinterpret_cast<uint8_t *>(ifr.ifr_ifru.ifru_addr.sa_data);
+ 
+         close(s);
+ 
diff --git a/kea/patches/patch-src_lib_util_signal__set.cc b/kea/patches/patch-src_lib_util_signal__set.cc
new file mode 100644
index 0000000000..7bc6966c22
--- /dev/null
+++ b/kea/patches/patch-src_lib_util_signal__set.cc
@@ -0,0 +1,32 @@
+$NetBSD$
+
+* setting SIG_IGN on SIGCHLD removes the result from the child that triggered
+  the signal on solaris/illumos
+
+--- src/lib/util/signal_set.cc.orig	2020-01-10 08:19:15.723309083 +0000
++++ src/lib/util/signal_set.cc
+@@ -118,11 +118,22 @@ SignalSet::invokeOnReceiptHandler(int si
+     struct sigaction sa;
+     struct sigaction prev_sa;
+     memset(&sa, 0, sizeof(sa));
+-    sa.sa_handler = SIG_IGN;
++    
++    if (sig == SIGCHLD) {
++        sa.sa_handler = SIG_DFL;
++    } else {
++        sa.sa_handler = SIG_IGN;
++    }
+     if (sigaction(sig, &sa, &prev_sa) < 0) {
+         // Highly unlikely we can get here.
++        std::string sig_type;
++        if (sa.sa_handler == SIG_DFL) {
++            sig_type = "SIG_DFL";
++        } else {
++            sig_type = "SIG_IGN";
++        }
+         const char* errmsg = strerror(errno);
+-        isc_throw(SignalSetError, "failed to set SIG_IGN for signal "
++        isc_throw(SignalSetError, "failed to set " << sig_type << " for signal "
+                   << sig << ": " << errmsg);
+     }
+ 


Home | Main Index | Thread Index | Old Index